Hi, I'm back to PostgreSQL development concerns after some distraction here. First, thanks for pushing the patch to commit!
I've been reviewing your changes and here's a very small patch with some details I would have spelled out differently. See what you think, I mostly needed to edit some code to get back in shape :) Coming next, catch-up with things I've missed and extending the included support for event triggers in term of function parameters (rewritten command string, object kind, etc), and maybe PL support too. Regards, -- Dimitri Fontaine http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index d725360..9bc699e 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -17,6 +17,7 @@ #include "catalog/dependency.h" #include "catalog/indexing.h" #include "catalog/objectaccess.h" +#include "catalog/pg_collation.h" #include "catalog/pg_event_trigger.h" #include "catalog/pg_proc.h" #include "catalog/pg_trigger.h" @@ -31,6 +32,7 @@ #include "utils/builtins.h" #include "utils/evtcache.h" #include "utils/fmgroids.h" +#include "utils/formatting.h" #include "utils/lsyscache.h" #include "utils/memutils.h" #include "utils/rel.h" @@ -337,14 +339,11 @@ filter_list_to_array(List *filterlist) foreach(lc, filterlist) { const char *value = strVal(lfirst(lc)); - char *result, - *p; - - result = pstrdup(value); - for (p = result; *p; p++) - *p = pg_ascii_toupper((unsigned char) *p); - data[i++] = PointerGetDatum(cstring_to_text(result)); - pfree(result); + + data[i++] = + PointerGetDatum( + cstring_to_text( + str_toupper(value, strlen(value), DEFAULT_COLLATION_OID))); } return PointerGetDatum(construct_array(data, l, TEXTOID, -1, false, 'i')); @@ -565,6 +564,9 @@ EventTriggerDDLCommandStart(Node *parsetree) const char *tag; EventTriggerData trigdata; + /* Get the command tag. */ + tag = CreateCommandTag(parsetree); + /* * We want the list of command tags for which this procedure is actually * invoked to match up exactly with the list that CREATE EVENT TRIGGER @@ -579,15 +581,11 @@ EventTriggerDDLCommandStart(Node *parsetree) * type in question, or you need to adjust check_ddl_tag to accept the * relevant command tag. */ + #ifdef USE_ASSERT_CHECKING if (assert_enabled) - { - const char *dbgtag; - - dbgtag = CreateCommandTag(parsetree); - if (check_ddl_tag(dbgtag) != EVENT_TRIGGER_COMMAND_TAG_OK) - elog(ERROR, "unexpected command tag \"%s\"", dbgtag); - } + if (check_ddl_tag(tag) != EVENT_TRIGGER_COMMAND_TAG_OK) + elog(ERROR, "unexpected command tag \"%s\"", tag); #endif /* Use cache to find triggers for this event; fast exit if none. */ @@ -595,9 +593,6 @@ EventTriggerDDLCommandStart(Node *parsetree) if (cachelist == NULL) return; - /* Get the command tag. */ - tag = CreateCommandTag(parsetree); - /* * Filter list of event triggers by command tag, and copy them into * our memory context. Once we start running the command trigers, or @@ -609,7 +604,10 @@ EventTriggerDDLCommandStart(Node *parsetree) { EventTriggerCacheItem *item = lfirst(lc); - /* Filter by session replication role. */ + /* + * Filter by session replication role. Remember that DISABLED event + * triggers didn't make it to the cache. + */ if (SessionReplicationRole == SESSION_REPLICATION_ROLE_REPLICA) { if (item->enabled == TRIGGER_FIRES_ON_ORIGIN)
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers