Re: BUG #5202: Rule affecting more than one row is only fired once with LIMIT 1 - Mailing list pgsql-bugs

From Robert Haas
Subject Re: BUG #5202: Rule affecting more than one row is only fired once with LIMIT 1
Date
Msg-id 603c8f070911222035l60754072lf311a19b816c208c@mail.gmail.com
Whole thread Raw
In response to BUG #5202: Rule affecting more than one row is only fired once with LIMIT 1  ("Marcel Wieland" <marcel.wieland@fondsnet.de>)
List pgsql-bugs
On Fri, Nov 20, 2009 at 9:58 AM, Marcel Wieland
<marcel.wieland@fondsnet.de> wrote:
>
> The following bug has been logged online:
>
> Bug reference: =A0 =A0 =A05202
> Logged by: =A0 =A0 =A0 =A0 =A0Marcel Wieland
> Email address: =A0 =A0 =A0marcel.wieland@fondsnet.de
> PostgreSQL version: 8.2
> Operating system: =A0 Linux
> Description: =A0 =A0 =A0 =A0Rule affecting more than one row is only fire=
d once with
> LIMIT 1
> Details:
>
> BEGIN;
>
> -- Create testing Tables
> CREATE TABLE footable (
> =A0 =A0name char
> );
> CREATE TABLE bartable (
> =A0 =A0foo char
> );
>
> -- Insert testing Values
> INSERT INTO footable (name) VALUES('a'), ('b');
>
> -- RULE with LIMIT 1
> CREATE OR REPLACE RULE foorule AS ON UPDATE TO footable DO
> =A0 =A0INSERT INTO bartable (foo) SELECT name FROM footable WHERE name =
=3D
> old.name LIMIT 1;
>
> -- Query fires Rule
> UPDATE footable SET name =3D name;
> -- Result
> SELECT * FROM bartable;
>
> -- Reset
> DELETE FROM bartable;
>
> -- RULE without LIMIT 1
> CREATE OR REPLACE RULE foorule AS ON UPDATE TO footable DO
> =A0 =A0INSERT INTO bartable (foo) SELECT name FROM footable WHERE name =
=3D
> old.name;
>
> -- Query fires Rule
> UPDATE footable SET name =3D name;
> -- Result
> SELECT * FROM bartable;
>
> -- Cleanup
> DROP TABLE footable;
> DROP TABLE bartable;
>
> ROLLBACK;

See my response to your other bug report - same issues apply here.

...Robert

pgsql-bugs by date:

Previous
From: Robert Haas
Date:
Subject: Re: BUG #5203: Rule affecting more than one row is only fired once, when there is no reference to the row.
Next
From: Robert Haas
Date:
Subject: Re: BUG #5205: Cannot ADD CONSTRAINT ... FOREIGN KEY...