David Fetter david
Fri Jul 23 20:47:58 PDT 2004
On Thu, Jul 22, 2004 at 06:15:55PM -0400, Dan Wright wrote:

> It sounds like you are doing the kind of thing that table
> inheritance is supposed to solve.  If you use inheritance in your DB
> tables, you could get exactly what you are asking for from slony
> right now.

Table inheritance is a Bad Thing(TM) in its current implementation.
Please find attached an example of why this is so.

Cheers,
D
-- 
David Fetter david at fetter.org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!
-------------- next part --------------
BEGIN;
CREATE TABLE foo (
  foo_id SERIAL PRIMARY KEY
);

CREATE TABLE parent (
  parent_id SERIAL PRIMARY KEY
, foo_id INTEGER NOT NULL REFERENCES foo(foo_id) ON DELETE CASCADE
, parent_1_text TEXT NOT NULL
);

CREATE TABLE child_1 (
  child_1_text TEXT NOT NULL
) INHERITS(parent);

CREATE TABLE child_2 (
  child_2_text TEXT NOT NULL
) INHERITS(parent);

INSERT INTO foo VALUES(DEFAULT);
INSERT INTO child_1 (foo_id, parent_1_text, child_1_text)
VALUES (currval('public.foo_foo_id_seq'), 'parent text 1', 'child_1 text 1');

INSERT INTO foo VALUES(DEFAULT);
INSERT INTO child_1 (foo_id, parent_1_text, child_1_text)
VALUES (currval('public.foo_foo_id_seq'), 'parent text 2', 'child_1 text 2');

INSERT INTO foo VALUES(DEFAULT);
INSERT INTO child_2 (foo_id, parent_1_text, child_2_text)
VALUES (currval('foo_foo_id_seq'), 'parent text 3', 'child_2 text 1');

DELETE FROM foo WHERE foo_id = 1;
SELECT * FROM parent;
SELECT * FROM child_1;
ROLLBACK;


More information about the Slony1-general mailing list