mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.105 2003/09/23 15:11:33 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.106 2003/09/25 18:58:35 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,10 +32,12 @@ static int _SPI_connected = -1;
|
||||
static int _SPI_curid = -1;
|
||||
|
||||
static int _SPI_execute(const char *src, int tcount, _SPI_plan *plan);
|
||||
static int _SPI_pquery(QueryDesc *queryDesc, bool runit, int tcount);
|
||||
static int _SPI_pquery(QueryDesc *queryDesc, bool runit,
|
||||
bool useSnapshotNow, int tcount);
|
||||
|
||||
static int _SPI_execute_plan(_SPI_plan *plan,
|
||||
Datum *Values, const char *Nulls, int tcount);
|
||||
Datum *Values, const char *Nulls,
|
||||
bool useSnapshotNow, int tcount);
|
||||
|
||||
static void _SPI_cursor_operation(Portal portal, bool forward, int count,
|
||||
DestReceiver *dest);
|
||||
@@ -236,7 +238,33 @@ SPI_execp(void *plan, Datum *Values, const char *Nulls, int tcount)
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
res = _SPI_execute_plan((_SPI_plan *) plan, Values, Nulls, tcount);
|
||||
res = _SPI_execute_plan((_SPI_plan *) plan, Values, Nulls, false, tcount);
|
||||
|
||||
_SPI_end_call(true);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* SPI_execp_now -- identical to SPI_execp, except that we use SnapshotNow
|
||||
* instead of the normal QuerySnapshot. This is currently not documented
|
||||
* in spi.sgml because it is only intended for use by RI triggers.
|
||||
*/
|
||||
int
|
||||
SPI_execp_now(void *plan, Datum *Values, const char *Nulls, int tcount)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (plan == NULL || tcount < 0)
|
||||
return SPI_ERROR_ARGUMENT;
|
||||
|
||||
if (((_SPI_plan *) plan)->nargs > 0 && Values == NULL)
|
||||
return SPI_ERROR_PARAM;
|
||||
|
||||
res = _SPI_begin_call(true);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
res = _SPI_execute_plan((_SPI_plan *) plan, Values, Nulls, true, tcount);
|
||||
|
||||
_SPI_end_call(true);
|
||||
return res;
|
||||
@@ -1068,7 +1096,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
|
||||
{
|
||||
qdesc = CreateQueryDesc(queryTree, planTree, dest,
|
||||
NULL, false);
|
||||
res = _SPI_pquery(qdesc, true,
|
||||
res = _SPI_pquery(qdesc, true, false,
|
||||
queryTree->canSetTag ? tcount : 0);
|
||||
if (res < 0)
|
||||
return res;
|
||||
@@ -1078,7 +1106,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
|
||||
{
|
||||
qdesc = CreateQueryDesc(queryTree, planTree, dest,
|
||||
NULL, false);
|
||||
res = _SPI_pquery(qdesc, false, 0);
|
||||
res = _SPI_pquery(qdesc, false, false, 0);
|
||||
if (res < 0)
|
||||
return res;
|
||||
}
|
||||
@@ -1096,7 +1124,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
|
||||
|
||||
static int
|
||||
_SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
|
||||
int tcount)
|
||||
bool useSnapshotNow, int tcount)
|
||||
{
|
||||
List *query_list_list = plan->qtlist;
|
||||
List *plan_list = plan->ptlist;
|
||||
@@ -1167,7 +1195,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
|
||||
{
|
||||
qdesc = CreateQueryDesc(queryTree, planTree, dest,
|
||||
paramLI, false);
|
||||
res = _SPI_pquery(qdesc, true,
|
||||
res = _SPI_pquery(qdesc, true, useSnapshotNow,
|
||||
queryTree->canSetTag ? tcount : 0);
|
||||
if (res < 0)
|
||||
return res;
|
||||
@@ -1180,7 +1208,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
|
||||
}
|
||||
|
||||
static int
|
||||
_SPI_pquery(QueryDesc *queryDesc, bool runit, int tcount)
|
||||
_SPI_pquery(QueryDesc *queryDesc, bool runit, bool useSnapshotNow, int tcount)
|
||||
{
|
||||
int operation = queryDesc->operation;
|
||||
int res;
|
||||
@@ -1217,7 +1245,7 @@ _SPI_pquery(QueryDesc *queryDesc, bool runit, int tcount)
|
||||
ResetUsage();
|
||||
#endif
|
||||
|
||||
ExecutorStart(queryDesc, false);
|
||||
ExecutorStart(queryDesc, useSnapshotNow, false);
|
||||
|
||||
ExecutorRun(queryDesc, ForwardScanDirection, (long) tcount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user