X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F44E3A450A for ; Fri, 12 Nov 2004 03:24:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51147-01 for ; Fri, 12 Nov 2004 03:24:07 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 93C4E3A4249 for ; Fri, 12 Nov 2004 03:24:11 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iAC3O6g5051639 for ; Fri, 12 Nov 2004 03:24:07 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iAC3G1f1049995 for pgsql-sql@postgresql.org; Fri, 12 Nov 2004 03:16:01 GMT From: "Thomas Berg" X-Newsgroups: comp.databases.postgresql.sql Subject: Cascade updates wait until the end of the transaction? Date: Fri, 12 Nov 2004 12:15:21 +0900 Organization: Hub.Org Networking Services Lines: 46 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-2022-jp"; reply-type=original Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=PRIORITY_NO_NAME X-Spam-Level: X-Archive-Number: 200411/137 X-Sequence-Number: 19456 Within a function (and therefore within a transaction), if I UPDATE the primary key of a table, the old value remains visible in the child table through the end of the function. Is this a) by design, and a good thing for some reason I don't understand b) by design, but should be changed c) a bug in 7.4.3 that has been fixed in version XXX d) an unfixed bug e) a heretofore unnoticed bug? f) something else? And has anyone any recommendations how to get around this? The only thing I can think of is to make 2 separate calls from the client, which I would be very sad to do. This demonstrates what I'm talking about. Run each block and check the output before proceeding to the next block (don't run line by line). Thanks for any insight. Berg -- BLOCK 1 CREATE TABLE t1 ( t1_code char(3) NOT NULL PRIMARY KEY ); CREATE TABLE t2 ( t1_code char(3) REFERENCES t1 (t1_code) ON UPDATE CASCADE ON DELETE SET NULL, t2_name varchar ); INSERT INTO t1 (t1_code) VALUES ('ABC'); INSERT INTO t2 (t1_code, t2_name) VALUES ('ABC', 'I refer to ABC'); UPDATE t1 SET t1_code = 'DEF' WHERE t1_code = 'ABC'; UPDATE t2 SET t2_name = 'I refer to ' || t1_code; SELECT * FROM t2; -- shows ABC | I refer to ABC -- BLOCK 2 SELECT * FROM t2; -- shows DEF | I refere to ABC -- BLOCK 3 : clean up DROP TABLE t2; DROP TABLE t1;