1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +03:00

Disallow comments on columns of relation types other than tables, views,

and composite types, which are the only relkinds for which pg_dump support
exists for dumping column comments.  There is no obvious usefulness for
comments on columns of sequences or toast tables; and while comments on
index columns might have some value, it's not worth the risk of compatibility
problems due to possible changes in the algorithm for assigning names to
index columns.  Per discussion.

In consequence, remove now-dead code for copying such comments in CREATE TABLE
LIKE.
This commit is contained in:
Tom Lane
2009-12-22 23:54:17 +00:00
parent de0d75ea24
commit b7d6795445
4 changed files with 26 additions and 53 deletions

View File

@@ -7,7 +7,7 @@
* Copyright (c) 1996-2009, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.110 2009/12/21 01:34:11 rhaas Exp $
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.111 2009/12/22 23:54:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -627,6 +627,22 @@ CommentAttribute(List *qualname, char *comment)
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
RelationGetRelationName(relation));
/*
* Allow comments only on columns of tables, views, and composite types
* (which are the only relkinds for which pg_dump will dump per-column
* comments). In particular we wish to disallow comments on index
* columns, because the naming of an index's columns may change across
* PG versions, so dumping per-column comments could create reload
* failures.
*/
if (relation->rd_rel->relkind != RELKIND_RELATION &&
relation->rd_rel->relkind != RELKIND_VIEW &&
relation->rd_rel->relkind != RELKIND_COMPOSITE_TYPE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a table, view, or composite type",
RelationGetRelationName(relation))));
/* Now, fetch the attribute number from the system cache */
attnum = get_attnum(RelationGetRelid(relation), attrname);