|
| 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_typeobject_access_hook=NULL; |
| 20 | + |
| 21 | +/* |
| 22 | + * RunObjectPostCreateHook |
| 23 | + * |
| 24 | + * It is entrypoint of OAT_POST_CREATE event |
| 25 | + */ |
| 26 | +void |
| 27 | +RunObjectPostCreateHook(OidclassId,OidobjectId,intsubId, |
| 28 | +boolis_internal) |
| 29 | +{ |
| 30 | +ObjectAccessPostCreatepc_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(OidclassId,OidobjectId,intsubId, |
| 50 | +intdropflags) |
| 51 | +{ |
| 52 | +ObjectAccessDropdrop_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 | +} |