17
17
*
18
18
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
19
19
*
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 $
21
21
*
22
22
* ----------
23
23
*/
@@ -193,17 +193,11 @@ RI_FKey_check(PG_FUNCTION_ARGS)
193
193
*/
194
194
ri_CheckTrigger (fcinfo , "RI_FKey_check" , RI_TRIGTYPE_INUP );
195
195
196
- tgnargs = trigdata -> tg_trigger -> tgnargs ;
197
- tgargs = trigdata -> tg_trigger -> tgargs ;
198
-
199
196
/*
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.
204
198
*/
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 ;
207
201
if (TRIGGER_FIRED_BY_UPDATE (trigdata -> tg_event ))
208
202
{
209
203
old_row = trigdata -> tg_trigtuple ;
@@ -224,10 +218,16 @@ RI_FKey_check(PG_FUNCTION_ARGS)
224
218
*/
225
219
Assert (new_row_buf != InvalidBuffer );
226
220
if (!HeapTupleSatisfiesItself (new_row -> t_data , new_row_buf ))
227
- {
228
- heap_close (pk_rel , RowShareLock );
229
221
return 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 );
231
231
232
232
/* ----------
233
233
* SQL3 11.9 <referential constraint definition>
0 commit comments