Re: BUG #15555: Syntax errors when using the COMMENT command in plpgsql and a "comment" variable

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

From: Tom Lane <tgl@sss.pgh.pa.us>
To: feikesteenbergen@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2018-12-17T22:05:58Z
Lists: pgsql-bugs

Attachments

I wrote:
>> I wonder whether we could improve matters by adjusting the heuristic for
>> such things in pl_scanner.c:
>> 
>>         * If we are at start of statement, prefer unreserved keywords
>>         * over variable names, unless the next token is assignment or
>>         * '[', in which case prefer variable names.  (Note we need not
>>         * consider '.' as the next token; that case was handled above,
>>         * and we always prefer variable names in that case.)  If we are
>>         * not at start of statement, always prefer variable names over
>>         * unreserved keywords.

[ pokes at that for a bit ]  The logic here is a bit denser than
one could wish, but here's a draft patch that seems to get the
job done.  It passes check-world, which isn't conclusive but
at least suggests that this doesn't break anything.

I'll add this to the next CF in hopes that somebody will try to
break it.

			regards, tom lane

Commits

  1. Support plpgsql variable names that conflict with unreserved SQL keywords.

  2. De-reserve most statement-introducing keywords in plpgsql.