Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dc6b821

Browse files
committed
Remove duplicated code left behind by my recent refactoring of comment.c
These checks are also present in objectaddress.c, so there's no need to recheck here.
1 parent 54d0e28 commit dc6b821

File tree

1 file changed

+4
-48
lines changed

1 file changed

+4
-48
lines changed

src/backend/commands/comment.c

+4-48
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
*
99
* 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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -38,7 +38,6 @@
3838
* object types require something more complex; for those, we define helper
3939
* functions.
4040
*/
41-
static void CheckRelationComment(int objtype, Relation relation);
4241
static void CheckAttributeComment(Relation relation);
4342
static void CheckCastComment(List *qualname, List *arguments);
4443

@@ -92,7 +91,9 @@ CommentObject(CommentStmt *stmt)
9291
case OBJECT_SEQUENCE:
9392
case OBJECT_TABLE:
9493
case OBJECT_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));
9697
break;
9798
case OBJECT_COLUMN:
9899
CheckAttributeComment(relation);
@@ -561,51 +562,6 @@ GetComment(Oid oid, Oid classoid, int32 subid)
561562
return comment;
562563
}
563564

564-
/*
565-
* Check whether the user is allowed to comment on this relation.
566-
*/
567-
static void
568-
CheckRelationComment(int objtype, Relation relation)
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-
case OBJECT_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-
case OBJECT_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-
case OBJECT_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-
case OBJECT_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-
609565
/*
610566
* Check whether the user is allowed to comment on an attribute of the
611567
* specified relation.

0 commit comments

Comments
 (0)