From dc6b82124323b50de8e4134d9cc182f935c9602f Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 17 Sep 2010 02:49:10 +0000 Subject: [PATCH] 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. --- src/backend/commands/comment.c | 52 +++------------------------------- 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index 4a801858b6..c4addf7f80 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -7,7 +7,7 @@ * Copyright (c) 1996-2010, PostgreSQL Global Development Group * * 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 @@ * object types require something more complex; for those, we define helper * functions. */ -static void CheckRelationComment(int objtype, Relation relation); static void CheckAttributeComment(Relation relation); static void CheckCastComment(List *qualname, List *arguments); @@ -92,7 +91,9 @@ CommentObject(CommentStmt *stmt) case OBJECT_SEQUENCE: case OBJECT_TABLE: 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; case OBJECT_COLUMN: CheckAttributeComment(relation); @@ -561,51 +562,6 @@ GetComment(Oid oid, Oid classoid, int32 subid) 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 * specified relation. -- 2.39.5