]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix plpgsql's handling of "return simple_record_variable".
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 11 Feb 2026 21:53:14 +0000 (16:53 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 11 Feb 2026 21:53:14 +0000 (16:53 -0500)
commit9863c90759ecb3c200520db9a8b02c33eaec6e17
tree1ac45337723d2920376546c5545c042df8e3e679
parent78a5e3074b824b4bbcb75ea4dd565ce735f54293
Fix plpgsql's handling of "return simple_record_variable".

If the variable's value is null, exec_stmt_return() missed filling
in estate->rettype.  This is a pretty old bug, but we'd managed not
to notice because that value isn't consulted for a null result ...
unless we have to cast it to a domain.  That case led to a failure
with "cache lookup failed for type 0".

The correct way to assign the data type is known by exec_eval_datum.
While we could copy-and-paste that logic, it seems like a better
idea to just invoke exec_eval_datum, as the ROW case already does.

Reported-by: Pavel Stehule <pavel.stehule@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAFj8pRBT_ahexDf-zT-cyH8bMR_qcySKM8D5nv5MvTWPiatYGA@mail.gmail.com
Backpatch-through: 14
src/pl/plpgsql/src/expected/plpgsql_domain.out
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/sql/plpgsql_domain.sql