mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
Tsearch2 functionality migrates to core. The bulk of this work is by
Oleg Bartunov and Teodor Sigaev, but I did a lot of editorializing, so anything that's broken is probably my fault. Documentation is nonexistent as yet, but let's land the patch so we can get some portability testing done.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user