postgresql/src/pl/plpython/expected
Tom Lane 2e517818f4 Fix SPI's handling of errors during transaction commit.
SPI_commit previously left it up to the caller to recover from any error
occurring during commit.  Since that's complicated and requires use of
low-level xact.c facilities, it's not too surprising that no caller got
it right.  Let's move the responsibility for cleanup into spi.c.  Doing
that requires redefining SPI_commit as starting a new transaction, so
that it becomes equivalent to SPI_commit_and_chain except that you get
default transaction characteristics instead of preserving the prior
transaction's characteristics.  We can make this pretty transparent
API-wise by redefining SPI_start_transaction() as a no-op.  Callers
that expect to do something in between might be surprised, but
available evidence is that no callers do so.

Having made that API redefinition, we can fix this mess by having
SPI_commit[_and_chain] trap errors and start a new, clean transaction
before re-throwing the error.  Likewise for SPI_rollback[_and_chain].
Some cleanup is also needed in AtEOXact_SPI, which was nowhere near
smart enough to deal with SPI contexts nested inside a committing
context.

While plperl and pltcl need no changes beyond removing their now-useless
SPI_start_transaction() calls, plpython needs some more work because it
hadn't gotten the memo about catching commit/rollback errors in the
first place.  Such an error resulted in longjmp'ing out of the Python
interpreter, which leaks Python stack entries at present and is reported
to crash Python 3.11 altogether.  Add the missing logic to catch such
errors and convert them into Python exceptions.

We are probably going to have to back-patch this once Python 3.11 ships,
but it's a sufficiently basic change that I'm a bit nervous about doing
so immediately.  Let's let it bake awhile in HEAD first.

Peter Eisentraut and Tom Lane

Discussion: https://postgr.es/m/3375ffd8-d71c-2565-e348-a597d6e739e3@enterprisedb.com
Discussion: https://postgr.es/m/17416-ed8fe5d7213d6c25@postgresql.org
2022-02-28 12:45:36 -05:00
..
plpython_call.out Reconsider the handling of procedure OUT parameters. 2021-06-10 17:11:36 -04:00
plpython_composite.out PL/Python: Fix hint about returning composite type from Python 2017-06-30 16:51:14 -04:00
plpython_do.out Rearrange the handling of error context reports. 2015-09-05 11:58:33 -04:00
plpython_drop.out Create extension infrastructure for the core procedural languages. 2011-03-04 21:51:14 -05:00
plpython_ereport.out Modernize Python exception syntax in tests 2020-01-08 22:47:22 +01:00
plpython_error.out Modernize Python exception syntax in tests 2020-01-08 22:47:22 +01:00
plpython_error_5.out Fix broken logic for reporting PL/Python function names in errcontext. 2018-02-14 14:47:18 -05:00
plpython_global.out Make PL/Python tests more compatible with Python 3 2009-08-24 20:25:25 +00:00
plpython_import.out Modernize Python exception syntax in tests 2020-01-08 22:47:22 +01:00
plpython_newline.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
plpython_params.out Modernize Python exception syntax in tests 2020-01-08 22:47:22 +01:00
plpython_populate.out
plpython_quote.out Add PL/Python functions for quoting strings 2011-02-22 23:41:23 +02:00
plpython_record.out PL/Python: Accept strings in functions returning composite types 2012-04-26 21:03:48 +03:00
plpython_schema.out Reduce messages about implicit indexes and sequences to DEBUG1. 2012-07-04 20:35:29 -04:00
plpython_setof.out Adapt python regression tests to 69f4b9c85f. 2017-01-18 16:11:19 -08:00
plpython_spi.out Modernize Python exception syntax in tests 2020-01-08 22:47:22 +01:00
plpython_subtransaction.out Fix subtransaction test for Python 3.10 2021-06-05 07:16:34 +02:00
plpython_test.out Transaction control in PL procedures 2018-01-22 08:43:06 -05:00
plpython_transaction.out Fix SPI's handling of errors during transaction commit. 2022-02-28 12:45:36 -05:00
plpython_trigger.out Generated columns 2019-03-30 08:15:57 +01:00
plpython_types.out Modernize Python exception syntax in tests 2020-01-08 22:47:22 +01:00
plpython_types_3.out Mop-up for 3522d0eaba, which missed some alternative output files. 2018-07-22 17:39:02 -07:00
plpython_unicode.out Make plpython_unicode regression test work in more database encodings. 2014-06-03 12:01:54 -04:00
plpython_void.out Enhanced error context support in PL/Python 2009-08-25 12:44:59 +00:00
README Remove support for Python older than 2.6 2020-01-08 22:47:22 +01:00

Guide to alternative expected files:

plpython_error_5.out			Python 3.5 and newer

plpython_unicode.out			server encoding != SQL_ASCII
plpython_unicode_3.out			server encoding == SQL_ASCII

plpython_types_3.out			Python 3.x