The following bug has been logged online:
Bug reference: 5500
Logged by: Robert Walker
Email address: robwalker01@speedymail.org
PostgreSQL version: 9.0 beta 2
Operating system: Windows XP 32-bit SP2
Description: SPI_execute_plan_with_paramlist SPI_ERROR_TRANSACTION
with savepoint
Details:
SPI_execute_plan_with_paramlist seems to be newly introduced into 9.0 beta
that is causing an error in pl/pgsql when attempting to create a savepoint.
This did not happen when using version 8.4 (which I assume was not using
SPI_execute_plan_with_paramlist), so I believe this is a regression.
The specific format of the error is:
ERROR: SPI_execute_plan_with_paramlist failed executing query "SAVEPOINT
savepoint_name": SPI_ERROR_TRANSACTION
SQL state: XX000
Context: PL/pgSQL function "add_foo" line 241 at SQL statement
Before the savepoint is only a couple of statements: one insert statement
and another insert statement using "returning *" into a variable. The
function parameters use %TYPE in order to help ensure the parameters match
the same type as the table column it is meant to deal with. The function's
return value is a rowtype of the results from the insert/returning right
before the savepoint.
If I comment out the few lines regarding savepoints, the function works (but
without error trapping of course), so I know it's not a syntax error or some
other type of error. PostgreSQL for some reason wants to use
SPI_execute_plan_with_paramlist and this causes the error.