aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2010-11-25 11:48:49 -0500
committerRobert Haas <rhaas@postgresql.org>2010-11-25 11:50:13 -0500
commitcc1ed40d57aa68322e43a7b0a3320a6c5aff010a (patch)
tree9ea4ae8d86ab1e9709e16357a05040700acbe02a /src/include
parentd3c126544342728ab4b5c167b4f4b01a39270db5 (diff)
downloadpostgresql-cc1ed40d57aa68322e43a7b0a3320a6c5aff010a.tar.gz
postgresql-cc1ed40d57aa68322e43a7b0a3320a6c5aff010a.zip
Object access hook framework, with post-creation hook.
After a SQL object is created, we provide an opportunity for security or logging plugins to get control; for example, a security label provider could use this to assign an initial security label to newly created objects. The basic infrastructure is (hopefully) reusable for other types of events that might require similar treatment. KaiGai Kohei, with minor adjustments.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/objectaccess.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/include/catalog/objectaccess.h b/src/include/catalog/objectaccess.h
new file mode 100644
index 00000000000..88508b0103e
--- /dev/null
+++ b/src/include/catalog/objectaccess.h
@@ -0,0 +1,46 @@
+/*
+ * objectaccess.h
+ *
+ * Object access hooks.
+ *
+ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
+ * 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
+ * performing certain actions on a SQL object. This is intended as
+ * infrastructure for security or logging pluggins.
+ *
+ * OAT_POST_CREATE should be invoked just after the the object is created.
+ * Typically, this is done after inserting the primary catalog records and
+ * associated dependencies.
+ *
+ * Other types may be added in the future.
+ */
+typedef enum ObjectAccessType
+{
+ OAT_POST_CREATE,
+} ObjectAccessType;
+
+/*
+ * Hook, and a macro to invoke it.
+ */
+
+typedef void (*object_access_hook_type)(ObjectAccessType access,
+ Oid classId,
+ Oid objectId,
+ int subId);
+
+extern PGDLLIMPORT object_access_hook_type object_access_hook;
+
+#define InvokeObjectAccessHook(access,classId,objectId,subId) \
+ do { \
+ if (object_access_hook) \
+ (*object_access_hook)((access),(classId),(objectId),(subId)); \
+ } while(0)
+
+#endif /* OBJECTACCESS_H */