aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2003-06-11 15:02:25 +0000
committerBruce Momjian <bruce@momjian.us>2003-06-11 15:02:25 +0000
commit535756649f8989b460ca1b32803649cdcc6e5c63 (patch)
tree71bb750c301c13346b1947585a100c8a0a75c45a
parent9167a566d632c975da9c1436e67637bc63c7eda1 (diff)
downloadpostgresql-535756649f8989b460ca1b32803649cdcc6e5c63.tar.gz
postgresql-535756649f8989b460ca1b32803649cdcc6e5c63.zip
During looking stuff up for a discussion on -general, I realized that
I'd placed the check for newly created matching pk rows for on update no action earlier than it needed to be so that it'd check even when the key values hadn't changed. This patch moves it to after checking for NULLs in the old row and comparing the values since the select's probably more expensive. Stephan Szabo
-rw-r--r--src/backend/utils/adt/ri_triggers.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 7f45d347d3e..b940315bbf1 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -17,7 +17,7 @@
*
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.50 2003/04/26 22:21:47 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.51 2003/06/11 15:02:25 momjian Exp $
*
* ----------
*/
@@ -883,17 +883,6 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
old_row = trigdata->tg_trigtuple;
match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]);
- if (ri_Check_Pk_Match(pk_rel, fk_rel,
- old_row, trigdata->tg_trigger->tgoid,
- match_type, tgnargs, tgargs))
- {
- /*
- * There's either another row, or no row could match this one. In
- * either case, we don't need to do the check.
- */
- heap_close(fk_rel, RowShareLock);
- return PointerGetDatum(NULL);
- }
switch (match_type)
{
@@ -941,6 +930,18 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
}
+ if (ri_Check_Pk_Match(pk_rel, fk_rel,
+ old_row, trigdata->tg_trigger->tgoid,
+ match_type, tgnargs, tgargs))
+ {
+ /*
+ * There's either another row, or no row could match this one. In
+ * either case, we don't need to do the check.
+ */
+ heap_close(fk_rel, RowShareLock);
+ return PointerGetDatum(NULL);
+ }
+
if (SPI_connect() != SPI_OK_CONNECT)
elog(ERROR, "SPI_connect() failed in RI_FKey_noaction_upd()");