Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfccf99f

Browse files
committed
Repair bug #2836: SPI_execute_plan returned zero if none of the querytrees
were marked canSetTag. While it's certainly correct to return the resultof the last one that is marked canSetTag, it's less clear what to do whennone of them are. Since plpgsql will complain if zero is returned, the8.2.0 behavior isn't good. I've fixed it to restore the prior behavior ofreturning the physically last query's result code when there are nocanSetTag queries.
1 parent4a836ba commitfccf99f

File tree

1 file changed

+9
-2
lines changed
  • src/backend/executor

1 file changed

+9
-2
lines changed

‎src/backend/executor/spi.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.166 2006/12/08 00:40:27 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.167 2006/12/26 16:56:18 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1341,6 +1341,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
13411341
volatileuint32my_processed=0;
13421342
volatileOidmy_lastoid=InvalidOid;
13431343
SPITupleTable*volatilemy_tuptable=NULL;
1344+
volatileintres=0;
13441345
SnapshotsaveActiveSnapshot;
13451346

13461347
/* Be sure to restore ActiveSnapshot on error exit */
@@ -1396,7 +1397,6 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
13961397
Plan*planTree;
13971398
QueryDesc*qdesc;
13981399
DestReceiver*dest;
1399-
intres;
14001400

14011401
planTree=lfirst(plan_list_item);
14021402
plan_list_item=lnext(plan_list_item);
@@ -1546,6 +1546,13 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
15461546
/* tuptable now is caller's responsibility, not SPI's */
15471547
_SPI_current->tuptable=NULL;
15481548

1549+
/*
1550+
* If none of the queries had canSetTag, we return the last query's result
1551+
* code, but not its auxiliary results (for backwards compatibility).
1552+
*/
1553+
if (my_res==0)
1554+
my_res=res;
1555+
15491556
returnmy_res;
15501557
}
15511558

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp