From 91d03e378a9572747f4edaa64973811fe61f52fd Mon Sep 17 00:00:00 2001 From: Honza Horak Date: Tue, 11 May 2021 23:06:31 +0200 Subject: [PATCH] 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 - s.__exit__(None, None, None) + PL/Python function "subtransaction_exit_subtransaction_in_with", line 2, in + with plpy.subtransaction() as s: Using try/except specifically makes the error look always the same. Resolves: #1959080 --- postgresql-subtransaction-test.patch | 56 ++++++++++++++++++++++++++++ postgresql.spec | 7 +++- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 postgresql-subtransaction-test.patch diff --git a/postgresql-subtransaction-test.patch b/postgresql-subtransaction-test.patch new file mode 100644 index 0000000..e470e18 --- /dev/null +++ b/postgresql-subtransaction-test.patch @@ -0,0 +1,56 @@ +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 + - s.__exit__(None, None, None) + + PL/Python function "subtransaction_exit_subtransaction_in_with", line 2, in + + with plpy.subtransaction() as s: +Using try/except specifically makes the error look always the same. + +RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1959080 + +diff -up postgresql-13.2/src/pl/plpython/expected/plpython_subtransaction.out.patchnew postgresql-13.2/src/pl/plpython/expected/plpython_subtransaction.out +--- postgresql-13.2/src/pl/plpython/expected/plpython_subtransaction.out.patchnew 2021-02-08 22:54:11.000000000 +0100 ++++ postgresql-13.2/src/pl/plpython/expected/plpython_subtransaction.out 2021-05-11 21:04:25.085586012 +0200 +@@ -171,8 +171,11 @@ with plpy.subtransaction() as s: + $$ LANGUAGE plpythonu; + CREATE FUNCTION subtransaction_exit_subtransaction_in_with() RETURNS void + AS $$ +-with plpy.subtransaction() as s: +- s.__exit__(None, None, None) ++try: ++ with plpy.subtransaction() as s: ++ s.__exit__(None, None, None) ++except ValueError as e: ++ raise ValueError(e) + $$ LANGUAGE plpythonu; + SELECT subtransaction_exit_without_enter(); + ERROR: ValueError: this subtransaction has not been entered +@@ -224,8 +227,8 @@ PL/Python function "subtransaction_enter + SELECT subtransaction_exit_subtransaction_in_with(); + ERROR: ValueError: this subtransaction has already been exited + CONTEXT: Traceback (most recent call last): +- PL/Python function "subtransaction_exit_subtransaction_in_with", line 3, in +- s.__exit__(None, None, None) ++ PL/Python function "subtransaction_exit_subtransaction_in_with", line 6, in ++ raise ValueError(e) + PL/Python function "subtransaction_exit_subtransaction_in_with" + -- Make sure we don't get a "current transaction is aborted" error + SELECT 1 as test; +diff -up postgresql-13.2/src/pl/plpython/sql/plpython_subtransaction.sql.patchnew postgresql-13.2/src/pl/plpython/sql/plpython_subtransaction.sql +--- postgresql-13.2/src/pl/plpython/sql/plpython_subtransaction.sql.patchnew 2021-02-08 22:54:11.000000000 +0100 ++++ postgresql-13.2/src/pl/plpython/sql/plpython_subtransaction.sql 2021-05-11 21:02:34.386415376 +0200 +@@ -121,8 +121,11 @@ $$ LANGUAGE plpythonu; + + CREATE FUNCTION subtransaction_exit_subtransaction_in_with() RETURNS void + AS $$ +-with plpy.subtransaction() as s: +- s.__exit__(None, None, None) ++try: ++ with plpy.subtransaction() as s: ++ s.__exit__(None, None, None) ++except ValueError as e: ++ raise ValueError(e) + $$ LANGUAGE plpythonu; + + SELECT subtransaction_exit_without_enter(); diff --git a/postgresql.spec b/postgresql.spec index ce10028..d19c74c 100644 --- a/postgresql.spec +++ b/postgresql.spec @@ -110,6 +110,7 @@ Patch9: postgresql-server-pg_config.patch # Upstream bug #16971: https://www.postgresql.org/message-id/16971-5d004d34742a3d35%40postgresql.org # rhbz#1940964 Patch10: postgresql-datalayout-mismatch-on-s390.patch +Patch11: postgresql-subtransaction-test.patch BuildRequires: make BuildRequires: gcc @@ -379,6 +380,7 @@ goal of accelerating analytics queries. %patch8 -p1 %patch9 -p1 %patch10 -p1 +%patch11 -p1 # We used to run autoconf here, but there's no longer any real need to, # since Postgres ships with a reasonably modern configure script. @@ -1130,8 +1132,9 @@ make -C postgresql-setup-%{setup_version} check * Thu May 20 2021 Pete Walter - 13.2-8 - Rebuild for ICU 69 -* Wed May 19 2021 Pete Walter - 13.2-7 -- Rebuild for ICU 69 +* Tue May 11 2021 Honza Horak - 13.2-7 +- Fix subtransaction test for Python 3.10 + Resolves: #1959080 * Thu Apr 22 2021 Honza Horak - 13.2-6 - Fix jit failure on s390x