Wed Jul 18 00:55:38 PDT 2007
- Previous message: [Slony1-general] Problems with triggers
- Next message: [Slony1-general] Replication and deferrable constraints
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello. The question is: does Slony correctly support DEFERRABLE foreign keys during the replication? Suppose I have a table with deferrable foreign key constraint referenced to self: tbl(id INTEGER, parent_id INTEGER); The field parent_id references to the table tbl with deferrable constraint: ALTER TABLE tbl ADD CONSTRAINT parent FOREIGN KEY (parent_id) REFERENCES tbl(id) DEFERRABLE INITIALLY DEFERRED; Then I insert a child element in tbl BEFORE inserting a parent one: BEGIN; INSERT INTO tbl(id, parent_id) VALUES(1, 2); -- child first! INSERT INTO tbl(id, parent_id) VALUES(2, null); -- parent COMMIT; It is correct, because the constraint is deferrable and checked at the end of transaction. But I suppose that in the event log this two INSERTs will possibly (?) be presented one after one and in DIFFERENT trtansactions, so, the first one will fail with constraint check error immediately. Please say, could it happen or not? Or, if some statements were initially in a single transaction, slon daemon will run them in a single transaction too on a replica? P.S. Please do not advice to change the order of INSERTs, because in a real application I run these inserts as: INSERT INTO tbl(id, parent_id) SELECT * FROM othertbl; and the order is totally unpredictable. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.slony.info/pipermail/slony1-general/attachments/20070718/= 493ede2a/attachment.htm
- Previous message: [Slony1-general] Problems with triggers
- Next message: [Slony1-general] Replication and deferrable constraints
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-general mailing list