Is this a bug or a feature? - Mailing list pgsql-general

From Kevin O'Gorman
Subject Is this a bug or a feature?
Date
Msg-id 39EE5DDA.A8234DB4@pacbell.net
Whole thread Raw
Responses Re: Is this a bug or a feature?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I'm trying to understand rules, because I'm about to use them
heavily in some research I'm doing on query optimization.
It seems a natural.

I've notices what looks like an anomaly.  I can define a rule
with two delete commands like this:

> CREATE RULE rule1 AS ON delete TO dummy DO INSTEAD
>    (delete from d2 where id=old.id; delete from d3 where id=old.id);

and it even works.

I can define a rule that does a random SELECT command like so:

>CREATE RULE rule2 AS ON insert TO dummy DO INSTEAD
>    select * from d2;

And this works too, although of course it looks odd.

But I cannot seem to get two selects in the same rule.  When I
try something like this:

> CREATE RULE rule3 AS ON insert TO dummy DO INSTEAD
>     (select * from d2; select * from d3;);

I get a complaint from the parser around the ; (it doesn't say
which ;).  The syntax looks like a direct parallel to the
syntax which worked for deletes, so I was hoping it would
work.

So the question becomes: is this a bug or a feature?
If it's a feature, I'd like it explained.  If it's a
bug, then I'll probably just go fix it.  I really want
to be able to put multiple queries in a rule so that
I can do weird things to them, time the results, and
call it research (thereby maybe earning a PhD).

I'm utterly new to PostgreSQL (did some stuff in
Oracle for my masters), so I'm not going to presume
I can tell at a glance whether this ought to work
or not.  I could use at least a little help.

If there's going to be a problem with doing this sort
of thing, I'd like to know as soon as possible so I
don't just bash my head on walls.

++ kevin


--
Kevin O'Gorman  (805) 650-6274  mailto:kogorman@pacbell.net
Permanent e-mail forwarder:  mailto:Kevin.O'Gorman.64@Alum.Dartmouth.org
At school: mailto:kogorman@cs.ucsb.edu
Web: http://www.cs.ucsb.edu/~kogorman/index.html
Web: http://trixie.kosman.via.ayuda.com/~kevin/index.html

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Any risk in increasing BLCKSZ to get larger tuples?
Next
From: Brian Edginton
Date:
Subject: Re: [HACKERS] pg_connect error