mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Add new SPI_OK_REWRITTEN return code to SPI_execute and friends, for the
case that the command is rewritten into another type of command. The old behavior to return the command tag of the last executed command was pretty surprising. In PL/pgSQL, for example, it meant that if a command was rewritten to a utility statement, FOUND wasn't set at all.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.206 2009/01/07 20:38:56 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.207 2009/01/21 11:02:40 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1490,6 +1490,8 @@ SPI_result_code_string(int code)
|
||||
return "SPI_OK_DELETE_RETURNING";
|
||||
case SPI_OK_UPDATE_RETURNING:
|
||||
return "SPI_OK_UPDATE_RETURNING";
|
||||
case SPI_OK_REWRITTEN:
|
||||
return "SPI_OK_REWRITTEN";
|
||||
}
|
||||
/* Unrecognized code ... return something useful ... */
|
||||
sprintf(buf, "Unrecognized SPI code %d", code);
|
||||
@ -1910,11 +1912,12 @@ fail:
|
||||
_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 none of the queries had canSetTag, return SPI_OK_REWRITTEN. Prior
|
||||
* to 8.4, we used return the last query's result code, but not its
|
||||
* auxiliary results, but that's confusing.
|
||||
*/
|
||||
if (my_res == 0)
|
||||
my_res = res;
|
||||
my_res = SPI_OK_REWRITTEN;
|
||||
|
||||
return my_res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user