Skip to content
Snippets Groups Projects
Commit dc6b8212 authored by Robert Haas's avatar Robert Haas
Browse files

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.
parent 54d0e288
Branches
Tags
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 1996-2010, PostgreSQL Global Development Group * Copyright (c) 1996-2010, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.118 2010/08/27 11:47:41 rhaas Exp $ * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.119 2010/09/17 02:49:10 rhaas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
* object types require something more complex; for those, we define helper * object types require something more complex; for those, we define helper
* functions. * functions.
*/ */
static void CheckRelationComment(int objtype, Relation relation);
static void CheckAttributeComment(Relation relation); static void CheckAttributeComment(Relation relation);
static void CheckCastComment(List *qualname, List *arguments); static void CheckCastComment(List *qualname, List *arguments);
...@@ -92,7 +91,9 @@ CommentObject(CommentStmt *stmt) ...@@ -92,7 +91,9 @@ CommentObject(CommentStmt *stmt)
case OBJECT_SEQUENCE: case OBJECT_SEQUENCE:
case OBJECT_TABLE: case OBJECT_TABLE:
case OBJECT_VIEW: case OBJECT_VIEW:
CheckRelationComment(stmt->objtype, relation); if (!pg_class_ownercheck(RelationGetRelid(relation), GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
RelationGetRelationName(relation));
break; break;
case OBJECT_COLUMN: case OBJECT_COLUMN:
CheckAttributeComment(relation); CheckAttributeComment(relation);
...@@ -561,51 +562,6 @@ GetComment(Oid oid, Oid classoid, int32 subid) ...@@ -561,51 +562,6 @@ GetComment(Oid oid, Oid classoid, int32 subid)
return comment; return comment;
} }
/*
* Check whether the user is allowed to comment on this relation.
*/
static void
CheckRelationComment(int objtype, Relation relation)
{
/* Check object security */
if (!pg_class_ownercheck(RelationGetRelid(relation), GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
RelationGetRelationName(relation));
/* Next, verify that the relation type matches the intent */
switch (objtype)
{
case OBJECT_INDEX:
if (relation->rd_rel->relkind != RELKIND_INDEX)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not an index",
RelationGetRelationName(relation))));
break;
case OBJECT_SEQUENCE:
if (relation->rd_rel->relkind != RELKIND_SEQUENCE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a sequence",
RelationGetRelationName(relation))));
break;
case OBJECT_TABLE:
if (relation->rd_rel->relkind != RELKIND_RELATION)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a table",
RelationGetRelationName(relation))));
break;
case OBJECT_VIEW:
if (relation->rd_rel->relkind != RELKIND_VIEW)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a view",
RelationGetRelationName(relation))));
break;
}
}
/* /*
* Check whether the user is allowed to comment on an attribute of the * Check whether the user is allowed to comment on an attribute of the
* specified relation. * specified relation.
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment