From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix PL/pgSQL error message on EOF in the middle of an expression
Date: Sat, 31 Oct 2026 11:01:03 +0000
Message-ID: <E1xN6pb-00000001Wbd-0RGj@gemulon.postgresql.org> (raw)
Fix PL/pgSQL error message on EOF in the middle of an expression
read_sql_construct() takes up to three terminator tokens, passing zero
for those not used. But zero is also the token code for end of input,
so when the function body ended in the middle of an expression or
statement, the loop treated EOF as a valid terminator and stopped
there, instead of reaching the code that reports a missing terminator.
Users got a generic 'syntax error at end of input', or a misleading
'missing expression at end of input', instead of e.g. 'missing "THEN"
at end of SQL expression'.
Don't let unused terminator slots match EOF.
Author: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/CAM2+6=WcWycVx0j-zw=0jFJxfazFHtZadqZbBedEg2AQkGasfQ@mail.gmail...
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/46d7c16ca14e01211f75b39b4062a916dcb0c6b2
Modified Files
--------------
src/pl/plpgsql/src/expected/plpgsql_misc.out | 9 +++++++++
src/pl/plpgsql/src/pl_gram.y | 5 +++--
src/pl/plpgsql/src/sql/plpgsql_misc.sql | 4 ++++
3 files changed, 16 insertions(+), 2 deletions(-)
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: heikki.linnakangas@iki.fi
Subject: Re: pgsql: Fix PL/pgSQL error message on EOF in the middle of an expression
In-Reply-To: <E1xN6pb-00000001Wbd-0RGj@gemulon.postgresql.org>
References: <E1xN6pb-00000001Wbd-0RGj@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