| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef OBJECTACCESS_H |
| #define OBJECTACCESS_H |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| typedef enum ObjectAccessType |
| { |
| OAT_POST_CREATE, |
| OAT_DROP, |
| OAT_POST_ALTER, |
| OAT_NAMESPACE_SEARCH, |
| OAT_FUNCTION_EXECUTE, |
| OAT_TRUNCATE |
| } ObjectAccessType; |
|
|
| |
| |
| |
| typedef struct |
| { |
| |
| |
| |
| |
| |
| bool is_internal; |
| } ObjectAccessPostCreate; |
|
|
| |
| |
| |
| typedef struct |
| { |
| |
| |
| |
| |
| int dropflags; |
| } ObjectAccessDrop; |
|
|
| |
| |
| |
| typedef struct |
| { |
| |
| |
| |
| |
| |
| |
| Oid auxiliary_id; |
|
|
| |
| |
| |
| |
| |
| |
| bool is_internal; |
| } ObjectAccessPostAlter; |
|
|
| |
| |
| |
| typedef struct |
| { |
| |
| |
| |
| |
| bool ereport_on_violation; |
|
|
| |
| |
| |
| |
| |
| |
| |
| bool result; |
| } ObjectAccessNamespaceSearch; |
|
|
| |
| typedef void (*object_access_hook_type) (ObjectAccessType access, |
| Oid classId, |
| Oid objectId, |
| int subId, |
| void *arg); |
|
|
| typedef void (*object_access_hook_type_str) (ObjectAccessType access, |
| Oid classId, |
| const char *objectStr, |
| int subId, |
| void *arg); |
|
|
| |
| extern PGDLLIMPORT object_access_hook_type object_access_hook; |
| extern PGDLLIMPORT object_access_hook_type_str object_access_hook_str; |
|
|
|
|
| |
| extern void RunObjectPostCreateHook(Oid classId, Oid objectId, int subId, |
| bool is_internal); |
| extern void RunObjectDropHook(Oid classId, Oid objectId, int subId, |
| int dropflags); |
| extern void RunObjectTruncateHook(Oid objectId); |
| extern void RunObjectPostAlterHook(Oid classId, Oid objectId, int subId, |
| Oid auxiliaryId, bool is_internal); |
| extern bool RunNamespaceSearchHook(Oid objectId, bool ereport_on_violation); |
| extern void RunFunctionExecuteHook(Oid objectId); |
|
|
| |
| extern void RunObjectPostCreateHookStr(Oid classId, const char *objectName, int subId, |
| bool is_internal); |
| extern void RunObjectDropHookStr(Oid classId, const char *objectName, int subId, |
| int dropflags); |
| extern void RunObjectTruncateHookStr(const char *objectName); |
| extern void RunObjectPostAlterHookStr(Oid classId, const char *objectName, int subId, |
| Oid auxiliaryId, bool is_internal); |
| extern bool RunNamespaceSearchHookStr(const char *objectName, bool ereport_on_violation); |
| extern void RunFunctionExecuteHookStr(const char *objectName); |
|
|
|
|
| |
| |
| |
| |
| |
|
|
| #define InvokeObjectPostCreateHook(classId,objectId,subId) \ |
| InvokeObjectPostCreateHookArg((classId),(objectId),(subId),false) |
| #define InvokeObjectPostCreateHookArg(classId,objectId,subId,is_internal) \ |
| do { \ |
| if (object_access_hook) \ |
| RunObjectPostCreateHook((classId),(objectId),(subId), \ |
| (is_internal)); \ |
| } while(0) |
|
|
| #define InvokeObjectDropHook(classId,objectId,subId) \ |
| InvokeObjectDropHookArg((classId),(objectId),(subId),0) |
| #define InvokeObjectDropHookArg(classId,objectId,subId,dropflags) \ |
| do { \ |
| if (object_access_hook) \ |
| RunObjectDropHook((classId),(objectId),(subId), \ |
| (dropflags)); \ |
| } while(0) |
|
|
| #define InvokeObjectTruncateHook(objectId) \ |
| do { \ |
| if (object_access_hook) \ |
| RunObjectTruncateHook(objectId); \ |
| } while(0) |
|
|
| #define InvokeObjectPostAlterHook(classId,objectId,subId) \ |
| InvokeObjectPostAlterHookArg((classId),(objectId),(subId), \ |
| InvalidOid,false) |
| #define InvokeObjectPostAlterHookArg(classId,objectId,subId, \ |
| auxiliaryId,is_internal) \ |
| do { \ |
| if (object_access_hook) \ |
| RunObjectPostAlterHook((classId),(objectId),(subId), \ |
| (auxiliaryId),(is_internal)); \ |
| } while(0) |
|
|
| #define InvokeNamespaceSearchHook(objectId, ereport_on_violation) \ |
| (!object_access_hook \ |
| ? true \ |
| : RunNamespaceSearchHook((objectId), (ereport_on_violation))) |
|
|
| #define InvokeFunctionExecuteHook(objectId) \ |
| do { \ |
| if (object_access_hook) \ |
| RunFunctionExecuteHook(objectId); \ |
| } while(0) |
|
|
|
|
| #define InvokeObjectPostCreateHookStr(classId,objectName,subId) \ |
| InvokeObjectPostCreateHookArgStr((classId),(objectName),(subId),false) |
| #define InvokeObjectPostCreateHookArgStr(classId,objectName,subId,is_internal) \ |
| do { \ |
| if (object_access_hook_str) \ |
| RunObjectPostCreateHookStr((classId),(objectName),(subId), \ |
| (is_internal)); \ |
| } while(0) |
|
|
| #define InvokeObjectDropHookStr(classId,objectName,subId) \ |
| InvokeObjectDropHookArgStr((classId),(objectName),(subId),0) |
| #define InvokeObjectDropHookArgStr(classId,objectName,subId,dropflags) \ |
| do { \ |
| if (object_access_hook_str) \ |
| RunObjectDropHookStr((classId),(objectName),(subId), \ |
| (dropflags)); \ |
| } while(0) |
|
|
| #define InvokeObjectTruncateHookStr(objectName) \ |
| do { \ |
| if (object_access_hook_str) \ |
| RunObjectTruncateHookStr(objectName); \ |
| } while(0) |
|
|
| #define InvokeObjectPostAlterHookStr(classId,objectName,subId) \ |
| InvokeObjectPostAlterHookArgStr((classId),(objectName),(subId), \ |
| InvalidOid,false) |
| #define InvokeObjectPostAlterHookArgStr(classId,objectName,subId, \ |
| auxiliaryId,is_internal) \ |
| do { \ |
| if (object_access_hook_str) \ |
| RunObjectPostAlterHookStr((classId),(objectName),(subId), \ |
| (auxiliaryId),(is_internal)); \ |
| } while(0) |
|
|
| #define InvokeNamespaceSearchHookStr(objectName, ereport_on_violation) \ |
| (!object_access_hook_str \ |
| ? true \ |
| : RunNamespaceSearchHookStr((objectName), (ereport_on_violation))) |
|
|
| #define InvokeFunctionExecuteHookStr(objectName) \ |
| do { \ |
| if (object_access_hook_str) \ |
| RunFunctionExecuteHookStr(objectName); \ |
| } while(0) |
|
|
|
|
| #endif |
|
|