pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't crash on null pstate in coerce_record_to_complex().
Date: Wed, 18 Nov 2026 02:55:50 +0000
Message-ID: <E1xTVpt-00000000AuA-2v9S@gemulon.postgresql.org> (raw)

Don't crash on null pstate in coerce_record_to_complex().

Since commit 913bbd88d, this case is reachable if a SQL-language
function returns a whole-row Var of type RECORD when its declared
output type is a named composite type.  We'd need the original
ParseState to find out what the Var's columns are, but we don't have
that structure at hand anymore.  This didn't work before 913bbd88d
either, but you got a slightly off-point error message instead of a
crash.

Given that this has never worked and there's been no field complaints
about that before now, it doesn't seem worth doing major work to fix
this.  Let's just ensure that we throw a helpful error explaining what
to do to work around the limitation.  (The workaround actually reaches
this same code, but does so while we still have the ParseState.)

While at it, update various badly-obsolete comments about what
coerce_type() uses its pstate argument for.

Bug: #19906
Reported-by: Boris Murasov <murasovb@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/19906-229033275b593ef0@postgresql.org
Backpatch-through: 15

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/64f45756ed67895b3073b9f5ee42bdff27ad3a28

Modified Files
--------------
src/backend/parser/parse_coerce.c        | 49 ++++++++++++++++++++------------
src/backend/parser/parse_expr.c          |  4 +--
src/backend/parser/parse_func.c          |  3 +-
src/test/regress/expected/rangefuncs.out |  9 +++++-
src/test/regress/sql/rangefuncs.sql      |  7 ++++-
5 files changed, 47 insertions(+), 25 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1xTVpt-00000000AuA-2v9S@gemulon.postgresql.org>
Permalink:  ../E1xTVpt-00000000AuA-2v9S@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xTVpt-00000000AuA-2v9S@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Don't crash on null pstate in coerce_record_to_complex().
  In-Reply-To: <E1xTVpt-00000000AuA-2v9S@gemulon.postgresql.org>
  References: <E1xTVpt-00000000AuA-2v9S@gemulon.postgresql.org>

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

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