88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.155 2006/08/12 20:05:55 tgl Exp $
11+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.156 2006/08/14 13:40:18 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -1306,7 +1306,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
13061306Snapshot snapshot ,Snapshot crosscheck_snapshot ,
13071307bool read_only ,long tcount )
13081308{
1309- volatile int res = 0 ;
1309+ volatile int my_res = 0 ;
13101310volatile uint32 my_processed = 0 ;
13111311volatile Oid my_lastoid = InvalidOid ;
13121312SPITupleTable * volatile my_tuptable = NULL ;
@@ -1364,6 +1364,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
13641364Plan * planTree ;
13651365QueryDesc * qdesc ;
13661366DestReceiver * dest ;
1367+ int res ;
13671368
13681369planTree = lfirst (plan_list_item );
13691370plan_list_item = lnext (plan_list_item );
@@ -1380,20 +1381,20 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
13801381
13811382if (stmt -> filename == NULL )
13821383{
1383- res = SPI_ERROR_COPY ;
1384+ my_res = SPI_ERROR_COPY ;
13841385gotofail ;
13851386}
13861387}
13871388else if (IsA (queryTree -> utilityStmt ,DeclareCursorStmt )||
13881389IsA (queryTree -> utilityStmt ,ClosePortalStmt )||
13891390IsA (queryTree -> utilityStmt ,FetchStmt ))
13901391{
1391- res = SPI_ERROR_CURSOR ;
1392+ my_res = SPI_ERROR_CURSOR ;
13921393gotofail ;
13931394}
13941395else if (IsA (queryTree -> utilityStmt ,TransactionStmt ))
13951396{
1396- res = SPI_ERROR_TRANSACTION ;
1397+ my_res = SPI_ERROR_TRANSACTION ;
13971398gotofail ;
13981399}
13991400}
@@ -1459,7 +1460,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
14591460ActiveSnapshot = NULL ;
14601461
14611462/*
1462- * The last canSetTag query sets theauxiliary values returned
1463+ * The last canSetTag query sets thestatus values returned
14631464 * to the caller. Be careful to free any tuptables not
14641465 * returned, to avoid intratransaction memory leak.
14651466 */
@@ -1469,6 +1470,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
14691470my_lastoid = _SPI_current -> lastoid ;
14701471SPI_freetuptable (my_tuptable );
14711472my_tuptable = _SPI_current -> tuptable ;
1473+ my_res = res ;
14721474}
14731475else
14741476{
@@ -1477,7 +1479,10 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
14771479}
14781480/* we know that the receiver doesn't need a destroy call */
14791481if (res < 0 )
1482+ {
1483+ my_res = res ;
14801484gotofail ;
1485+ }
14811486}
14821487}
14831488
@@ -1503,7 +1508,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
15031508SPI_lastoid = my_lastoid ;
15041509SPI_tuptable = my_tuptable ;
15051510
1506- return res ;
1511+ return my_res ;
15071512}
15081513
15091514static int