|
7 | 7 | * Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.118 2010/08/27 11:47:41 rhaas Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.119 2010/09/17 02:49:10 rhaas Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
|
38 | 38 | * object types require something more complex; for those, we define helper
|
39 | 39 | * functions.
|
40 | 40 | */
|
41 |
| -staticvoidCheckRelationComment(intobjtype,Relationrelation); |
42 | 41 | staticvoidCheckAttributeComment(Relationrelation);
|
43 | 42 | staticvoidCheckCastComment(List*qualname,List*arguments);
|
44 | 43 |
|
@@ -92,7 +91,9 @@ CommentObject(CommentStmt *stmt)
|
92 | 91 | caseOBJECT_SEQUENCE:
|
93 | 92 | caseOBJECT_TABLE:
|
94 | 93 | caseOBJECT_VIEW:
|
95 |
| -CheckRelationComment(stmt->objtype,relation); |
| 94 | +if (!pg_class_ownercheck(RelationGetRelid(relation),GetUserId())) |
| 95 | +aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_CLASS, |
| 96 | +RelationGetRelationName(relation)); |
96 | 97 | break;
|
97 | 98 | caseOBJECT_COLUMN:
|
98 | 99 | CheckAttributeComment(relation);
|
@@ -561,51 +562,6 @@ GetComment(Oid oid, Oid classoid, int32 subid)
|
561 | 562 | returncomment;
|
562 | 563 | }
|
563 | 564 |
|
564 |
| -/* |
565 |
| - * Check whether the user is allowed to comment on this relation. |
566 |
| - */ |
567 |
| -staticvoid |
568 |
| -CheckRelationComment(intobjtype,Relationrelation) |
569 |
| -{ |
570 |
| -/* Check object security */ |
571 |
| -if (!pg_class_ownercheck(RelationGetRelid(relation),GetUserId())) |
572 |
| -aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_CLASS, |
573 |
| -RelationGetRelationName(relation)); |
574 |
| - |
575 |
| -/* Next, verify that the relation type matches the intent */ |
576 |
| -switch (objtype) |
577 |
| -{ |
578 |
| -caseOBJECT_INDEX: |
579 |
| -if (relation->rd_rel->relkind!=RELKIND_INDEX) |
580 |
| -ereport(ERROR, |
581 |
| -(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
582 |
| -errmsg("\"%s\" is not an index", |
583 |
| -RelationGetRelationName(relation)))); |
584 |
| -break; |
585 |
| -caseOBJECT_SEQUENCE: |
586 |
| -if (relation->rd_rel->relkind!=RELKIND_SEQUENCE) |
587 |
| -ereport(ERROR, |
588 |
| -(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
589 |
| -errmsg("\"%s\" is not a sequence", |
590 |
| -RelationGetRelationName(relation)))); |
591 |
| -break; |
592 |
| -caseOBJECT_TABLE: |
593 |
| -if (relation->rd_rel->relkind!=RELKIND_RELATION) |
594 |
| -ereport(ERROR, |
595 |
| -(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
596 |
| -errmsg("\"%s\" is not a table", |
597 |
| -RelationGetRelationName(relation)))); |
598 |
| -break; |
599 |
| -caseOBJECT_VIEW: |
600 |
| -if (relation->rd_rel->relkind!=RELKIND_VIEW) |
601 |
| -ereport(ERROR, |
602 |
| -(errcode(ERRCODE_WRONG_OBJECT_TYPE), |
603 |
| -errmsg("\"%s\" is not a view", |
604 |
| -RelationGetRelationName(relation)))); |
605 |
| -break; |
606 |
| -} |
607 |
| -} |
608 |
| - |
609 | 565 | /*
|
610 | 566 | * Check whether the user is allowed to comment on an attribute of the
|
611 | 567 | * specified relation.
|
|