|
| 1 | +/* ------------------------------------------------------------------------- |
| 2 | + * |
| 3 | + * objectaccess.c |
| 4 | + * functions for object_access_hook on various events |
| 5 | + * |
| 6 | + * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group |
| 7 | + * Portions Copyright (c) 1994, Regents of the University of California |
| 8 | + * |
| 9 | + * ------------------------------------------------------------------------- |
| 10 | + */ |
| 11 | +#include "postgres.h" |
| 12 | + |
| 13 | +#include "catalog/objectaccess.h" |
| 14 | + |
| 15 | +/* |
| 16 | + * Hook on object accesses. This is intended as infrastructure for security |
| 17 | + * and logging plugins. |
| 18 | + */ |
| 19 | +object_access_hook_type object_access_hook = NULL; |
| 20 | + |
| 21 | +/* |
| 22 | + * RunObjectPostCreateHook |
| 23 | + * |
| 24 | + * It is entrypoint of OAT_POST_CREATE event |
| 25 | + */ |
| 26 | +void |
| 27 | +RunObjectPostCreateHook(Oid classId, Oid objectId, int subId, |
| 28 | + bool is_internal) |
| 29 | +{ |
| 30 | + ObjectAccessPostCreate pc_arg; |
| 31 | + |
| 32 | + /* caller should check, but just in case... */ |
| 33 | + Assert(object_access_hook != NULL); |
| 34 | + |
| 35 | + memset(&pc_arg, 0, sizeof(ObjectAccessPostCreate)); |
| 36 | + pc_arg.is_internal = is_internal; |
| 37 | + |
| 38 | + (*object_access_hook)(OAT_POST_CREATE, |
| 39 | + classId, objectId, subId, |
| 40 | + (void *) &pc_arg); |
| 41 | +} |
| 42 | + |
| 43 | +/* |
| 44 | + * RunObjectDropHook |
| 45 | + * |
| 46 | + * It is entrypoint of OAT_DROP event |
| 47 | + */ |
| 48 | +void |
| 49 | +RunObjectDropHook(Oid classId, Oid objectId, int subId, |
| 50 | + int dropflags) |
| 51 | +{ |
| 52 | + ObjectAccessDrop drop_arg; |
| 53 | + |
| 54 | + /* caller should check, but just in case... */ |
| 55 | + Assert(object_access_hook != NULL); |
| 56 | + |
| 57 | + memset(&drop_arg, 0, sizeof(ObjectAccessDrop)); |
| 58 | + drop_arg.dropflags = dropflags; |
| 59 | + |
| 60 | + (*object_access_hook)(OAT_DROP, |
| 61 | + classId, objectId, subId, |
| 62 | + (void *) &drop_arg); |
| 63 | +} |
0 commit comments