mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Fix confusion between ObjectType and ObjectClass
Per report by Will Leinweber and Peter Eisentraut
This commit is contained in:
parent
82b55c9769
commit
6a76edb188
@ -210,7 +210,7 @@ deleteObjectsInList(ObjectAddresses *targetObjects, Relation *depRel,
|
|||||||
ObjectAddress *thisobj = targetObjects->refs + i;
|
ObjectAddress *thisobj = targetObjects->refs + i;
|
||||||
|
|
||||||
if ((!(flags & PERFORM_DELETION_INTERNAL)) &&
|
if ((!(flags & PERFORM_DELETION_INTERNAL)) &&
|
||||||
EventTriggerSupportsObjectType(getObjectClass(thisobj)))
|
EventTriggerSupportsObjectClass(getObjectClass(thisobj)))
|
||||||
{
|
{
|
||||||
EventTriggerSQLDropAddObject(thisobj);
|
EventTriggerSQLDropAddObject(thisobj);
|
||||||
}
|
}
|
||||||
|
@ -905,9 +905,96 @@ EventTriggerSupportsObjectType(ObjectType obtype)
|
|||||||
case OBJECT_EVENT_TRIGGER:
|
case OBJECT_EVENT_TRIGGER:
|
||||||
/* no support for event triggers on event triggers */
|
/* no support for event triggers on event triggers */
|
||||||
return false;
|
return false;
|
||||||
default:
|
case OBJECT_AGGREGATE:
|
||||||
|
case OBJECT_ATTRIBUTE:
|
||||||
|
case OBJECT_CAST:
|
||||||
|
case OBJECT_COLUMN:
|
||||||
|
case OBJECT_CONSTRAINT:
|
||||||
|
case OBJECT_COLLATION:
|
||||||
|
case OBJECT_CONVERSION:
|
||||||
|
case OBJECT_DOMAIN:
|
||||||
|
case OBJECT_EXTENSION:
|
||||||
|
case OBJECT_FDW:
|
||||||
|
case OBJECT_FOREIGN_SERVER:
|
||||||
|
case OBJECT_FOREIGN_TABLE:
|
||||||
|
case OBJECT_FUNCTION:
|
||||||
|
case OBJECT_INDEX:
|
||||||
|
case OBJECT_LANGUAGE:
|
||||||
|
case OBJECT_LARGEOBJECT:
|
||||||
|
case OBJECT_MATVIEW:
|
||||||
|
case OBJECT_OPCLASS:
|
||||||
|
case OBJECT_OPERATOR:
|
||||||
|
case OBJECT_OPFAMILY:
|
||||||
|
case OBJECT_RULE:
|
||||||
|
case OBJECT_SCHEMA:
|
||||||
|
case OBJECT_SEQUENCE:
|
||||||
|
case OBJECT_TABLE:
|
||||||
|
case OBJECT_TRIGGER:
|
||||||
|
case OBJECT_TSCONFIGURATION:
|
||||||
|
case OBJECT_TSDICTIONARY:
|
||||||
|
case OBJECT_TSPARSER:
|
||||||
|
case OBJECT_TSTEMPLATE:
|
||||||
|
case OBJECT_TYPE:
|
||||||
|
case OBJECT_VIEW:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
case OCLASS_CLASS:
|
||||||
|
case OCLASS_PROC:
|
||||||
|
case OCLASS_TYPE:
|
||||||
|
case OCLASS_CAST:
|
||||||
|
case OCLASS_COLLATION:
|
||||||
|
case OCLASS_CONSTRAINT:
|
||||||
|
case OCLASS_CONVERSION:
|
||||||
|
case OCLASS_DEFAULT:
|
||||||
|
case OCLASS_LANGUAGE:
|
||||||
|
case OCLASS_LARGEOBJECT:
|
||||||
|
case OCLASS_OPERATOR:
|
||||||
|
case OCLASS_OPCLASS:
|
||||||
|
case OCLASS_OPFAMILY:
|
||||||
|
case OCLASS_AMOP:
|
||||||
|
case OCLASS_AMPROC:
|
||||||
|
case OCLASS_REWRITE:
|
||||||
|
case OCLASS_TRIGGER:
|
||||||
|
case OCLASS_SCHEMA:
|
||||||
|
case OCLASS_TSPARSER:
|
||||||
|
case OCLASS_TSDICT:
|
||||||
|
case OCLASS_TSTEMPLATE:
|
||||||
|
case OCLASS_TSCONFIG:
|
||||||
|
case OCLASS_FDW:
|
||||||
|
case OCLASS_FOREIGN_SERVER:
|
||||||
|
case OCLASS_USER_MAPPING:
|
||||||
|
case OCLASS_DEFACL:
|
||||||
|
case OCLASS_EXTENSION:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case MAX_OCLASS:
|
||||||
|
/*
|
||||||
|
* This shouldn't ever happen, but we keep the case to avoid a
|
||||||
|
* compiler warning without a "default" clause in the switch.
|
||||||
|
*/
|
||||||
|
Assert(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1011,7 +1098,7 @@ EventTriggerSQLDropAddObject(ObjectAddress *object)
|
|||||||
if (!currentEventTriggerState)
|
if (!currentEventTriggerState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Assert(EventTriggerSupportsObjectType(getObjectClass(object)));
|
Assert(EventTriggerSupportsObjectClass(getObjectClass(object)));
|
||||||
|
|
||||||
/* don't report temp schemas */
|
/* don't report temp schemas */
|
||||||
if (object->classId == NamespaceRelationId &&
|
if (object->classId == NamespaceRelationId &&
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#ifndef EVENT_TRIGGER_H
|
#ifndef EVENT_TRIGGER_H
|
||||||
#define EVENT_TRIGGER_H
|
#define EVENT_TRIGGER_H
|
||||||
|
|
||||||
|
#include "catalog/dependency.h"
|
||||||
#include "catalog/objectaddress.h"
|
#include "catalog/objectaddress.h"
|
||||||
#include "catalog/pg_event_trigger.h"
|
#include "catalog/pg_event_trigger.h"
|
||||||
#include "nodes/parsenodes.h"
|
#include "nodes/parsenodes.h"
|
||||||
@ -41,6 +42,7 @@ extern Oid AlterEventTriggerOwner(const char *name, Oid newOwnerId);
|
|||||||
extern void AlterEventTriggerOwner_oid(Oid, Oid newOwnerId);
|
extern void AlterEventTriggerOwner_oid(Oid, Oid newOwnerId);
|
||||||
|
|
||||||
extern bool EventTriggerSupportsObjectType(ObjectType obtype);
|
extern bool EventTriggerSupportsObjectType(ObjectType obtype);
|
||||||
|
extern bool EventTriggerSupportsObjectClass(ObjectClass objclass);
|
||||||
extern void EventTriggerDDLCommandStart(Node *parsetree);
|
extern void EventTriggerDDLCommandStart(Node *parsetree);
|
||||||
extern void EventTriggerDDLCommandEnd(Node *parsetree);
|
extern void EventTriggerDDLCommandEnd(Node *parsetree);
|
||||||
extern void EventTriggerSQLDrop(Node *parsetree);
|
extern void EventTriggerSQLDrop(Node *parsetree);
|
||||||
|
Loading…
Reference in New Issue
Block a user