diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-09-19 08:31:27 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-09-19 08:31:27 +0900 |
commit | 35e8ba3e54ec01fb705c31061eaeda56ba904354 (patch) | |
tree | 1fcca59b0a75f6a8e74104636b40b4d6e8bf19f9 /src/pl/plpython/sql/plpython_error.sql | |
parent | e6e50ada07bbbbea2a68597d0bf7f795b0dc1269 (diff) | |
download | postgresql-35e8ba3e54ec01fb705c31061eaeda56ba904354.tar.gz postgresql-35e8ba3e54ec01fb705c31061eaeda56ba904354.zip |
Fix assertion failure with PL/Python exceptions
PLy_elog() was not able to handle correctly cases where a SPI called
failed, which would fill in a DETAIL string able to trigger an
assertion. We may want to improve this infrastructure so as it is able
to provide any extra detail information provided by an error stack, but
this is left as a future improvement as it could impact existing error
stacks and any applications that depend on them. For now, the assertion
is removed and a regression test is added to cover the case of a failure
with a detail string.
This problem exists since 2bd78eb8d51c, so backpatch all the way down
with tweaks to the regression tests output added where required.
Author: Alexander Lakhin
Discussion: https://postgr.es/m/18070-ab9c171cbf4ebb0f@postgresql.org
Backpatch-through: 11
Diffstat (limited to 'src/pl/plpython/sql/plpython_error.sql')
-rw-r--r-- | src/pl/plpython/sql/plpython_error.sql | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pl/plpython/sql/plpython_error.sql b/src/pl/plpython/sql/plpython_error.sql index 88d6936fd0d..8d86bf7d1e0 100644 --- a/src/pl/plpython/sql/plpython_error.sql +++ b/src/pl/plpython/sql/plpython_error.sql @@ -344,3 +344,14 @@ $$ LANGUAGE plpythonu; \set SHOW_CONTEXT always SELECT notice_outerfunc(); + +/* test error logged with an underlying exception that includes a detail + * string (bug #18070). + */ +CREATE FUNCTION python_error_detail() RETURNS SETOF text AS $$ + plan = plpy.prepare("SELECT to_date('xy', 'DD') d") + for row in plpy.cursor(plan): + yield row['d'] +$$ LANGUAGE plpythonu; + +SELECT python_error_detail(); |