diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-09-25 18:58:36 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-09-25 18:58:36 +0000 |
commit | c63a5452d8a44e087cfb5bf843e7bd555c400b04 (patch) | |
tree | 649b38d610152e5c9894210fa4be87cb4c469f30 /src/backend/utils/adt/ri_triggers.c | |
parent | 7ab5c5b83ed118d3d42ce0250dafe760a39a4252 (diff) | |
download | postgresql-c63a5452d8a44e087cfb5bf843e7bd555c400b04.tar.gz postgresql-c63a5452d8a44e087cfb5bf843e7bd555c400b04.zip |
Get rid of ReferentialIntegritySnapshotOverride by extending Executor API
to allow es_snapshot to be set to SnapshotNow rather than a query snapshot.
This solves a bug reported by Wade Klaver, wherein triggers fired as a
result of RI cascade updates could misbehave.
Diffstat (limited to 'src/backend/utils/adt/ri_triggers.c')
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 877034519c1..6250995e1b8 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-2003, PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.57 2003/09/25 06:58:04 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.58 2003/09/25 18:58:35 tgl Exp $ * * ---------- */ @@ -187,8 +187,6 @@ RI_FKey_check(PG_FUNCTION_ARGS) int i; int match_type; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -627,8 +625,6 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) int i; int match_type; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -807,8 +803,6 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) int i; int match_type; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -995,8 +989,6 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) void *qplan; int i; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -1159,8 +1151,6 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) int i; int j; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -1349,8 +1339,6 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) void *qplan; int i; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -1520,8 +1508,6 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) void *qplan; int i; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -1694,8 +1680,6 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS) void *qplan; int i; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -1868,8 +1852,6 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) int match_type; bool use_cached_query; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -2083,8 +2065,6 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) RI_QueryKey qkey; void *qplan; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -2296,8 +2276,6 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) void *qplan; int match_type; - ReferentialIntegritySnapshotOverride = true; - /* * Check that this is a valid trigger call on the right time and * event. @@ -2936,15 +2914,19 @@ ri_PerformCheck(RI_QueryKey *qkey, void *qplan, */ limit = (expect_OK == SPI_OK_SELECT) ? 1 : 0; - /* Run the plan */ - spi_result = SPI_execp(qplan, vals, nulls, limit); + /* + * Run the plan, using SnapshotNow time qual rules so that we can see + * all committed tuples, even those committed after our own transaction + * or query started. + */ + spi_result = SPI_execp_now(qplan, vals, nulls, limit); /* Restore UID */ SetUserId(save_uid); /* Check result */ if (spi_result < 0) - elog(ERROR, "SPI_execp failed"); + elog(ERROR, "SPI_execp_now returned %d", spi_result); if (expect_OK >= 0 && spi_result != expect_OK) ri_ReportViolation(qkey, constrname ? constrname : "", |