Re: Sanding down some edge cases for PL/pgSQL reserved words

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, Jan Behrens <jbe-mlist@magnetkern.de>
Date: 2025-06-08T21:49:20Z
Lists: pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> Is there some description of what keywords should be reserved? If I
> remember correctly, the scanner was changed more times, and maybe more
> reserved keywords are not necessary.

Per the comment in pl_scanner.c:

 * We try to avoid reserving more keywords than we have to; but there's
 * little point in not reserving a word if it's reserved in the core grammar.
 * Currently, the following words are reserved here but not in the core:
 * BEGIN BY DECLARE EXECUTE FOREACH IF LOOP STRICT WHILE

This patch gets rid of EXECUTE and STRICT, but the others are harder
to de-reserve.  I think most of the rest are there because they can
follow a block or loop label, and the same comment observes

 * (We still have to reserve initial keywords that might follow a block
 * label, unfortunately, since the method used to determine if we are at
 * start of statement doesn't recognize such cases.

			regards, tom lane



Commits

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

  2. De-reserve keywords EXECUTE and STRICT in PL/pgSQL.