| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix plpgsql's handling of "return simple_record_variable". |
| Date: | 2026-02-11 21:53:34 |
| Message-ID: | E1vqI9N-000GOk-21@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(dot)stehule(at)gmail(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAFj8pRBT_ahexDf-zT-cyH8bMR_qcySKM8D5nv5MvTWPiatYGA@mail.gmail.com
Backpatch-through: 14
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/ce4b7e3a1058eb3edd7511f2770379d7f78bd3a0
Modified Files
--------------
src/pl/plpgsql/src/expected/plpgsql_domain.out | 13 +++++++++++++
src/pl/plpgsql/src/pl_exec.c | 20 +++-----------------
src/pl/plpgsql/src/sql/plpgsql_domain.sql | 10 ++++++++++
3 files changed, 26 insertions(+), 17 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2026-02-12 06:31:07 | pgsql: Reduce LEFT JOIN to ANTI JOIN using NOT NULL constraints |
| Previous Message | Heikki Linnakangas | 2026-02-11 17:00:27 | pgsql: Fix pg_stat_get_backend_wait_event() for aux processes |