Comments not allowed on partitioned table columns

Started by Amit Langoteover 8 years ago4 messages
#1Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
1 attachment(s)

Attached patch fixes the oversight that COMMENT ON COLUMN is not allowed
on partitioned tables columns.

Thanks,
Amit

Attachments:

0001-Allow-COMMENT-ON-partitioned-table-columns.patchtext/x-diff; name=0001-Allow-COMMENT-ON-partitioned-table-columns.patchDownload
From cfc0717478f2a73087c85d67d73e557aaccb4f78 Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Tue, 18 Apr 2017 14:48:37 +0900
Subject: [PATCH] Allow COMMENT ON partitioned table columns

---
 src/backend/commands/comment.c             |  3 ++-
 src/test/regress/expected/create_table.out | 19 +++++++++++++++++++
 src/test/regress/sql/create_table.sql      |  8 ++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index b5569bddaf..1c17927c49 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -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",
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index 6f8645ddbd..b6c75d2e81 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -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;
diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql
index 1f0fa8e16d..b00d9e87b8 100644
--- a/src/test/regress/sql/create_table.sql
+++ b/src/test/regress/sql/create_table.sql
@@ -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;
-- 
2.11.0

#2Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
In reply to: Amit Langote (#1)
Re: Comments not allowed on partitioned table columns

On 2017/04/18 14:50, Amit Langote wrote:

Attached patch fixes the oversight that COMMENT ON COLUMN is not allowed
on partitioned tables columns.

Forgot to mention that I added this to the open items list.

Thanks,
Amit

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Simon Riggs
simon@2ndquadrant.com
In reply to: Amit Langote (#2)
Re: Comments not allowed on partitioned table columns

On 18 April 2017 at 06:57, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> wrote:

On 2017/04/18 14:50, Amit Langote wrote:

Attached patch fixes the oversight that COMMENT ON COLUMN is not allowed
on partitioned tables columns.

Forgot to mention that I added this to the open items list.

Pushed, thanks.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
In reply to: Simon Riggs (#3)
Re: Comments not allowed on partitioned table columns

On 2017/04/18 18:45, Simon Riggs wrote:

On 18 April 2017 at 06:57, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> wrote:

On 2017/04/18 14:50, Amit Langote wrote:

Attached patch fixes the oversight that COMMENT ON COLUMN is not allowed
on partitioned tables columns.

Forgot to mention that I added this to the open items list.

Pushed, thanks.

Thanks.

Regards,
Amit

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers