Will Leinweber wrote: > On ref 8507907 when compiling with clang on os x, I got this warning which > seems like a possible bug. > > I thought to report this because I imagine clang isn't frequently used > day-to-day by most.
Ugh. My fault. Yes, this is a bug. I don't see any nice way to convert ObjectType to ObjectClass or the other way around; it seems to me the only simple way to fix this is to add a new function EventTriggerSupportsObjectClass(), which takes ObjectClass instead of ObjectType. Patch attached. Now, it annoys me that we now have three places that know about object types supported by event triggers: there's a large struct of command tag substrings (event_trigger_support), then there's these two functions. It might be better to add ObjectType and ObjectClass entries to the struct, so that only the struct needs to know about that. The problem is that these two functions would have to walk the struct every time, instead of being a simple switch. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
*** a/src/backend/catalog/dependency.c --- b/src/backend/catalog/dependency.c *************** *** 210,216 **** deleteObjectsInList(ObjectAddresses *targetObjects, Relation *depRel, ObjectAddress *thisobj = targetObjects->refs + i; if ((!(flags & PERFORM_DELETION_INTERNAL)) && ! EventTriggerSupportsObjectType(getObjectClass(thisobj))) { EventTriggerSQLDropAddObject(thisobj); } --- 210,216 ---- ObjectAddress *thisobj = targetObjects->refs + i; if ((!(flags & PERFORM_DELETION_INTERNAL)) && ! EventTriggerSupportsObjectClass(getObjectClass(thisobj))) { EventTriggerSQLDropAddObject(thisobj); } *** a/src/backend/commands/event_trigger.c --- b/src/backend/commands/event_trigger.c *************** *** 912,917 **** EventTriggerSupportsObjectType(ObjectType obtype) --- 912,939 ---- } /* + * Do event triggers support this object class? + */ + bool + EventTriggerSupportsObjectClass(ObjectClass objclass) + { + switch (objclass) + { + case OCLASS_DATABASE: + case OCLASS_TBLSPACE: + case OCLASS_ROLE: + /* no support for global objects */ + return false; + case OCLASS_EVENT_TRIGGER: + /* no support for event triggers on event triggers */ + return false; + default: + break; + } + return true; + } + + /* * Prepare event trigger state for a new complete query to run, if necessary; * returns whether this was done. If it was, EventTriggerEndCompleteQuery must * be called when the query is done, regardless of whether it succeeds or fails *** a/src/include/commands/event_trigger.h --- b/src/include/commands/event_trigger.h *************** *** 13,18 **** --- 13,19 ---- #ifndef EVENT_TRIGGER_H #define EVENT_TRIGGER_H + #include "catalog/dependency.h" #include "catalog/objectaddress.h" #include "catalog/pg_event_trigger.h" #include "nodes/parsenodes.h" *************** *** 41,46 **** extern Oid AlterEventTriggerOwner(const char *name, Oid newOwnerId); --- 42,48 ---- extern void AlterEventTriggerOwner_oid(Oid, Oid newOwnerId); extern bool EventTriggerSupportsObjectType(ObjectType obtype); + extern bool EventTriggerSupportsObjectClass(ObjectClass objclass); extern void EventTriggerDDLCommandStart(Node *parsetree); extern void EventTriggerDDLCommandEnd(Node *parsetree); extern void EventTriggerSQLDrop(Node *parsetree);
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers