AFAIR  (Postgres 6.5 - 7.1.3):

cd /usr/src/postgresql-X.X.X/src/interfaces/libpq++/examples
[postgres@xxx examples]$ /usr/local/pgsql/bin/psql
Password:
Welcome to psql, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=# \i testlibpq2.sql
CREATE
CREATE
psql:testlibpq2.sql:5: ERROR:  parser: parse error at or near ""
psql:testlibpq2.sql:5: ERROR:  parser: parse error at or near "]"
postgres=# \q
[postgres@komuna examples]$ cat testlibpq2.sql
CREATE TABLE TBL1 (i int4);

CREATE TABLE TBL2 (i int4);

CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values (new.i);
NOTIFY TBL2];
[postgres@komuna examples]$

What is wrong?




Wed, 28 Nov 2001 15:07:51 +0100
"Albert Bartoszko" <albertb@nt.kegel.com.pl>
Rules
"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

Wed, 28 Nov 2001 16:49:09 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: Rules 
On Wed, 28 Nov 2001, Albert Bartoszko wrote:

> AFAIR  (Postgres 6.5 - 7.1.3):
>
> cd /usr/src/postgresql-X.X.X/src/interfaces/libpq++/examples
> [postgres@xxx examples]$ /usr/local/pgsql/bin/psql
> Password:
> Welcome to psql, the PostgreSQL interactive terminal.
>
> Type:  \copyright for distribution terms
>        \h for help with SQL commands
>        \? for help on internal slash commands
>        \g or terminate with semicolon to execute query
>        \q to quit
>
> postgres=# \i testlibpq2.sql
> CREATE
> CREATE
> psql:testlibpq2.sql:5: ERROR:  parser: parse error at or near ""
> psql:testlibpq2.sql:5: ERROR:  parser: parse error at or near "]"
> postgres=# \q
> [postgres@komuna examples]$ cat testlibpq2.sql
> CREATE TABLE TBL1 (i int4);
>
> CREATE TABLE TBL2 (i int4);
>
> CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values (new.i);
> NOTIFY TBL2];

It works for me with () rather than [], although both are in the help.



Wed, 28 Nov 2001 13:56:18 -0800 (PST)
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Re: Rules
> 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.


Wed, 28 Nov 2001 23:52:14 +0100
=?iso-8859-1?Q?M=E5rten_Gustafsson?= <marten@ditt.as>
Re: [GENERAL] Rules 
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


Thu, 29 Nov 2001 20:04:15 +0100 (CET)
Peter Eisentraut <peter_e@gmx.net>
Re: Rules 
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

Thu, 29 Nov 2001 14:29:02 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: Rules 
> 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

Wed, 5 Dec 2001 17:46:24 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Rules
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


Wed, 5 Dec 2001 17:58:02 -0500 (EST)
Jan Wieck <janwieck@yahoo.com>
Re: Rules