Patch for removal of RULE bracket use - Mailing list pgsql-hackers

From Bruce Momjian
Subject Patch for removal of RULE bracket use
Date
Msg-id 200203080409.g2849Pr23299@candle.pha.pa.us
Whole thread Raw
Responses Re: Patch for removal of RULE bracket use
Re: Patch for removal of RULE bracket use
List pgsql-hackers
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 ****
  <replaceable class="parameter">query</replaceable>
  |
  ( <replaceable class="parameter">query</replaceable> ; <replaceable class="parameter">query</replaceable> ... )
- |
- [ <replaceable class="parameter">query</replaceable> ; <replaceable class="parameter">query</replaceable> ... ]
    </synopsis>

    <refsect2 id="R2-SQL-CREATERULE-1">
--- 32,37 ----
***************
*** 177,191 ****
    </para>

    <para>
!    The <replaceable class="parameter">action</replaceable> 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
!    <replaceable class="parameter">action</replaceable> 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.
    </para>

    <para>
--- 175,189 ----
    </para>

    <para>
!    The <replaceable class="parameter">action</replaceable> 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 <replaceable
!    class="parameter">action</replaceable> 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.
    </para>

    <para>
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 ----

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_class -> reltuples?
Next
From: Tom Lane
Date:
Subject: Re: Time for 7.2.1?