FOREIGN KEY triggers.
Added pg_proc entries for all the new functions.
Jan
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;
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));
# 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 $
#
#-------------------------------------------------------------------------
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
--- /dev/null
+/* ----------
+ * 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;
+}
+
+
*
* 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
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)");
*
* 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.
#include "utils/int8.h"
#include "utils/nabstime.h"
#include "utils/numeric.h"
+#include "access/heapam.h" /* for HeapTuple */
/*
* Defined in adt/
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 */