2010-11-25 17:48:49 +01:00
|
|
|
/*
|
|
|
|
* objectaccess.h
|
|
|
|
*
|
|
|
|
* Object access hooks.
|
|
|
|
*
|
2012-01-02 00:01:58 +01:00
|
|
|
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
|
2010-11-25 17:48:49 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OBJECTACCESS_H
|
|
|
|
#define OBJECTACCESS_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Object access hooks are intended to be called just before or just after
|
2011-04-10 17:42:00 +02:00
|
|
|
* performing certain actions on a SQL object. This is intended as
|
2010-11-25 17:48:49 +01:00
|
|
|
* infrastructure for security or logging pluggins.
|
|
|
|
*
|
2012-05-02 15:27:34 +02:00
|
|
|
* OAT_POST_CREATE should be invoked just after the object is created.
|
2010-11-25 17:48:49 +01:00
|
|
|
* Typically, this is done after inserting the primary catalog records and
|
|
|
|
* associated dependencies.
|
|
|
|
*
|
2012-03-09 20:34:56 +01:00
|
|
|
* OAT_DROP should be invoked just before deletion of objects; typically
|
|
|
|
* deleteOneObject(). Its arguments are packed within ObjectAccessDrop.
|
|
|
|
*
|
2010-11-25 17:48:49 +01:00
|
|
|
* Other types may be added in the future.
|
|
|
|
*/
|
|
|
|
typedef enum ObjectAccessType
|
|
|
|
{
|
|
|
|
OAT_POST_CREATE,
|
2012-03-09 20:34:56 +01:00
|
|
|
OAT_DROP,
|
2010-11-25 17:48:49 +01:00
|
|
|
} ObjectAccessType;
|
|
|
|
|
2012-10-23 23:07:26 +02:00
|
|
|
/*
|
|
|
|
* Arguments of OAT_POST_CREATE event
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This flag informs extensions whether the context of this creation
|
|
|
|
* is invoked by user's operations, or not. E.g, it shall be dealt
|
|
|
|
* as internal stuff on toast tables or indexes due to type changes.
|
|
|
|
*/
|
|
|
|
bool is_internal;
|
|
|
|
} ObjectAccessPostCreate;
|
|
|
|
|
2010-11-25 17:48:49 +01:00
|
|
|
/*
|
2012-03-09 20:34:56 +01:00
|
|
|
* Arguments of OAT_DROP event
|
2010-11-25 17:48:49 +01:00
|
|
|
*/
|
2012-03-09 20:34:56 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/*
|
2012-06-10 21:20:04 +02:00
|
|
|
* Flags to inform extensions the context of this deletion. Also see
|
|
|
|
* PERFORM_DELETION_* in dependency.h
|
2012-03-09 20:34:56 +01:00
|
|
|
*/
|
2012-06-10 21:20:04 +02:00
|
|
|
int dropflags;
|
2012-03-09 20:34:56 +01:00
|
|
|
} ObjectAccessDrop;
|
2010-11-25 17:48:49 +01:00
|
|
|
|
2012-03-09 20:34:56 +01:00
|
|
|
/*
|
|
|
|
* Hook, and a macro to invoke it.
|
|
|
|
*/
|
2011-04-10 17:42:00 +02:00
|
|
|
typedef void (*object_access_hook_type) (ObjectAccessType access,
|
|
|
|
Oid classId,
|
|
|
|
Oid objectId,
|
2012-03-09 20:34:56 +01:00
|
|
|
int subId,
|
|
|
|
void *arg);
|
2010-11-25 17:48:49 +01:00
|
|
|
|
|
|
|
extern PGDLLIMPORT object_access_hook_type object_access_hook;
|
|
|
|
|
2012-03-09 20:34:56 +01:00
|
|
|
#define InvokeObjectAccessHook(access,classId,objectId,subId,arg) \
|
|
|
|
do { \
|
|
|
|
if (object_access_hook) \
|
|
|
|
(*object_access_hook)((access),(classId), \
|
|
|
|
(objectId),(subId),(arg)); \
|
2010-11-25 17:48:49 +01:00
|
|
|
} while(0)
|
|
|
|
|
2011-04-10 17:42:00 +02:00
|
|
|
#endif /* OBJECTACCESS_H */
|