summaryrefslogtreecommitdiff
path: root/src/pl/plpython/expected/plpython_error.out
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-11-24 17:18:43 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-11-24 17:18:43 +0200
commitf21fc7f9fc63ff86d7d77d352ae274b6e2b6e09e (patch)
tree04b60697b3d4cb694b544dca4a008d3f687c337f /src/pl/plpython/expected/plpython_error.out
parent5df1403b0f2b44235c8f401bd49dab9a8cf6bf90 (diff)
Preserve SQLSTATE when an SPI error is propagated through PL/python
exception handler. This was a regression in 9.1, when the capability to catch specific SPI errors was added, so backpatch to 9.1. Mika Eloranta, with some editing by Jan UrbaƄski.
Diffstat (limited to 'src/pl/plpython/expected/plpython_error.out')
-rw-r--r--src/pl/plpython/expected/plpython_error.out22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pl/plpython/expected/plpython_error.out b/src/pl/plpython/expected/plpython_error.out
index dbf19fda9b9..bab07fbeb24 100644
--- a/src/pl/plpython/expected/plpython_error.out
+++ b/src/pl/plpython/expected/plpython_error.out
@@ -351,6 +351,28 @@ CONTEXT: PL/Python function "specific_exception"
(1 row)
+/* SPI errors in PL/Python functions should preserve the SQLSTATE value
+ */
+CREATE FUNCTION python_unique_violation() RETURNS void AS $$
+plpy.execute("insert into specific values (1)")
+plpy.execute("insert into specific values (1)")
+$$ LANGUAGE plpythonu;
+CREATE FUNCTION catch_python_unique_violation() RETURNS text AS $$
+begin
+ begin
+ perform python_unique_violation();
+ exception when unique_violation then
+ return 'ok';
+ end;
+ return 'not reached';
+end;
+$$ language plpgsql;
+SELECT catch_python_unique_violation();
+ catch_python_unique_violation
+-------------------------------
+ ok
+(1 row)
+
/* manually starting subtransactions - a bad idea
*/
CREATE FUNCTION manual_subxact() RETURNS void AS $$