Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4a682d8

Browse files
committed
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.(Seepython/cpython#25719 for the discussionof this change in Python.)Author: Honza Horak <hhorak@redhat.com>Discussion:https://www.postgresql.org/message-id/flat/853083.1620749597%40sss.pgh.pa.usRHBZ:https://bugzilla.redhat.com/show_bug.cgi?id=1959080
1 parentf61db90 commit4a682d8

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

‎src/pl/plpython/expected/plpython_subtransaction.out

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,11 @@ with plpy.subtransaction() as s:
171171
$$ LANGUAGE plpythonu;
172172
CREATE FUNCTION subtransaction_exit_subtransaction_in_with() RETURNS void
173173
AS $$
174-
with plpy.subtransaction() as s:
175-
s.__exit__(None, None, None)
174+
try:
175+
with plpy.subtransaction() as s:
176+
s.__exit__(None, None, None)
177+
except ValueError as e:
178+
raise ValueError(e)
176179
$$ LANGUAGE plpythonu;
177180
SELECT subtransaction_exit_without_enter();
178181
ERROR: ValueError: this subtransaction has not been entered
@@ -224,8 +227,8 @@ PL/Python function "subtransaction_enter_subtransaction_in_with"
224227
SELECT subtransaction_exit_subtransaction_in_with();
225228
ERROR: ValueError: this subtransaction has already been exited
226229
CONTEXT: Traceback (most recent call last):
227-
PL/Python function "subtransaction_exit_subtransaction_in_with", line3, in <module>
228-
s.__exit__(None, None, None)
230+
PL/Python function "subtransaction_exit_subtransaction_in_with", line6, in <module>
231+
raise ValueError(e)
229232
PL/Python function "subtransaction_exit_subtransaction_in_with"
230233
-- Make sure we don't get a "current transaction is aborted" error
231234
SELECT 1 as test;

‎src/pl/plpython/sql/plpython_subtransaction.sql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,11 @@ $$ LANGUAGE plpythonu;
121121

122122
CREATEFUNCTIONsubtransaction_exit_subtransaction_in_with() RETURNS void
123123
AS $$
124-
withplpy.subtransaction()as s:
125-
s.__exit__(None, None, None)
124+
try:
125+
withplpy.subtransaction()as s:
126+
s.__exit__(None, None, None)
127+
except ValueErroras e:
128+
raise ValueError(e)
126129
$$ LANGUAGE plpythonu;
127130

128131
SELECT subtransaction_exit_without_enter();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp