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

Commit1a2752b

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 parent5a45603 commit1a2752b

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
@@ -236,8 +236,11 @@ with plpy.subtransaction() as s:
236236
$$ LANGUAGE plpythonu;
237237
CREATE FUNCTION subtransaction_exit_subtransaction_in_with() RETURNS void
238238
AS $$
239-
with plpy.subtransaction() as s:
240-
s.__exit__(None, None, None)
239+
try:
240+
with plpy.subtransaction() as s:
241+
s.__exit__(None, None, None)
242+
except ValueError as e:
243+
raise ValueError(e)
241244
$$ LANGUAGE plpythonu;
242245
SELECT subtransaction_exit_without_enter();
243246
ERROR: ValueError: this subtransaction has not been entered
@@ -289,8 +292,8 @@ PL/Python function "subtransaction_enter_subtransaction_in_with"
289292
SELECT subtransaction_exit_subtransaction_in_with();
290293
ERROR: ValueError: this subtransaction has already been exited
291294
CONTEXT: Traceback (most recent call last):
292-
PL/Python function "subtransaction_exit_subtransaction_in_with", line3, in <module>
293-
s.__exit__(None, None, None)
295+
PL/Python function "subtransaction_exit_subtransaction_in_with", line6, in <module>
296+
raise ValueError(e)
294297
PL/Python function "subtransaction_exit_subtransaction_in_with"
295298
-- Make sure we don't get a "current transaction is aborted" error
296299
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
@@ -158,8 +158,11 @@ $$ LANGUAGE plpythonu;
158158

159159
CREATEFUNCTIONsubtransaction_exit_subtransaction_in_with() RETURNS void
160160
AS $$
161-
withplpy.subtransaction()as s:
162-
s.__exit__(None, None, None)
161+
try:
162+
withplpy.subtransaction()as s:
163+
s.__exit__(None, None, None)
164+
except ValueErroras e:
165+
raise ValueError(e)
163166
$$ LANGUAGE plpythonu;
164167

165168
SELECT subtransaction_exit_without_enter();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp