#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_trigger.h"
+#include "catalog/pg_ts_config.h"
#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
#include "commands/event_trigger.h"
MemoryContextSwitchTo(oldcxt);
}
+void
+EventTriggerStashAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
+ Oid *dictIds, int ndicts)
+{
+ MemoryContext oldcxt;
+ StashedCommand *stashed;
+
+ if (currentEventTriggerState->commandCollectionInhibited)
+ return;
+
+ oldcxt = MemoryContextSwitchTo(currentEventTriggerState->cxt);
+
+ stashed = palloc0(sizeof(StashedCommand));
+ stashed->type = SCT_AlterTSConfig;
+ stashed->in_extension = creating_extension;
+ stashed->d.atscfg.tscfgOid = cfgId;
+ stashed->d.atscfg.dictIds = palloc(sizeof(Oid) * ndicts);
+ memcpy(stashed->d.atscfg.dictIds, dictIds, sizeof(Oid) * ndicts);
+ stashed->d.atscfg.ndicts = ndicts;
+ stashed->parsetree = copyObject(stmt);
+
+ currentEventTriggerState->stash = lappend(currentEventTriggerState->stash,
+ stashed);
+
+ MemoryContextSwitchTo(oldcxt);
+}
/*
* EventTriggerStashAlterDefPrivs
if (cmd->type == SCT_Simple ||
cmd->type == SCT_AlterTable ||
cmd->type == SCT_AlterOpFamily ||
- cmd->type == SCT_CreateOpClass)
+ cmd->type == SCT_CreateOpClass ||
+ cmd->type == SCT_AlterTSConfig)
{
const char *tag;
char *identity;
ObjectAddressSet(addr,
OperatorClassRelationId,
cmd->d.createopc.opcOid);
+ else if (cmd->type == SCT_AlterTSConfig)
+ ObjectAddressSet(addr,
+ TSConfigRelationId,
+ cmd->d.atscfg.tscfgOid);
tag = CreateCommandTag(cmd->parsetree);
#include "catalog/pg_type.h"
#include "commands/alter.h"
#include "commands/defrem.h"
+#include "commands/event_trigger.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "parser/parse_func.h"
}
}
}
+
+ EventTriggerStashAlterTSConfig(stmt, cfgId, dictIds, ndict);
}
/*
i++;
}
+
+ EventTriggerStashAlterTSConfig(stmt, cfgId, NULL, 0);
}
{
AlterTSConfigurationStmt *newnode = makeNode(AlterTSConfigurationStmt);
+ COPY_SCALAR_FIELD(kind);
COPY_NODE_FIELD(cfgname);
COPY_NODE_FIELD(tokentype);
COPY_NODE_FIELD(dicts);
_equalAlterTSConfigurationStmt(const AlterTSConfigurationStmt *a,
const AlterTSConfigurationStmt *b)
{
+ COMPARE_SCALAR_FIELD(kind);
COMPARE_NODE_FIELD(cfgname);
COMPARE_NODE_FIELD(tokentype);
COMPARE_NODE_FIELD(dicts);
ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
{
AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
+ n->kind = ALTER_TSCONFIG_ADD_MAPPING;
n->cfgname = $5;
n->tokentype = $9;
n->dicts = $11;
| ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
{
AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
+ n->kind = ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN;
n->cfgname = $5;
n->tokentype = $9;
n->dicts = $11;
| ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING REPLACE any_name any_with any_name
{
AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
+ n->kind = ALTER_TSCONFIG_REPLACE_DICT;
n->cfgname = $5;
n->tokentype = NIL;
n->dicts = list_make2($9,$11);
| ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list REPLACE any_name any_with any_name
{
AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
+ n->kind = ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN;
n->cfgname = $5;
n->tokentype = $9;
n->dicts = list_make2($11,$13);
| ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING FOR name_list
{
AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
+ n->kind = ALTER_TSCONFIG_DROP_MAPPING;
n->cfgname = $5;
n->tokentype = $9;
n->missing_ok = false;
| ALTER TEXT_P SEARCH CONFIGURATION any_name DROP MAPPING IF_P EXISTS FOR name_list
{
AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
+ n->kind = ALTER_TSCONFIG_DROP_MAPPING;
n->cfgname = $5;
n->tokentype = $11;
n->missing_ok = true;
case SCT_AlterDefaultPrivileges:
tree = deparse_AlterDefaultPrivilegesStmt(cmd);
break;
+ case SCT_AlterTSConfig:
+ tree = deparse_AlterTSConfigurationStmt(cmd);
+ break;
default:
elog(ERROR, "unexpected deparse node type %d", cmd->type);
}
List *operators, List *procedures);
extern void EventTriggerStashCreateOpClass(CreateOpClassStmt *stmt, Oid opcoid,
List *operators, List *procedures);
+extern void EventTriggerStashAlterTSConfig(AlterTSConfigurationStmt *stmt,
+ Oid cfgId, Oid *dicts, int ndicts);
extern void EventTriggerStashAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt);
#endif /* EVENT_TRIGGER_H */
/*
* TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
*/
+typedef enum AlterTSConfigType
+{
+ ALTER_TSCONFIG_ADD_MAPPING,
+ ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN,
+ ALTER_TSCONFIG_REPLACE_DICT,
+ ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN,
+ ALTER_TSCONFIG_DROP_MAPPING
+} AlterTSConfigType;
+
typedef struct AlterTSConfigurationStmt
{
NodeTag type;
+ AlterTSConfigType kind; /* ALTER_TSCONFIG_ADD_MAPPING, etc */
List *cfgname; /* qualified name (list of Value strings) */
/*
SCT_Grant,
SCT_AlterOpFamily,
SCT_AlterDefaultPrivileges,
- SCT_CreateOpClass
+ SCT_CreateOpClass,
+ SCT_AlterTSConfig
} StashedCommandType;
/*
List *procedures;
} createopc;
+ /* ALTER TEXT SEARCH CONFIGURATION ADD/ALTER/DROP MAPPING */
+ struct
+ {
+ Oid tscfgOid;
+ Oid *dictIds;
+ int ndicts;
+ } atscfg;
+
/* ALTER DEFAULT PRIVILEGES */
struct
{