pgsql: Improve error report for PL/pgSQL reserved word used as a field

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve error report for PL/pgSQL reserved word used as a field
Date: 2025-06-30 21:06:46
Message-ID: E1uWLiA-0045jd-1F@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-06-30 23:59:38 pgsql: Improve error handling of libxml2 calls in xml.c
Previous Message Nathan Bossart 2025-06-30 20:40:38 pgsql: Add new OID alias type regdatabase.