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

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)postgresql(dot)org>
Cc: "PostgreSQL-development Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords
Date: 2007-06-26 13:49:51
Message-ID: 87bqf2j05c.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

"Gregory Stark" <stark(at)enterprisedb(dot)com> writes:

> "Tom Lane" <tgl(at)postgresql(dot)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
;

Attachment Content-Type Size
gram.y.diff text/x-diff 4.6 KB

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Gregory Stark 2007-06-26 14:31:04 Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords
Previous Message Gregory Stark 2007-06-26 12:26:25 Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Mair 2007-06-26 14:04:28 no cascade triggers?
Previous Message Gregory Stark 2007-06-26 12:26:25 Re: [COMMITTERS] pgsql: Arrange for quote_identifier() and pg_dump to not quote keywords