From 37b57f118663d33583454ea7b01fc6db42deb219 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 15 Aug 2007 19:15:55 +0000 Subject: Repair problems occurring when multiple RI updates have to be done to the same row within one query: we were firing check triggers before all the updates were done, leading to bogus failures. Fix by making the triggers queued by an RI update go at the end of the outer query's trigger event list, thereby effectively making the processing "breadth-first". This was indeed how it worked pre-8.0, so the bug does not occur in the 7.x branches. Per report from Pavel Stehule. --- src/backend/utils/adt/ri_triggers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/adt/ri_triggers.c') diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 747ef66bf77..af2955183cd 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.89 2006/10/04 00:29:59 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.89.2.1 2007/08/15 19:15:55 tgl Exp $ * * ---------- */ @@ -2717,7 +2717,7 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) NULL, NULL, CopySnapshot(GetLatestSnapshot()), InvalidSnapshot, - true, 1); + true, false, 1); /* Check result */ if (spi_result != SPI_OK_SELECT) @@ -3146,7 +3146,7 @@ ri_PerformCheck(RI_QueryKey *qkey, void *qplan, spi_result = SPI_execute_snapshot(qplan, vals, nulls, test_snapshot, crosscheck_snapshot, - false, limit); + false, false, limit); /* Restore UID */ SetUserId(save_uid); -- cgit v1.2.3