diff options
Diffstat (limited to 'src/backend/commands/comment.c')
-rw-r--r-- | src/backend/commands/comment.c | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index 344099ebdf6..89158251aa4 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -7,7 +7,7 @@ * Copyright (c) 1996-2007, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.96 2007/02/01 19:10:25 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.97 2007/08/21 01:11:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -34,6 +34,10 @@ #include "catalog/pg_shdescription.h" #include "catalog/pg_tablespace.h" #include "catalog/pg_trigger.h" +#include "catalog/pg_ts_config.h" +#include "catalog/pg_ts_dict.h" +#include "catalog/pg_ts_parser.h" +#include "catalog/pg_ts_template.h" #include "catalog/pg_type.h" #include "commands/comment.h" #include "commands/dbcommands.h" @@ -78,6 +82,10 @@ static void CommentLargeObject(List *qualname, char *comment); static void CommentCast(List *qualname, List *arguments, char *comment); static void CommentTablespace(List *qualname, char *comment); static void CommentRole(List *qualname, char *comment); +static void CommentTSParser(List *qualname, char *comment); +static void CommentTSDictionary(List *qualname, char *comment); +static void CommentTSTemplate(List *qualname, char *comment); +static void CommentTSConfiguration(List *qualname, char *comment); /* @@ -151,6 +159,18 @@ CommentObject(CommentStmt *stmt) case OBJECT_ROLE: CommentRole(stmt->objname, stmt->comment); break; + case OBJECT_TSPARSER: + CommentTSParser(stmt->objname, stmt->comment); + break; + case OBJECT_TSDICTIONARY: + CommentTSDictionary(stmt->objname, stmt->comment); + break; + case OBJECT_TSTEMPLATE: + CommentTSTemplate(stmt->objname, stmt->comment); + break; + case OBJECT_TSCONFIGURATION: + CommentTSConfiguration(stmt->objname, stmt->comment); + break; default: elog(ERROR, "unrecognized object type: %d", (int) stmt->objtype); @@ -1462,3 +1482,61 @@ CommentCast(List *qualname, List *arguments, char *comment) /* Call CreateComments() to create/drop the comments */ CreateComments(castOid, CastRelationId, 0, comment); } + +static void +CommentTSParser(List *qualname, char *comment) +{ + Oid prsId; + + prsId = TSParserGetPrsid(qualname, false); + + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be superuser to comment on text search parser"))); + + CreateComments(prsId, TSParserRelationId, 0, comment); +} + +static void +CommentTSDictionary(List *qualname, char *comment) +{ + Oid dictId; + + dictId = TSDictionaryGetDictid(qualname, false); + + if (!pg_ts_dict_ownercheck(dictId, GetUserId())) + aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSDICTIONARY, + NameListToString(qualname)); + + CreateComments(dictId, TSDictionaryRelationId, 0, comment); +} + +static void +CommentTSTemplate(List *qualname, char *comment) +{ + Oid tmplId; + + tmplId = TSTemplateGetTmplid(qualname, false); + + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be superuser to comment on text search template"))); + + CreateComments(tmplId, TSTemplateRelationId, 0, comment); +} + +static void +CommentTSConfiguration(List *qualname, char *comment) +{ + Oid cfgId; + + cfgId = TSConfigGetCfgid(qualname, false); + + if (!pg_ts_config_ownercheck(cfgId, GetUserId())) + aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSCONFIGURATION, + NameListToString(qualname)); + + CreateComments(cfgId, TSConfigRelationId, 0, comment); +} |