Fix subtransaction test for Python 3.10
Starting with Python 3.10, the stacktrace looks differently: - PL/Python function "subtransaction_exit_subtransaction_in_with", line 3, in <module> - s.__exit__(None, None, None) + PL/Python function "subtransaction_exit_subtransaction_in_with", line 2, in <module> + with plpy.subtransaction() as s: Using try/except specifically makes the error look always the same. (See https://github.com/python/cpython/pull/25719 for the discussion of this change in Python.) Author: Honza Horak <hhorak@redhat.com> Discussion: https://www.postgresql.org/message-id/flat/853083.1620749597%40sss.pgh.pa.us RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1959080
This commit is contained in:
parent
9f7bba2629
commit
3989f8fb9d
@ -171,8 +171,11 @@ with plpy.subtransaction() as s:
|
|||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
CREATE FUNCTION subtransaction_exit_subtransaction_in_with() RETURNS void
|
CREATE FUNCTION subtransaction_exit_subtransaction_in_with() RETURNS void
|
||||||
AS $$
|
AS $$
|
||||||
with plpy.subtransaction() as s:
|
try:
|
||||||
|
with plpy.subtransaction() as s:
|
||||||
s.__exit__(None, None, None)
|
s.__exit__(None, None, None)
|
||||||
|
except ValueError as e:
|
||||||
|
raise ValueError(e)
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
SELECT subtransaction_exit_without_enter();
|
SELECT subtransaction_exit_without_enter();
|
||||||
ERROR: ValueError: this subtransaction has not been entered
|
ERROR: ValueError: this subtransaction has not been entered
|
||||||
@ -224,8 +227,8 @@ PL/Python function "subtransaction_enter_subtransaction_in_with"
|
|||||||
SELECT subtransaction_exit_subtransaction_in_with();
|
SELECT subtransaction_exit_subtransaction_in_with();
|
||||||
ERROR: ValueError: this subtransaction has already been exited
|
ERROR: ValueError: this subtransaction has already been exited
|
||||||
CONTEXT: Traceback (most recent call last):
|
CONTEXT: Traceback (most recent call last):
|
||||||
PL/Python function "subtransaction_exit_subtransaction_in_with", line 3, in <module>
|
PL/Python function "subtransaction_exit_subtransaction_in_with", line 6, in <module>
|
||||||
s.__exit__(None, None, None)
|
raise ValueError(e)
|
||||||
PL/Python function "subtransaction_exit_subtransaction_in_with"
|
PL/Python function "subtransaction_exit_subtransaction_in_with"
|
||||||
-- Make sure we don't get a "current transaction is aborted" error
|
-- Make sure we don't get a "current transaction is aborted" error
|
||||||
SELECT 1 as test;
|
SELECT 1 as test;
|
||||||
|
@ -121,8 +121,11 @@ $$ LANGUAGE plpythonu;
|
|||||||
|
|
||||||
CREATE FUNCTION subtransaction_exit_subtransaction_in_with() RETURNS void
|
CREATE FUNCTION subtransaction_exit_subtransaction_in_with() RETURNS void
|
||||||
AS $$
|
AS $$
|
||||||
with plpy.subtransaction() as s:
|
try:
|
||||||
|
with plpy.subtransaction() as s:
|
||||||
s.__exit__(None, None, None)
|
s.__exit__(None, None, None)
|
||||||
|
except ValueError as e:
|
||||||
|
raise ValueError(e)
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
SELECT subtransaction_exit_without_enter();
|
SELECT subtransaction_exit_without_enter();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user