]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix recursive RECORD-returning plpython functions.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 May 2024 17:16:21 +0000 (13:16 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 May 2024 17:16:21 +0000 (13:16 -0400)
commit157b1e6b41b4a1f4bdb3166c791bb3a103abd8c4
treed04b4f4eebf6bf4d02e4cc1a66b3118ff13878bb
parenta3c00ab1545029ee5d8c87d55da976ae1ccf2ba8
Fix recursive RECORD-returning plpython functions.

If we recursed to a new call of the same function, with a different
coldeflist (AS clause), it would fail because the inner call would
overwrite the outer call's idea of what to return.  This is vaguely
like 1d2fe56e4 and c5bec5426, but it's not due to any API decisions:
it's just that we computed the actual output rowtype at the start of
the call, and saved it in the per-procedure data structure.  We can
fix it at basically zero cost by doing the computation at the end
of each call instead of the start.

It's not clear that there's any real-world use-case for such a
function, but given that it doesn't cost anything to fix,
it'd be silly not to.

Per report from Andreas Karlsson.  Back-patch to all supported
branches.

Discussion: https://postgr.es/m/1651a46d-3c15-4028-a8c1-d74937b54e19@proxel.se
src/pl/plpython/expected/plpython_composite.out
src/pl/plpython/plpy_exec.c
src/pl/plpython/sql/plpython_composite.sql