Problem With A Rule - Mailing list pgsql-sql

From
Subject Problem With A Rule
Date
Msg-id 200204111109.12ab@th00.opsion.fr
Whole thread Raw
Responses Re: Problem With A Rule  (Tom Lane <tgl@sss.pgh.pa.us>)
Inserting values into numeric fields  ("Eric Carpenter" <postgresql@slacker.to>)
List pgsql-sql
Hi!

When the following rule is created:

CREATE RULE rule1 AS ON UPDATE TO table1
DO UPDATE table2 SET column7=130 WHERE
column10=NEW.column10
AND column1=(SELECT column1 FROM table3  WHERE column10=NEW.column10 AND column4='N'AND column5=NEW.column1)
AND column6='2'
AND column8=OLD.column7 AND column9=OLD.column2;

then postgresql seems to be confused by the following
SQL such that psql keeps waiting for postgresql's
result:
update table1 set column6=130 where column2=1;

I have to ctrl-c psql to wake up psql.

However, the following rule works without problem:

CREATE RULE rule1 AS ON UPDATE TO table1
DO UPDATE table2 SET column7=130 WHERE
column10=NEW.column10
AND column1='OneConstant' AND column6='2'
AND column8=OLD.column7 AND column9=OLD.column2;

The following SQL also works fine:

update table2 set column7=130 where column10='1'
and column1=(SELECT column1 FROM table3 WHERE
column10='1' AND column4='N' AND column5='ID1') and column6='2' and column8='r'
and column9=1;

Does rule has problem with subselect or the above
problematic rule has bug?

Regards,

cn

--------------------------------------------------------
You too can have your own email address from Eurosport.
http://www.eurosport.com







pgsql-sql by date:

Previous
From: "Richard Ellerbrock"
Date:
Subject: REPOST: Trouble with SQL conversion
Next
From: "Samuel J. Sutjiono"
Date:
Subject: Transactional vs. Read-only (Retrieval) database