diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-01-21 11:02:40 +0000 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-01-21 11:02:40 +0000 |
commit | 94136d5a18403445cd60ae6beb470f6ebecca8b3 (patch) | |
tree | 96999d4189dbaf14033fa70cad6cf9d0ae904904 /src/backend/executor | |
parent | 0154345078fb96a8bbe8b8785628400b17e5a75b (diff) | |
download | postgresql-94136d5a18403445cd60ae6beb470f6ebecca8b3.tar.gz postgresql-94136d5a18403445cd60ae6beb470f6ebecca8b3.zip |
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.
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/spi.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index aa562c2ea9a..f750560c6f4 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -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; } |