Re: inherited table and rules

From: Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au>
To: Scott Frankel <leknarf(at)pacbell(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: inherited table and rules
Date: 2005-03-23 07:04:54
Message-ID: 42411516298.97F7KG@129.180.47.120
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)kgb(dot)une(dot)edu(dot)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 : :
+---------------------------------------+-----------------+

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Klint Gore 2005-03-23 07:34:01 Re: inherited table and rules
Previous Message Sim Zacks 2005-03-23 06:49:31 Re: multi line text data/query ?bug?