Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords
Date
Msg-id 87bqf2j05c.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
"Gregory Stark" <stark@enterprisedb.com> writes:

> "Tom Lane" <tgl@postgresql.org> writes:
>
>> For the moment, lie about WITH's status in the table so it will still get
>> quoted --- this is because of the expectation that WITH will become reserved
>> when the SQL recursive-queries patch gets done.
>
> Out of curiosity I'm checking what consequences some other future grammer
> changes might have for us.

And checking OLAP window functions it at first glance at least it seems we
would have to make ROWS, WINDOW, RANGE, and PARTITION reserved keywords.

Again, I just sucked in the spec's grammar and fixed it up to fit in our
grammar. I did make PARTITION BY and ORDER BY take arbitrary expressions as is
our general approach.

It's possible there may be clever ways around these conflicts, in particular
it seems like it might be possible to make PARTITION not a keyword given the
nearby BY. However it appears in parentheses which looks like it makes things
a bit tricky.

Here's the relevant grammar snippet, and I attached the diff for gram.y to
parse both window clause and rollup/cube/grouping sets.

window_clause:
    WINDOW window_definition_list
    | /* EMPTY */
    ;

window_definition_list:
    window_definition
    | window_definition ',' window_definition
    ;

window_definition:
    ColId AS window_specification
    ;

window_specification:
    '(' window_specification_details ')'
    ;

window_specification_details:
    opt_window_name
    window_partition_clause
    window_order_clause
    window_frame_clause
    ;

opt_window_name:
    ColId
    | /*EMPTY*/ ;
    ;

window_partition_clause:
    PARTITION BY expr_list
    | /* EMPTY */
    ;

window_order_clause:
    ORDER BY sortby_list
    | /* EMPTY */
    ;

window_frame_clause:
    window_frame_units window_frame_extent opt_window_frame_exclusion
    | /* EMPTY */
    ;

window_frame_units:
    ROWS
    | RANGE
    ;

window_frame_extent:
    window_frame_start
    | window_frame_between
    ;

window_frame_start:
    UNBOUNDED PRECEDING
    | window_frame_preceding
    | CURRENT_P ROW
    ;

window_frame_preceding:
    Iconst PRECEDING
    ;

window_frame_between: BETWEEN window_frame_bound AND window_frame_bound
    ;

window_frame_bound:
    window_frame_start
    | UNBOUNDED FOLLOWING
    | window_frame_following
    ;

window_frame_following:
    Iconst FOLLOWING
    ;

opt_window_frame_exclusion:
    /*EMPTY*/
    | EXCLUDE CURRENT_P ROW
    | EXCLUDE GROUP_P
    | EXCLUDE TIES
    | EXCLUDE NO OTHERS
    ;


--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

Attachment

pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords
Next
From: Chris Mair
Date:
Subject: no cascade triggers?