1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-26 23:43:30 +03:00

Fix for possible referential integrity violation when a qualified ON INSERT

rule split the query into one INSERT and one UPDATE where the UPDATE
then hit's the just created row without modifying the key fields again.
In this special case, the new key slipped in totally unchecked.

Jan
This commit is contained in:
Jan Wieck
2003-10-31 03:57:42 +00:00
parent 9e692f2307
commit d1c496e9d5
3 changed files with 119 additions and 2 deletions

View File

@@ -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.43.2.3 2003/05/21 18:14:46 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.43.2.4 2003/10/31 03:57:41 wieck Exp $
*
* ----------
*/
@@ -400,7 +400,9 @@ RI_FKey_check(PG_FUNCTION_ARGS)
*/
if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
{
if (ri_KeysEqual(fk_rel, old_row, new_row, &qkey,
if (HeapTupleHeaderGetXmin(old_row->t_data) !=
GetCurrentTransactionId() &&
ri_KeysEqual(fk_rel, old_row, new_row, &qkey,
RI_KEYPAIR_FK_IDX))
{
heap_close(pk_rel, RowShareLock);