Skip to content

Commit 51175f3

Browse files
Allow COMMENT ON COLUMN with partitioned tables
Amit Langote
1 parent b218857 commit 51175f3

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/backend/commands/comment.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ CommentObject(CommentStmt *stmt)
9494
relation->rd_rel->relkind != RELKIND_VIEW &&
9595
relation->rd_rel->relkind != RELKIND_MATVIEW &&
9696
relation->rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
97-
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
97+
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
98+
relation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
9899
ereport(ERROR,
99100
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
100101
errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",

src/test/regress/expected/create_table.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,22 @@ Number of partitions: 3 (Use \d+ to list them.)
669669

670670
-- cleanup
671671
DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3;
672+
-- comments on partitioned tables columns
673+
CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a);
674+
COMMENT ON TABLE parted_col_comment IS 'Am partitioned table';
675+
COMMENT ON COLUMN parted_col_comment.a IS 'Partition key';
676+
SELECT obj_description('parted_col_comment'::regclass);
677+
obj_description
678+
----------------------
679+
Am partitioned table
680+
(1 row)
681+
682+
\d+ parted_col_comment
683+
Table "public.parted_col_comment"
684+
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
685+
--------+---------+-----------+----------+---------+----------+--------------+---------------
686+
a | integer | | | | plain | | Partition key
687+
b | text | | | | extended | |
688+
Partition key: LIST (a)
689+
690+
DROP TABLE parted_col_comment;

src/test/regress/sql/create_table.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,11 @@ CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10);
597597

598598
-- cleanup
599599
DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3;
600+
601+
-- comments on partitioned tables columns
602+
CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a);
603+
COMMENT ON TABLE parted_col_comment IS 'Am partitioned table';
604+
COMMENT ON COLUMN parted_col_comment.a IS 'Partition key';
605+
SELECT obj_description('parted_col_comment'::regclass);
606+
\d+ parted_col_comment
607+
DROP TABLE parted_col_comment;

0 commit comments

Comments
 (0)