public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: [email protected]
Subject: pgsql: Fix plpgsql's handling of "return simple_record_variable".
Date: Wed, 11 Feb 2026 21:53:34 +0000
Message-ID: <[email protected]> (raw)

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 <[email protected]>
Author: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/CAFj8pRBT_ahexDf-zT-cyH8bMR_qcySKM8D5nv5MvTWPiatYGA@mail.gmail.com
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b93d382055b62e1493cfbb6c3b5547c1bb9ab82

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(-)



view thread (6+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Fix plpgsql's handling of "return simple_record_variable".
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox