On Fri, Jul 19, 2013 at 1:50 PM, Greg Stark <stark@mit.edu> wrote:
> My only reservation with this patch is whether the WITH_ORDINALITY
> parser hack is the way we want to go. The precedent was already set
> with WITH TIME ZONE though and I think this was the best option.
I share this reservation. Lexer hacks are reasonable ways of getting
LALR(2)-ish behavior in very simple cases, but it doesn't take much to
get into trouble. I think the with ordinality as (select 1) select *
from ordinality example you posted is precisely on point. Currently,
we will have four classes of keywords: unreserved, column-name,
type-function, and reserved. There are rules for when each of those
types of keywords needs to be quoted, and those rules are relatively
well-understood.
This patch will introduce, without documentation, a fifth class of
keyword. ORDINALITY will need to be quoted when, and only when, it
immediately follows WITH. Without some change to our deparsing code,
this is a dump/restore hazard; and with some such change it's still
probably not a good idea.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company