1717 *
1818 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
1919 *
20- * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.86 2006/07/14 14:52:24 momjian Exp $
20+ * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.87 2006/08/21 19:15:29 tgl Exp $
2121 *
2222 * ----------
2323 */
@@ -193,17 +193,11 @@ RI_FKey_check(PG_FUNCTION_ARGS)
193193 */
194194ri_CheckTrigger (fcinfo ,"RI_FKey_check" ,RI_TRIGTYPE_INUP );
195195
196- tgnargs = trigdata -> tg_trigger -> tgnargs ;
197- tgargs = trigdata -> tg_trigger -> tgargs ;
198-
199196/*
200- * Get the relation descriptors of the FK and PK tables and the new tuple.
201- *
202- * pk_rel is opened in RowShareLock mode since that's what our eventual
203- * SELECT FOR SHARE will get on it.
197+ * Get arguments.
204198 */
205- pk_rel = heap_open ( trigdata -> tg_trigger -> tgconstrrelid , RowShareLock ) ;
206- fk_rel = trigdata -> tg_relation ;
199+ tgnargs = trigdata -> tg_trigger -> tgnargs ;
200+ tgargs = trigdata -> tg_trigger -> tgargs ;
207201if (TRIGGER_FIRED_BY_UPDATE (trigdata -> tg_event ))
208202{
209203old_row = trigdata -> tg_trigtuple ;
@@ -224,10 +218,16 @@ RI_FKey_check(PG_FUNCTION_ARGS)
224218 */
225219Assert (new_row_buf != InvalidBuffer );
226220if (!HeapTupleSatisfiesItself (new_row -> t_data ,new_row_buf ))
227- {
228- heap_close (pk_rel ,RowShareLock );
229221return PointerGetDatum (NULL );
230- }
222+
223+ /*
224+ * Get the relation descriptors of the FK and PK tables.
225+ *
226+ * pk_rel is opened in RowShareLock mode since that's what our eventual
227+ * SELECT FOR SHARE will get on it.
228+ */
229+ fk_rel = trigdata -> tg_relation ;
230+ pk_rel = heap_open (trigdata -> tg_trigger -> tgconstrrelid ,RowShareLock );
231231
232232/* ----------
233233 * SQL3 11.9 <referential constraint definition>