]> granicus.if.org Git - postgresql/commitdiff
Allow COMMENT ON COLUMN with partitioned tables
authorSimon Riggs <simon@2ndQuadrant.com>
Tue, 18 Apr 2017 09:42:10 +0000 (10:42 +0100)
committerSimon Riggs <simon@2ndQuadrant.com>
Tue, 18 Apr 2017 09:42:10 +0000 (10:42 +0100)
Amit Langote

src/backend/commands/comment.c
src/test/regress/expected/create_table.out
src/test/regress/sql/create_table.sql

index b5569bddaf2e65c9614bf18972cdd55134e64a81..1c17927c499d7d4a706f4578d9eb1b605b85066d 100644 (file)
@@ -94,7 +94,8 @@ CommentObject(CommentStmt *stmt)
                                relation->rd_rel->relkind != RELKIND_VIEW &&
                                relation->rd_rel->relkind != RELKIND_MATVIEW &&
                                relation->rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
-                               relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE)
+                               relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
+                               relation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
                                ereport(ERROR,
                                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                                 errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
index 6f8645ddbd13093d521c99f7bb0765721865f370..b6c75d2e81fb67f8cc4b4d0f424c827ec20e0594 100644 (file)
@@ -669,3 +669,22 @@ Number of partitions: 3 (Use \d+ to list them.)
 
 -- cleanup
 DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3;
+-- comments on partitioned tables columns
+CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a);
+COMMENT ON TABLE parted_col_comment IS 'Am partitioned table';
+COMMENT ON COLUMN parted_col_comment.a IS 'Partition key';
+SELECT obj_description('parted_col_comment'::regclass);
+   obj_description    
+----------------------
+ Am partitioned table
+(1 row)
+
+\d+ parted_col_comment
+                              Table "public.parted_col_comment"
+ Column |  Type   | Collation | Nullable | Default | Storage  | Stats target |  Description  
+--------+---------+-----------+----------+---------+----------+--------------+---------------
+ a      | integer |           |          |         | plain    |              | Partition key
+ b      | text    |           |          |         | extended |              | 
+Partition key: LIST (a)
+
+DROP TABLE parted_col_comment;
index 1f0fa8e16d8ee1be31c3d78565492c1e8f3b671c..b00d9e87b823a8f5c2ffa1a69b749a7274fb5952 100644 (file)
@@ -597,3 +597,11 @@ CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10);
 
 -- cleanup
 DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3;
+
+-- comments on partitioned tables columns
+CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a);
+COMMENT ON TABLE parted_col_comment IS 'Am partitioned table';
+COMMENT ON COLUMN parted_col_comment.a IS 'Partition key';
+SELECT obj_description('parted_col_comment'::regclass);
+\d+ parted_col_comment
+DROP TABLE parted_col_comment;