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: Improve error report for PL/pgSQL reserved word used as a field
Date: Mon, 30 Jun 2025 21:06:46 +0000
Message-ID: <E1uWLiA-0045jd-1F@gemulon.postgresql.org> (raw)

Improve error report for PL/pgSQL reserved word used as a field name.

The current code in resolve_column_ref (dating to commits 01f7d2990
and fe24d7816) believes that not finding a RECFIELD datum is a
can't-happen case, in consequence of which I didn't spend a whole lot
of time considering what to do if it did happen.  But it turns out
that it *can* happen if the would-be field name is a fully-reserved
PL/pgSQL keyword.  Change the error message to describe that
situation, and add a test case demonstrating it.

This might need further refinement if anyone can find other ways to
trigger a failure here; but without an example it's not clear what
other error to throw.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
Discussion: https://postgr.es/m/2185258.1745617445@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0836683a8977cac07d8cbdd0462f8a3e7e32565f

Modified Files
--------------
src/pl/plpgsql/src/expected/plpgsql_misc.out | 22 ++++++++++++++++++++++
src/pl/plpgsql/src/pl_comp.c                 | 19 ++++++++++++-------
src/pl/plpgsql/src/sql/plpgsql_misc.sql      | 16 ++++++++++++++++
3 files changed, 50 insertions(+), 7 deletions(-)



Message-ID: <E1uWLiA-0045jd-1F@gemulon.postgresql.org>
Permalink:  ../E1uWLiA-0045jd-1F@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uWLiA-0045jd-1F@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: Improve error report for PL/pgSQL reserved word used as a field
  In-Reply-To: <E1uWLiA-0045jd-1F@gemulon.postgresql.org>
  References: <E1uWLiA-0045jd-1F@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