aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ri_triggers.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-08-21 19:15:29 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-08-21 19:15:29 +0000
commitd7c310c1fa03d062225cf7c5ef146cc615d44b7b (patch)
tree30ac5429cc41a915d9aefbb8277a4c72003d127d /src/backend/utils/adt/ri_triggers.c
parent548237fc840134bf038433e318b3cd4c30f85912 (diff)
downloadpostgresql-d7c310c1fa03d062225cf7c5ef146cc615d44b7b.tar.gz
postgresql-d7c310c1fa03d062225cf7c5ef146cc615d44b7b.zip
Minor code rearrangement to save a few cycles in RI_FKey_check when
the subject tuple is already deleted: we need not open the pk_rel until after we check that.
Diffstat (limited to 'src/backend/utils/adt/ri_triggers.c')
-rw-r--r--src/backend/utils/adt/ri_triggers.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 8eac5b8578f..21ae21d95cb 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-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.86 2006/07/14 14:52:24 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.87 2006/08/21 19:15:29 tgl Exp $
*
* ----------
*/
@@ -193,17 +193,11 @@ RI_FKey_check(PG_FUNCTION_ARGS)
*/
ri_CheckTrigger(fcinfo, "RI_FKey_check", RI_TRIGTYPE_INUP);
- tgnargs = trigdata->tg_trigger->tgnargs;
- tgargs = trigdata->tg_trigger->tgargs;
-
/*
- * Get the relation descriptors of the FK and PK tables and the new tuple.
- *
- * pk_rel is opened in RowShareLock mode since that's what our eventual
- * SELECT FOR SHARE will get on it.
+ * Get arguments.
*/
- pk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
- fk_rel = trigdata->tg_relation;
+ tgnargs = trigdata->tg_trigger->tgnargs;
+ tgargs = trigdata->tg_trigger->tgargs;
if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
{
old_row = trigdata->tg_trigtuple;
@@ -224,10 +218,16 @@ RI_FKey_check(PG_FUNCTION_ARGS)
*/
Assert(new_row_buf != InvalidBuffer);
if (!HeapTupleSatisfiesItself(new_row->t_data, new_row_buf))
- {
- heap_close(pk_rel, RowShareLock);
return PointerGetDatum(NULL);
- }
+
+ /*
+ * Get the relation descriptors of the FK and PK tables.
+ *
+ * pk_rel is opened in RowShareLock mode since that's what our eventual
+ * SELECT FOR SHARE will get on it.
+ */
+ fk_rel = trigdata->tg_relation;
+ pk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock);
/* ----------
* SQL3 11.9 <referential constraint definition>