aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Wieck <JanWieck@Yahoo.com>1999-09-30 14:54:24 +0000
committerJan Wieck <JanWieck@Yahoo.com>1999-09-30 14:54:24 +0000
commitccecf1fa460a934bf5d4ebaa4ef8568735cc82e0 (patch)
tree1d75be688460a1e0e0b92015f2421a8df4d144bb /src
parentdaaeafd9e1d85973695572425036dbb8c6175242 (diff)
downloadpostgresql-ccecf1fa460a934bf5d4ebaa4ef8568735cc82e0.tar.gz
postgresql-ccecf1fa460a934bf5d4ebaa4ef8568735cc82e0.zip
Added utils/adt/ri_triggers with empty shells for the
FOREIGN KEY triggers. Added pg_proc entries for all the new functions. Jan
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/trigger.c5
-rw-r--r--src/backend/utils/adt/Makefile5
-rw-r--r--src/backend/utils/adt/ri_triggers.c184
-rw-r--r--src/include/catalog/pg_proc.h24
-rw-r--r--src/include/utils/builtins.h14
5 files changed, 226 insertions, 6 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index ce7d6f5a2d6..17a26c3c8e9 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -155,7 +155,8 @@ CreateTrigger(CreateTrigStmt *stmt)
if (((Form_pg_proc) GETSTRUCT(tuple))->prorettype != 0)
elog(ERROR, "CreateTrigger: function %s() must return OPAQUE",
stmt->funcname);
- if (((Form_pg_proc) GETSTRUCT(tuple))->prolang != ClanguageId)
+ if (((Form_pg_proc) GETSTRUCT(tuple))->prolang != ClanguageId &&
+ ((Form_pg_proc) GETSTRUCT(tuple))->prolang != INTERNALlanguageId)
{
HeapTuple langTup;
@@ -166,7 +167,7 @@ CreateTrigger(CreateTrigStmt *stmt)
elog(ERROR, "CreateTrigger: cache lookup for PL failed");
if (((Form_pg_language) GETSTRUCT(langTup))->lanispl == false)
- elog(ERROR, "CreateTrigger: only C and PL functions are supported");
+ elog(ERROR, "CreateTrigger: only builtin, C and PL functions are supported");
}
MemSet(nulls, ' ', Natts_pg_trigger * sizeof(char));
diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile
index f6a19ed5968..74ef6285d2c 100644
--- a/src/backend/utils/adt/Makefile
+++ b/src/backend/utils/adt/Makefile
@@ -4,7 +4,7 @@
# Makefile for utils/adt
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.25 1999/07/22 18:30:08 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.26 1999/09/30 14:54:22 wieck Exp $
#
#-------------------------------------------------------------------------
@@ -34,7 +34,8 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o chunk.o \
oid.o oracle_compat.o \
regexp.o regproc.o ruleutils.o selfuncs.o sets.o \
tid.o timestamp.o varchar.o varlena.o version.o \
- network.o mac.o inet_net_ntop.o inet_net_pton.o
+ network.o mac.o inet_net_ntop.o inet_net_pton.o \
+ ri_triggers.o
all: SUBSYS.o
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
new file mode 100644
index 00000000000..13f17076e43
--- /dev/null
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -0,0 +1,184 @@
+/* ----------
+ * ri_triggers.c
+ *
+ * Generic trigger procedures for referential integrity constraint
+ * checks.
+ *
+ * 1999 Jan Wieck
+ *
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.1 1999/09/30 14:54:22 wieck Exp $
+ *
+ * ----------
+ */
+
+#include "postgres.h"
+#include "fmgr.h"
+
+#include "access/heapam.h"
+#include "catalog/pg_proc.h"
+#include "catalog/pg_type.h"
+#include "commands/trigger.h"
+#include "executor/spi.h"
+#include "utils/builtins.h"
+#include "utils/syscache.h"
+
+/* ----------
+ * RI_FKey_check_ins -
+ *
+ * Check foreign key existance at insert event on FK table.
+ * ----------
+ */
+HeapTuple
+RI_FKey_check_ins (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_check_ins() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_check_upd -
+ *
+ * Check foreign key existance at update event on FK table.
+ * ----------
+ */
+HeapTuple
+RI_FKey_check_upd (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_check_upd() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_cascade_del -
+ *
+ * Cascaded delete foreign key references at delete event on PK table.
+ * ----------
+ */
+HeapTuple
+RI_FKey_cascade_del (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_cascade_del() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_cascade_upd -
+ *
+ * Cascaded update/delete foreign key references at update event on PK table.
+ * ----------
+ */
+HeapTuple
+RI_FKey_cascade_upd (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_cascade_upd() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_restrict_del -
+ *
+ * Restrict delete from PK table to rows unreferenced by foreign key.
+ * ----------
+ */
+HeapTuple
+RI_FKey_restrict_del (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_restrict_del() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_restrict_upd -
+ *
+ * Restrict update of PK to rows unreferenced by foreign key.
+ * ----------
+ */
+HeapTuple
+RI_FKey_restrict_upd (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_restrict_upd() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_setnull_del -
+ *
+ * Set foreign key references to NULL values at delete event on PK table.
+ * ----------
+ */
+HeapTuple
+RI_FKey_setnull_del (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_setnull_del() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_setnull_upd -
+ *
+ * Set foreign key references to NULL at update event on PK table.
+ * ----------
+ */
+HeapTuple
+RI_FKey_setnull_upd (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_setnull_upd() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_setdefault_del -
+ *
+ * Set foreign key references to defaults at delete event on PK table.
+ * ----------
+ */
+HeapTuple
+RI_FKey_setdefault_del (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_setdefault_del() called\n");
+ return NULL;
+}
+
+
+/* ----------
+ * RI_FKey_setdefault_upd -
+ *
+ * Set foreign key references to defaults at update event on PK table.
+ * ----------
+ */
+HeapTuple
+RI_FKey_setdefault_upd (FmgrInfo *proinfo)
+{
+ CurrentTriggerData = NULL;
+
+ elog(NOTICE, "RI_FKey_setdefault_upd() called\n");
+ return NULL;
+}
+
+
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 1f560064e6c..24e74f0e624 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.103 1999/09/29 21:13:30 wieck Exp $
+ * $Id: pg_proc.h,v 1.104 1999/09/30 14:54:23 wieck Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2112,6 +2112,28 @@ DESCR("user name by UID (with fallback)");
DATA(insert OID = 1643 ( pg_get_indexdef PGUID 11 f t f 1 f 25 "26" 100 0 0 100 pg_get_indexdef - ));
DESCR("index description");
+/* Generic referential integrity constraint triggers */
+DATA(insert OID = 1644 ( RI_FKey_check_ins PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_check_ins - ));
+DESCR("referential integrity FOREIGN KEY ... REFERENCES");
+DATA(insert OID = 1645 ( RI_FKey_check_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_check_upd - ));
+DESCR("referential integrity FOREIGN KEY ... REFERENCES");
+DATA(insert OID = 1646 ( RI_FKey_cascade_del PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_cascade_del - ));
+DESCR("referential integrity ON DELETE CASCADE");
+DATA(insert OID = 1647 ( RI_FKey_cascade_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_cascade_upd - ));
+DESCR("referential integrity ON UPDATE CASCADE");
+DATA(insert OID = 1648 ( RI_FKey_restrict_del PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_restrict_del - ));
+DESCR("referential integrity ON DELETE RESTRICT");
+DATA(insert OID = 1649 ( RI_FKey_restrict_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_restrict_upd - ));
+DESCR("referential integrity ON UPDATE RESTRICT");
+DATA(insert OID = 1650 ( RI_FKey_setnull_del PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_setnull_del - ));
+DESCR("referential integrity ON DELETE SET NULL");
+DATA(insert OID = 1651 ( RI_FKey_setnull_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_setnull_upd - ));
+DESCR("referential integrity ON UPDATE SET NULL");
+DATA(insert OID = 1652 ( RI_FKey_setdefault_del PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_del - ));
+DESCR("referential integrity ON DELETE SET DEFAULT");
+DATA(insert OID = 1653 ( RI_FKey_setdefault_upd PGUID 11 f t f 0 f 0 "" 100 0 0 100 RI_FKey_setdefault_upd - ));
+DESCR("referential integrity ON UPDATE SET DEFAULT");
+
/* for mac type support */
DATA(insert OID = 436 ( macaddr_in PGUID 11 f t t 1 f 829 "0" 100 0 0 100 macaddr_in - ));
DESCR("(internal)");
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index b0bd050e9bc..f1c7a25f9dd 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: builtins.h,v 1.86 1999/09/29 21:13:31 wieck Exp $
+ * $Id: builtins.h,v 1.87 1999/09/30 14:54:24 wieck Exp $
*
* NOTES
* This should normally only be included by fmgr.h.
@@ -30,6 +30,7 @@
#include "utils/int8.h"
#include "utils/nabstime.h"
#include "utils/numeric.h"
+#include "access/heapam.h" /* for HeapTuple */
/*
* Defined in adt/
@@ -600,5 +601,16 @@ float32 numeric_float4(Numeric num);
Numeric float8_numeric(float64 val);
float64 numeric_float8(Numeric num);
+/* ri_triggers.c */
+HeapTuple RI_FKey_check_ins(FmgrInfo *proinfo);
+HeapTuple RI_FKey_check_upd(FmgrInfo *proinfo);
+HeapTuple RI_FKey_cascade_del(FmgrInfo *proinfo);
+HeapTuple RI_FKey_cascade_upd(FmgrInfo *proinfo);
+HeapTuple RI_FKey_restrict_del(FmgrInfo *proinfo);
+HeapTuple RI_FKey_restrict_upd(FmgrInfo *proinfo);
+HeapTuple RI_FKey_setnull_del(FmgrInfo *proinfo);
+HeapTuple RI_FKey_setnull_upd(FmgrInfo *proinfo);
+HeapTuple RI_FKey_setdefault_del(FmgrInfo *proinfo);
+HeapTuple RI_FKey_setdefault_upd(FmgrInfo *proinfo);
#endif /* BUILTINS_H */