Patch for removal of RULE bracket use
Patch for removal of RULE bracket use
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
This patch completes the following TODO item:
* Remove brackets as multi-statement rule grouping, must use parens
One question I have is whether this change is needed:
%left '.'
- %left '[' ']'
%left '(' ')'
I believe the logic for removal of brackets for multi-statement rules is
that brackets are just weird in this usage. :-)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Index: doc/src/sgml/ref/create_rule.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/create_rule.sgml,v
retrieving revision 1.31
diff -c -r1.31 create_rule.sgml
*** doc/src/sgml/ref/create_rule.sgml 24 Jan 2002 18:28:15 -0000 1.31
--- doc/src/sgml/ref/create_rule.sgml 8 Mar 2002 04:00:46 -0000
***************
*** 32,39 ****
query
|
( query ; query ... )
- |
- [ query ; query ... ]
--- 32,37 ----
***************
*** 177,191 ****
! The action part of the rule
! can consist of one or more queries. To write multiple queries, surround
! them with either parentheses or square brackets. Such queries will be
! performed in the specified order (whereas there are no guarantees about
! the execution order of multiple rules for an object). The
! action can also be NOTHING
! indicating no action. Thus, a DO INSTEAD NOTHING rule suppresses the
! original query from executing (when its condition is true); a DO NOTHING
! rule is useless.
--- 175,189 ----
! The action part of the
! rule can consist of one or more queries. To write multiple queries,
! surround them with parentheses. Such queries will be performed in the
! specified order (whereas there are no guarantees about the execution
! order of multiple rules for an object). The action can also be NOTHING indicating
! no action. Thus, a DO INSTEAD NOTHING rule suppresses the original
! query from executing (when its condition is true); a DO NOTHING rule
! is useless.
Index: src/backend/parser/gram.y
===================================================================
RCS file: /cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.287
diff -c -r2.287 gram.y
*** src/backend/parser/gram.y 7 Mar 2002 16:35:35 -0000 2.287
--- src/backend/parser/gram.y 8 Mar 2002 04:01:02 -0000
***************
*** 407,413 ****
%left AT ZONE /* sets precedence for AT TIME ZONE */
%right UMINUS
%left '.'
- %left '[' ']'
%left '(' ')'
%left TYPECAST
%%
--- 407,412 ----
***************
*** 2864,2870 ****
RuleActionList: NOTHING { $$ = NIL; }
| RuleActionStmt { $$ = makeList1($1); }
- | '[' RuleActionMulti ']' { $$ = $2; }
| '(' RuleActionMulti ')' { $$ = $2; }
;
--- 2863,2868 ----
Index: src/interfaces/ecpg/preproc/preproc.y
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/ecpg/preproc/preproc.y,v
retrieving revision 1.180
diff -c -r1.180 preproc.y
*** src/interfaces/ecpg/preproc/preproc.y 6 Mar 2002 10:10:52 -0000 1.180
--- src/interfaces/ecpg/preproc/preproc.y 8 Mar 2002 04:01:29 -0000
***************
*** 273,279 ****
%left AT ZONE
%right UMINUS
%left '.'
- %left '[' ']'
%left '(' ')'
%left TYPECAST
--- 273,278 ----
***************
*** 2153,2159 ****
RuleActionList: NOTHING { $$ = make_str("nothing"); }
| RuleActionStmt { $$ = $1; }
- | '[' RuleActionMulti ']' { $$ = cat_str(3, make_str("["), $2, make_str("]")); }
| '(' RuleActionMulti ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); }
;
--- 2152,2157 ----
Re: Patch for removal of RULE bracket use
От:
Gavin Sherry <swm@linuxworld.com.au>
Дата:
Bruce,
On Thu, 7 Mar 2002, Bruce Momjian wrote:
> This patch completes the following TODO item:
>
> * Remove brackets as multi-statement rule grouping, must use parens
>
> One question I have is whether this change is needed:
>
> %left '.'
> - %left '[' ']'
> %left '(' ')'
It is unncessary to remove this. Square brackets are used elsewhere in the
grammar (arrays, opt_indirection). It is possible that the grammar
requires left to right order of precidence for these.
Gavin
Re: Patch for removal of RULE bracket use
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian writes:
> One question I have is whether this change is needed:
> %left '.'
> - %left '[' ']'
> %left '(' ')'
Only if you want to break array-subscript parsing ;-). Leave it in.
> I believe the logic for removal of brackets for multi-statement rules is
> that brackets are just weird in this usage. :-)
I think the real reason is that psql and other clients aren't smart
about brackets overriding semicolons, and we don't feel like making
them so.
regards, tom lane