Re: inherited table and rules - Mailing list pgsql-general

From Klint Gore
Subject Re: inherited table and rules
Date
Msg-id 42411516298.97F7KG@129.180.47.120
Whole thread Raw
In response to inherited table and rules  (Scott Frankel <leknarf@pacbell.net>)
Responses Re: inherited table and rules
List pgsql-general
I thought that all rows in inherited tables are visible to the table
that they are inherited from (ie all rows in people_history are visible
to people).

step by step would be
> INSERT INTO people (usr_name, color) VALUES ('bob',   'red');

make one row in people

> -- update table (1) -- 2
> UPDATE people SET color = 'cyan' WHERE usr_pkey = 1;

rule fires inserting new row into people_history making 2 rows visible
in people.
not instead rule so update happens causing 2 rows updated.

> -- update table (2) -- 6
> UPDATE people SET color = 'magenta' WHERE usr_pkey = 1;

rule fires for each row updated making 2 new rows per original visible row
(ends up with 6 rows)
not instead rule so update happens causing 6 rows updated.

> -- update table (3) -- 42
> UPDATE people SET color = 'yellow' WHERE usr_pkey = 1;
6inserts * 6 updates + original 6 = 42

> -- update table (4) -- 1806
> UPDATE people SET color = 'black' WHERE usr_pkey = 1;
42*42+42 = 1806

klint.

+---------------------------------------+-----------------+
: Klint Gore                            : "Non rhyming    :
: EMail   : kg@kgb.une.edu.au           :  slang - the    :
: Snail   : A.B.R.I.                    :  possibilities  :
: Mail      University of New England   :  are useless"   :
:           Armidale NSW 2351 Australia :     L.J.J.      :
: Fax     : +61 2 6772 5376             :                 :
+---------------------------------------+-----------------+

pgsql-general by date:

Previous
From: "Sim Zacks"
Date:
Subject: Re: multi line text data/query ?bug?
Next
From: Klint Gore
Date:
Subject: Re: inherited table and rules