were marked canSetTag. While it's certainly correct to return the result
of the last one that is marked canSetTag, it's less clear what to do when
none of them are. Since plpgsql will complain if zero is returned, the
8.2.0 behavior isn't good. I've fixed it to restore the prior behavior of
returning the physically last query's result code when there are no
canSetTag queries.
- * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.166 2006/12/08 00:40:27 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.167 2006/12/26 16:56:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*
*-------------------------------------------------------------------------
*/
volatile uint32 my_processed = 0;
volatile Oid my_lastoid = InvalidOid;
SPITupleTable *volatile my_tuptable = NULL;
volatile uint32 my_processed = 0;
volatile Oid my_lastoid = InvalidOid;
SPITupleTable *volatile my_tuptable = NULL;
Snapshot saveActiveSnapshot;
/* Be sure to restore ActiveSnapshot on error exit */
Snapshot saveActiveSnapshot;
/* Be sure to restore ActiveSnapshot on error exit */
Plan *planTree;
QueryDesc *qdesc;
DestReceiver *dest;
Plan *planTree;
QueryDesc *qdesc;
DestReceiver *dest;
planTree = lfirst(plan_list_item);
plan_list_item = lnext(plan_list_item);
planTree = lfirst(plan_list_item);
plan_list_item = lnext(plan_list_item);
/* tuptable now is caller's responsibility, not SPI's */
_SPI_current->tuptable = NULL;
/* tuptable now is caller's responsibility, not SPI's */
_SPI_current->tuptable = NULL;
+ /*
+ * If none of the queries had canSetTag, we return the last query's result
+ * code, but not its auxiliary results (for backwards compatibility).
+ */
+ if (my_res == 0)
+ my_res = res;
+