Thread: Re: [GENERAL] Rules

Re: [GENERAL] Rules

From
Tom Lane
Date:
"Albert Bartoszko" <albertb@nt.kegel.com.pl> writes:
> [ src/interfaces/libpq++/examples/testlibpq2.sql fails ]
> What is wrong?

As best I can tell, psql is falling down on the job: it's not treating
square brackets as something to be matched up, as it does with
parentheses.  It ships this command to the backend as two separate
queries.  Trying it with psql -e shows what's happening:

regression=# CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values (new.i); NOTIFY TBL2];
CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values (new.i);
ERROR:  parser: parse error at or near ""
 NOTIFY TBL2];
ERROR:  parser: parse error at or near "]"
regression=#

While this clearly ought to be fixed, I think it's a bit late in the
cycle to consider fixing it for 7.2, especially seeing as how no
functionality is lost (multi-rule actions work fine if you put
parentheses rather than square brackets around them).

For 7.3, we should either fix psql or remove the option to use square
brackets in rule action lists.  Comments anyone?

            regards, tom lane

Re: [GENERAL] Rules

From
Mårten Gustafsson
Date:
> For 7.3, we should either fix psql or remove the option to use square
> brackets in rule action lists.  Comments anyone?

Do we really need square brackets?



Just my 2c,
Marten.



Re: [GENERAL] Rules

From
Peter Eisentraut
Date:
Tom Lane writes:

> For 7.3, we should either fix psql or remove the option to use square
> brackets in rule action lists.  Comments anyone?

I'd certainly be for removing this since no one could ever really have
used this, but this feature seems so unusual, perhaps there was a reason
for it?

--
Peter Eisentraut   peter_e@gmx.net


Re: [GENERAL] Rules

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane writes:
>> For 7.3, we should either fix psql or remove the option to use square
>> brackets in rule action lists.  Comments anyone?

> I'd certainly be for removing this since no one could ever really have
> used this, but this feature seems so unusual, perhaps there was a reason
> for it?

My guess is that the syntax predates psql, or at least predates psql's
current ideas about splitting up queries.  It's possible that someone
out there is entering square-bracket-delimited rule lists via a non-psql
interface, but I doubt it.  I'd vote for elimination of the syntax,
I think.

            regards, tom lane

Re: [GENERAL] Rules

From
Bruce Momjian
Date:
> Tom Lane writes:
>
> > For 7.3, we should either fix psql or remove the option to use square
> > brackets in rule action lists.  Comments anyone?
>
> I'd certainly be for removing this since no one could ever really have
> used this, but this feature seems so unusual, perhaps there was a reason
> for it?

Added to TODO:

    * Remove brackets as multi-statement rule grouping, must use parens

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

Re: [GENERAL] Rules

From
Jan Wieck
Date:
Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > Tom Lane writes:
> >> For 7.3, we should either fix psql or remove the option to use square
> >> brackets in rule action lists.  Comments anyone?
>
> > I'd certainly be for removing this since no one could ever really have
> > used this, but this feature seems so unusual, perhaps there was a reason
> > for it?
>
> My guess is that the syntax predates psql, or at least predates psql's
> current ideas about splitting up queries.  It's possible that someone
> out there is entering square-bracket-delimited rule lists via a non-psql
> interface, but I doubt it.  I'd vote for elimination of the syntax,
> I think.

    You're right. The [] syntax was used in Postgres 4.2 and well
    supported by monitor(1).

    Adding the parens as alternative was - uhm - a workaround for
    not  beeing  able to get square brackets through psql at some
    point, but I'm not sure if that was in 6.4 or 6.5.

    Anyway, let's rip out the square brackets.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com