diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile index df6da1f..6e29758 100644 --- a/src/backend/catalog/Makefile +++ b/src/backend/catalog/Makefile @@ -12,7 +12,8 @@ include $(top_builddir)/src/Makefile.global OBJS = catalog.o dependency.o heap.o index.o indexing.o namespace.o aclchk.o \ objectaddress.o pg_aggregate.o pg_collation.o pg_constraint.o pg_conversion.o \ - pg_depend.o pg_enum.o pg_inherits.o pg_largeobject.o pg_namespace.o \ + pg_depend.o pg_enum.o pg_event_trigger.o pg_inherits.o pg_largeobject.o \ + pg_namespace.o \ pg_operator.o pg_proc.o pg_range.o pg_db_role_setting.o pg_shdepend.o \ pg_type.o storage.o toasting.o diff --git a/src/backend/catalog/pg_event_trigger.c b/src/backend/catalog/pg_event_trigger.c new file mode 100644 index 0000000..7d52a84 --- /dev/null +++ b/src/backend/catalog/pg_event_trigger.c @@ -0,0 +1,200 @@ +/*------------------------------------------------------------------------- + * + * pg_event_trigger.c + * routines to support manipulation of the pg_event_trigger relation + * + * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * src/backend/catalog/pg_event_trigger.c + * + *------------------------------------------------------------------------- + */ +#include "postgres.h" + +#include "catalog/pg_event_trigger.h" +#include "catalog/pg_event_trigger_fn.h" +#include "utils/builtins.h" + +TrigEventCommand +parse_event_tag(char *command, bool noerror) +{ + if (pg_strcasecmp(command, "ALTER AGGREGATE") == 0) + return E_AlterAggregate; + else if (pg_strcasecmp(command, "ALTER COLLATION") == 0) + return E_AlterCollation; + else if (pg_strcasecmp(command, "ALTER CONVERSION") == 0) + return E_AlterConversion; + else if (pg_strcasecmp(command, "ALTER DOMAIN") == 0) + return E_AlterDomain; + else if (pg_strcasecmp(command, "ALTER EXTENSION") == 0) + return E_AlterExtension; + else if (pg_strcasecmp(command, "ALTER FOREIGN DATA WRAPPER") == 0) + return E_AlterForeignDataWrapper; + else if (pg_strcasecmp(command, "ALTER FOREIGN TABLE") == 0) + return E_AlterForeignTable; + else if (pg_strcasecmp(command, "ALTER FUNCTION") == 0) + return E_AlterFunction; + else if (pg_strcasecmp(command, "ALTER LANGUAGE") == 0) + return E_AlterLanguage; + else if (pg_strcasecmp(command, "ALTER OPERATOR") == 0) + return E_AlterOperator; + else if (pg_strcasecmp(command, "ALTER OPERATOR CLASS") == 0) + return E_AlterOperatorClass; + else if (pg_strcasecmp(command, "ALTER OPERATOR FAMILY") == 0) + return E_AlterOperatorFamily; + else if (pg_strcasecmp(command, "ALTER SEQUENCE") == 0) + return E_AlterSequence; + else if (pg_strcasecmp(command, "ALTER SERVER") == 0) + return E_AlterServer; + else if (pg_strcasecmp(command, "ALTER SCHEMA") == 0) + return E_AlterSchema; + else if (pg_strcasecmp(command, "ALTER TABLE") == 0) + return E_AlterTable; + else if (pg_strcasecmp(command, "ALTER TEXT SEARCH CONFIGURATION") == 0) + return E_AlterTextSearchConfiguration; + else if (pg_strcasecmp(command, "ALTER TEXT SEARCH DICTIONARY") == 0) + return E_AlterTextSearchDictionary; + else if (pg_strcasecmp(command, "ALTER TEXT SEARCH PARSER") == 0) + return E_AlterTextSearchParser; + else if (pg_strcasecmp(command, "ALTER TEXT SEARCH TEMPLATE") == 0) + return E_AlterTextSearchTemplate; + else if (pg_strcasecmp(command, "ALTER TRIGGER") == 0) + return E_AlterTrigger; + else if (pg_strcasecmp(command, "ALTER TYPE") == 0) + return E_AlterType; + else if (pg_strcasecmp(command, "ALTER USER MAPPING") == 0) + return E_AlterUserMapping; + else if (pg_strcasecmp(command, "ALTER VIEW") == 0) + return E_AlterView; + else if (pg_strcasecmp(command, "CLUSTER") == 0) + return E_Cluster; + else if (pg_strcasecmp(command, "CREATE AGGREGATE") == 0) + return E_CreateAggregate; + else if (pg_strcasecmp(command, "CREATE CAST") == 0) + return E_CreateCast; + else if (pg_strcasecmp(command, "CREATE COLLATION") == 0) + return E_CreateCollation; + else if (pg_strcasecmp(command, "CREATE CONVERSION") == 0) + return E_CreateConversion; + else if (pg_strcasecmp(command, "CREATE DOMAIN") == 0) + return E_CreateDomain; + else if (pg_strcasecmp(command, "CREATE EXTENSION") == 0) + return E_CreateExtension; + else if (pg_strcasecmp(command, "CREATE FOREIGN DATA WRAPPER") == 0) + return E_CreateForeignDataWrapper; + else if (pg_strcasecmp(command, "CREATE FOREIGN TABLE") == 0) + return E_CreateForeignTable; + else if (pg_strcasecmp(command, "CREATE FUNCTION") == 0) + return E_CreateFunction; + else if (pg_strcasecmp(command, "CREATE INDEX") == 0) + return E_CreateIndex; + else if (pg_strcasecmp(command, "CREATE LANGUAGE") == 0) + return E_CreateLanguage; + else if (pg_strcasecmp(command, "CREATE OPERATOR") == 0) + return E_CreateOperator; + else if (pg_strcasecmp(command, "CREATE OPERATOR CLASS") == 0) + return E_CreateOperatorClass; + else if (pg_strcasecmp(command, "CREATE OPERATOR FAMILY") == 0) + return E_CreateOperatorFamily; + else if (pg_strcasecmp(command, "CREATE RULE") == 0) + return E_CreateRule; + else if (pg_strcasecmp(command, "CREATE SEQUENCE") == 0) + return E_CreateSequence; + else if (pg_strcasecmp(command, "CREATE SERVER") == 0) + return E_CreateServer; + else if (pg_strcasecmp(command, "CREATE SCHEMA") == 0) + return E_CreateSchema; + else if (pg_strcasecmp(command, "CREATE TABLE") == 0) + return E_CreateTable; + else if (pg_strcasecmp(command, "CREATE TABLE AS") == 0) + return E_CreateTableAs; + else if (pg_strcasecmp(command, "CREATE TEXT SEARCH CONFIGURATION") == 0) + return E_CreateTextSearchConfiguration; + else if (pg_strcasecmp(command, "CREATE TEXT SEARCH DICTIONARY") == 0) + return E_CreateTextSearchDictionary; + else if (pg_strcasecmp(command, "CREATE TEXT SEARCH PARSER") == 0) + return E_CreateTextSearchParser; + else if (pg_strcasecmp(command, "CREATE TEXT SEARCH TEMPLATE") == 0) + return E_CreateTextSearchTemplate; + else if (pg_strcasecmp(command, "CREATE TRIGGER") == 0) + return E_CreateTrigger; + else if (pg_strcasecmp(command, "CREATE TYPE") == 0) + return E_CreateType; + else if (pg_strcasecmp(command, "CREATE USER MAPPING") == 0) + return E_CreateUserMapping; + else if (pg_strcasecmp(command, "CREATE VIEW") == 0) + return E_CreateView; + else if (pg_strcasecmp(command, "DROP AGGREGATE") == 0) + return E_DropAggregate; + else if (pg_strcasecmp(command, "DROP CAST") == 0) + return E_DropCast; + else if (pg_strcasecmp(command, "DROP COLLATION") == 0) + return E_DropCollation; + else if (pg_strcasecmp(command, "DROP CONVERSION") == 0) + return E_DropConversion; + else if (pg_strcasecmp(command, "DROP DOMAIN") == 0) + return E_DropDomain; + else if (pg_strcasecmp(command, "DROP EXTENSION") == 0) + return E_DropExtension; + else if (pg_strcasecmp(command, "DROP FOREIGN DATA WRAPPER") == 0) + return E_DropForeignDataWrapper; + else if (pg_strcasecmp(command, "DROP FOREIGN TABLE") == 0) + return E_DropForeignTable; + else if (pg_strcasecmp(command, "DROP FUNCTION") == 0) + return E_DropFunction; + else if (pg_strcasecmp(command, "DROP INDEX") == 0) + return E_DropIndex; + else if (pg_strcasecmp(command, "DROP LANGUAGE") == 0) + return E_DropLanguage; + else if (pg_strcasecmp(command, "DROP OPERATOR") == 0) + return E_DropOperator; + else if (pg_strcasecmp(command, "DROP OPERATOR CLASS") == 0) + return E_DropOperatorClass; + else if (pg_strcasecmp(command, "DROP OPERATOR FAMILY") == 0) + return E_DropOperatorFamily; + else if (pg_strcasecmp(command, "DROP RULE") == 0) + return E_DropRule; + else if (pg_strcasecmp(command, "DROP SCHEMA") == 0) + return E_DropSchema; + else if (pg_strcasecmp(command, "DROP SEQUENCE") == 0) + return E_DropSequence; + else if (pg_strcasecmp(command, "DROP SERVER") == 0) + return E_DropServer; + else if (pg_strcasecmp(command, "DROP TABLE") == 0) + return E_DropTable; + else if (pg_strcasecmp(command, "DROP TEXT SEARCH CONFIGURATION") == 0) + return E_DropTextSearchConfiguration; + else if (pg_strcasecmp(command, "DROP TEXT SEARCH DICTIONARY") == 0) + return E_DropTextSearchDictionary; + else if (pg_strcasecmp(command, "DROP TEXT SEARCH PARSER") == 0) + return E_DropTextSearchParser; + else if (pg_strcasecmp(command, "DROP TEXT SEARCH TEMPLATE") == 0) + return E_DropTextSearchTemplate; + else if (pg_strcasecmp(command, "DROP TRIGGER") == 0) + return E_DropTrigger; + else if (pg_strcasecmp(command, "DROP TYPE") == 0) + return E_DropType; + else if (pg_strcasecmp(command, "DROP USER MAPPING") == 0) + return E_DropUserMapping; + else if (pg_strcasecmp(command, "DROP VIEW") == 0) + return E_DropView; + else if (pg_strcasecmp(command, "LOAD") == 0) + return E_Load; + else if (pg_strcasecmp(command, "REINDEX") == 0) + return E_Reindex; + else if (pg_strcasecmp(command, "SELECT INTO") == 0) + return E_SelectInto; + else if (pg_strcasecmp(command, "VACUUM") == 0) + return E_Vacuum; + else + { + if (!noerror) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("unrecognized command \"%s\"", command))); + } + return E_UNKNOWN; +} diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index 13ffeb5..a93698b 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -103,9 +103,13 @@ InsertEventTriggerTuple(char *trigname, TrigEvent event, foreach(lc, cmdlist) { - tags[i++] = Int16GetDatum(lfirst_int(lc)); + TrigEventCommand cmd = lfirst_int(lc); + char *cmdstr = command_to_string(cmd); + if (cmd == E_UNKNOWN || cmdstr == NULL) + elog(ERROR, "Unknown command %d", cmd); + tags[i++] = PointerGetDatum(cstring_to_text(cmdstr)); } - tagArray = construct_array(tags, l, INT2OID, 2, true, 's'); + tagArray = construct_array(tags, l, TEXTOID, -1, false, 'i'); values[Anum_pg_event_trigger_evttags - 1] = PointerGetDatum(tagArray); } diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index ca95d76..21d92ef 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -54,6 +54,7 @@ #include "catalog/index.h" #include "catalog/namespace.h" #include "catalog/pg_event_trigger.h" +#include "catalog/pg_event_trigger_fn.h" #include "catalog/pg_trigger.h" #include "commands/defrem.h" #include "commands/event_trigger.h" @@ -4381,182 +4382,17 @@ trigger_command_list: trigger_command: SCONST { - if (pg_strcasecmp($1, "ALTER AGGREGATE") == 0) - $$ = E_AlterAggregate; - else if (pg_strcasecmp($1, "ALTER COLLATION") == 0) - $$ = E_AlterCollation; - else if (pg_strcasecmp($1, "ALTER CONVERSION") == 0) - $$ = E_AlterConversion; - else if (pg_strcasecmp($1, "ALTER DOMAIN") == 0) - $$ = E_AlterDomain; - else if (pg_strcasecmp($1, "ALTER EXTENSION") == 0) - $$ = E_AlterExtension; - else if (pg_strcasecmp($1, "ALTER FOREIGN DATA WRAPPER") == 0) - $$ = E_AlterForeignDataWrapper; - else if (pg_strcasecmp($1, "ALTER FOREIGN TABLE") == 0) - $$ = E_AlterForeignTable; - else if (pg_strcasecmp($1, "ALTER FUNCTION") == 0) - $$ = E_AlterFunction; - else if (pg_strcasecmp($1, "ALTER LANGUAGE") == 0) - $$ = E_AlterLanguage; - else if (pg_strcasecmp($1, "ALTER OPERATOR") == 0) - $$ = E_AlterOperator; - else if (pg_strcasecmp($1, "ALTER OPERATOR CLASS") == 0) - $$ = E_AlterOperatorClass; - else if (pg_strcasecmp($1, "ALTER OPERATOR FAMILY") == 0) - $$ = E_AlterOperatorFamily; - else if (pg_strcasecmp($1, "ALTER SEQUENCE") == 0) - $$ = E_AlterSequence; - else if (pg_strcasecmp($1, "ALTER SERVER") == 0) - $$ = E_AlterServer; - else if (pg_strcasecmp($1, "ALTER SCHEMA") == 0) - $$ = E_AlterSchema; - else if (pg_strcasecmp($1, "ALTER TABLE") == 0) - $$ = E_AlterTable; - else if (pg_strcasecmp($1, "ALTER TEXT SEARCH CONFIGURATION") == 0) - $$ = E_AlterTextSearchConfiguration; - else if (pg_strcasecmp($1, "ALTER TEXT SEARCH DICTIONARY") == 0) - $$ = E_AlterTextSearchDictionary; - else if (pg_strcasecmp($1, "ALTER TEXT SEARCH PARSER") == 0) - $$ = E_AlterTextSearchParser; - else if (pg_strcasecmp($1, "ALTER TEXT SEARCH TEMPLATE") == 0) - $$ = E_AlterTextSearchTemplate; - else if (pg_strcasecmp($1, "ALTER TRIGGER") == 0) - $$ = E_AlterTrigger; - else if (pg_strcasecmp($1, "ALTER TYPE") == 0) - $$ = E_AlterType; - else if (pg_strcasecmp($1, "ALTER USER MAPPING") == 0) - $$ = E_AlterUserMapping; - else if (pg_strcasecmp($1, "ALTER VIEW") == 0) - $$ = E_AlterView; - else if (pg_strcasecmp($1, "CLUSTER") == 0) - $$ = E_Cluster; - else if (pg_strcasecmp($1, "CREATE AGGREGATE") == 0) - $$ = E_CreateAggregate; - else if (pg_strcasecmp($1, "CREATE CAST") == 0) - $$ = E_CreateCast; - else if (pg_strcasecmp($1, "CREATE COLLATION") == 0) - $$ = E_CreateCollation; - else if (pg_strcasecmp($1, "CREATE CONVERSION") == 0) - $$ = E_CreateConversion; - else if (pg_strcasecmp($1, "CREATE DOMAIN") == 0) - $$ = E_CreateDomain; - else if (pg_strcasecmp($1, "CREATE EXTENSION") == 0) - $$ = E_CreateExtension; - else if (pg_strcasecmp($1, "CREATE FOREIGN DATA WRAPPER") == 0) - $$ = E_CreateForeignDataWrapper; - else if (pg_strcasecmp($1, "CREATE FOREIGN TABLE") == 0) - $$ = E_CreateForeignTable; - else if (pg_strcasecmp($1, "CREATE FUNCTION") == 0) - $$ = E_CreateFunction; - else if (pg_strcasecmp($1, "CREATE INDEX") == 0) - $$ = E_CreateIndex; - else if (pg_strcasecmp($1, "CREATE LANGUAGE") == 0) - $$ = E_CreateLanguage; - else if (pg_strcasecmp($1, "CREATE OPERATOR") == 0) - $$ = E_CreateOperator; - else if (pg_strcasecmp($1, "CREATE OPERATOR CLASS") == 0) - $$ = E_CreateOperatorClass; - else if (pg_strcasecmp($1, "CREATE OPERATOR FAMILY") == 0) - $$ = E_CreateOperatorFamily; - else if (pg_strcasecmp($1, "CREATE RULE") == 0) - $$ = E_CreateRule; - else if (pg_strcasecmp($1, "CREATE SEQUENCE") == 0) - $$ = E_CreateSequence; - else if (pg_strcasecmp($1, "CREATE SERVER") == 0) - $$ = E_CreateServer; - else if (pg_strcasecmp($1, "CREATE SCHEMA") == 0) - $$ = E_CreateSchema; - else if (pg_strcasecmp($1, "CREATE TABLE") == 0) - $$ = E_CreateTable; - else if (pg_strcasecmp($1, "CREATE TABLE AS") == 0) - $$ = E_CreateTableAs; - else if (pg_strcasecmp($1, "CREATE TEXT SEARCH CONFIGURATION") == 0) - $$ = E_CreateTextSearchConfiguration; - else if (pg_strcasecmp($1, "CREATE TEXT SEARCH DICTIONARY") == 0) - $$ = E_CreateTextSearchDictionary; - else if (pg_strcasecmp($1, "CREATE TEXT SEARCH PARSER") == 0) - $$ = E_CreateTextSearchParser; - else if (pg_strcasecmp($1, "CREATE TEXT SEARCH TEMPLATE") == 0) - $$ = E_CreateTextSearchTemplate; - else if (pg_strcasecmp($1, "CREATE TRIGGER") == 0) - $$ = E_CreateTrigger; - else if (pg_strcasecmp($1, "CREATE TYPE") == 0) - $$ = E_CreateType; - else if (pg_strcasecmp($1, "CREATE USER MAPPING") == 0) - $$ = E_CreateUserMapping; - else if (pg_strcasecmp($1, "CREATE VIEW") == 0) - $$ = E_CreateView; - else if (pg_strcasecmp($1, "DROP AGGREGATE") == 0) - $$ = E_DropAggregate; - else if (pg_strcasecmp($1, "DROP CAST") == 0) - $$ = E_DropCast; - else if (pg_strcasecmp($1, "DROP COLLATION") == 0) - $$ = E_DropCollation; - else if (pg_strcasecmp($1, "DROP CONVERSION") == 0) - $$ = E_DropConversion; - else if (pg_strcasecmp($1, "DROP DOMAIN") == 0) - $$ = E_DropDomain; - else if (pg_strcasecmp($1, "DROP EXTENSION") == 0) - $$ = E_DropExtension; - else if (pg_strcasecmp($1, "DROP FOREIGN DATA WRAPPER") == 0) - $$ = E_DropForeignDataWrapper; - else if (pg_strcasecmp($1, "DROP FOREIGN TABLE") == 0) - $$ = E_DropForeignTable; - else if (pg_strcasecmp($1, "DROP FUNCTION") == 0) - $$ = E_DropFunction; - else if (pg_strcasecmp($1, "DROP INDEX") == 0) - $$ = E_DropIndex; - else if (pg_strcasecmp($1, "DROP LANGUAGE") == 0) - $$ = E_DropLanguage; - else if (pg_strcasecmp($1, "DROP OPERATOR") == 0) - $$ = E_DropOperator; - else if (pg_strcasecmp($1, "DROP OPERATOR CLASS") == 0) - $$ = E_DropOperatorClass; - else if (pg_strcasecmp($1, "DROP OPERATOR FAMILY") == 0) - $$ = E_DropOperatorFamily; - else if (pg_strcasecmp($1, "DROP RULE") == 0) - $$ = E_DropRule; - else if (pg_strcasecmp($1, "DROP SCHEMA") == 0) - $$ = E_DropSchema; - else if (pg_strcasecmp($1, "DROP SEQUENCE") == 0) - $$ = E_DropSequence; - else if (pg_strcasecmp($1, "DROP SERVER") == 0) - $$ = E_DropServer; - else if (pg_strcasecmp($1, "DROP TABLE") == 0) - $$ = E_DropTable; - else if (pg_strcasecmp($1, "DROP TEXT SEARCH CONFIGURATION") == 0) - $$ = E_DropTextSearchConfiguration; - else if (pg_strcasecmp($1, "DROP TEXT SEARCH DICTIONARY") == 0) - $$ = E_DropTextSearchDictionary; - else if (pg_strcasecmp($1, "DROP TEXT SEARCH PARSER") == 0) - $$ = E_DropTextSearchParser; - else if (pg_strcasecmp($1, "DROP TEXT SEARCH TEMPLATE") == 0) - $$ = E_DropTextSearchTemplate; - else if (pg_strcasecmp($1, "DROP TRIGGER") == 0) - $$ = E_DropTrigger; - else if (pg_strcasecmp($1, "DROP TYPE") == 0) - $$ = E_DropType; - else if (pg_strcasecmp($1, "DROP USER MAPPING") == 0) - $$ = E_DropUserMapping; - else if (pg_strcasecmp($1, "DROP VIEW") == 0) - $$ = E_DropView; - else if (pg_strcasecmp($1, "LOAD") == 0) - $$ = E_Load; - else if (pg_strcasecmp($1, "REINDEX") == 0) - $$ = E_Reindex; - else if (pg_strcasecmp($1, "SELECT INTO") == 0) - $$ = E_SelectInto; - else if (pg_strcasecmp($1, "VACUUM") == 0) - $$ = E_Vacuum; - else + TrigEventCommand cmdtag = parse_event_tag($1, true); + if (cmdtag == E_UNKNOWN) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("unrecognized command \"%s\"", $1), - parser_errposition(@1))); + parser_errposition(@1))); + $$ = cmdtag; } ; + DropEventTrigStmt: DROP EVENT TRIGGER name opt_drop_behavior { diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c index e08f045..660d1cf 100644 --- a/src/backend/utils/cache/evtcache.c +++ b/src/backend/utils/cache/evtcache.c @@ -23,6 +23,7 @@ #include "catalog/index.h" #include "catalog/indexing.h" #include "catalog/pg_event_trigger.h" +#include "catalog/pg_event_trigger_fn.h" #include "catalog/pg_proc.h" #include "catalog/pg_trigger.h" #include "catalog/pg_type.h" @@ -195,7 +196,7 @@ BuildEventTriggerCache() else { ArrayType *arr; - int16 *tags; + Datum *tags; int i; arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */ @@ -204,15 +205,17 @@ BuildEventTriggerCache() if (ARR_NDIM(arr) != 1 || numkeys < 0 || ARR_HASNULL(arr) || - ARR_ELEMTYPE(arr) != INT2OID) - elog(ERROR, "evttags is not a 1-D smallint array"); + ARR_ELEMTYPE(arr) != TEXTOID) + elog(ERROR, "evttags is not a 1-D text array"); - tags = (int16 *) ARR_DATA_PTR(arr); + deconstruct_array(arr, TEXTOID, -1, false, 'i', + &tags, NULL, &numkeys); for (i = 0; i < numkeys; i++) { - command = tags[i]; - add_funcall_to_command_event(event, command, name, proc); + char *cmdstr = TextDatumGetCString(tags[i]); + command = parse_event_tag(cmdstr, false); + add_funcall_to_command_event(event, command, name, proc); } } } diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 450e93a..561281c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -5327,8 +5327,8 @@ getEvtTriggers(Archive *fout, int *numEvtTriggers) "SELECT e.tableoid, e.oid, evtname, evtenabled, " "pg_catalog.pg_evtevent_to_string(evtevent) as evtevent, " "array_to_string(array(" - "select '''' || pg_catalog.pg_evttag_to_string(x) || '''' " - "from unnest(evttags) as t(x)), ', ') as evttags, " + "select '''' || x || '''' " + " from unnest(evttags) as t(x)), ', ') as evttags, " "n.nspname || '.' || p.proname as evtfname " "FROM pg_event_trigger e JOIN pg_proc p on e.evtfoid = p.oid " "JOIN pg_namespace n ON p.pronamespace = n.oid " diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index b30af0d..a2a9a62 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -2975,7 +2975,7 @@ listEvtTriggers(const char *pattern, bool verbose) " when 'D' then 'disabled' end as \"%s\", " "pg_catalog.pg_evtevent_to_string(evtevent) as \"%s\", " "n.nspname || '.' || p.proname || '()' as \"%s\", " - " array_to_string(array(select pg_evttag_to_string(x) " + " array_to_string(array(select x " " from unnest(evttags) as t(x)), ', ') as \"%s\" " "FROM pg_event_trigger e JOIN pg_proc p on e.evtfoid = p.oid " "JOIN pg_namespace n ON p.pronamespace = n.oid ", diff --git a/src/include/catalog/pg_event_trigger.h b/src/include/catalog/pg_event_trigger.h index 9af38a1..6e270e3 100644 --- a/src/include/catalog/pg_event_trigger.h +++ b/src/include/catalog/pg_event_trigger.h @@ -36,7 +36,7 @@ CATALOG(pg_event_trigger,3466) char evtenabled; /* trigger's firing configuration WRT * session_replication_role */ #ifdef CATALOG_VARLEN - int16 evttags[1]; /* command TAGs this event trigger targets */ + text evttags[1]; /* command TAGs this event trigger targets */ #endif } FormData_pg_event_trigger; diff --git a/src/include/catalog/pg_event_trigger_fn.h b/src/include/catalog/pg_event_trigger_fn.h new file mode 100644 index 0000000..d1e7502 --- /dev/null +++ b/src/include/catalog/pg_event_trigger_fn.h @@ -0,0 +1,21 @@ +/*------------------------------------------------------------------------- + * + * pg_event_trigger_fn.h + * prototypes for functions in catalog/pg_event_trigger.c + * + * + * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/catalog/pg_event_trigger_fn.h + * + *------------------------------------------------------------------------- + */ +#ifndef PG_EVENT_TRIGGER_FN_H +#define PG_EVENT_TRIGGER_FN_H + +#include "catalog/pg_event_trigger.h" + +TrigEventCommand parse_event_tag(char *command, bool noerror); + +#endif /* PG_EVENT_TRIGGER_FN_H */