X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 97DC2536BD for ; Sat, 26 Mar 2005 12:08:25 +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 29949-01 for ; Sat, 26 Mar 2005 12:08:17 +0000 (GMT) Received: from linux.finestmedia.tv (linux.finestmedia.tv [213.180.31.12]) by svr1.postgresql.org (Postfix) with ESMTP id BB73C538F5 for ; Sat, 26 Mar 2005 12:08:15 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by linux.finestmedia.tv (Postfix) with ESMTP id 6D4B118E719 for ; Sat, 26 Mar 2005 14:08:17 +0200 (EET) Received: from linux.finestmedia.tv ([127.0.0.1]) by localhost (linux.finestmedia.tv [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09678-01 for ; Sat, 26 Mar 2005 14:08:15 +0200 (EET) Received: from [192.168.2.27] (rix.fm.sise [192.168.2.27]) by linux.finestmedia.tv (Postfix) with ESMTP id D778E18E718 for ; Sat, 26 Mar 2005 14:08:15 +0200 (EET) Message-ID: <424550AF.1040807@finestmedia.ee> Date: Sat, 26 Mar 2005 14:08:15 +0200 From: Rigmor Ukuhe User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Migrating from 7.2 to 8 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at finestmedia.ee X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.103 tagged_above=0 required=5 tests=AWL, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200503/434 X-Sequence-Number: 16932 Hi, I have problem with migrating our system to PG 8. problem is with rules and triggers. Basically i want to insert row to table 'a1', its primary key has default value nextval('"REO_ID_seq"'::text). I have a rule that must insert row to another table 'a2' using currval('"REO_ID_seq"'::text). And i have trigger that should enforce referential integrity between two tables. CREATE CONSTRAINT TRIGGER "fk_a1_id" AFTER INSERT OR UPDATE ON "a1" FROM "a2" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('fk_a1_id', 'a1', 'a2', 'UNSPECIFIED', 'id', 'id'); CREATE RULE "rule_a1_INSERT" AS ON INSERT TO a1 DO INSERT INTO a2 ("name", "id") VALUES ('REO_HOUSE'::"varchar", int4(currval('"REO_ID_seq"'::text))); These rule and trigger create statements are taken from dump script. (if i load this dump back to 7.2 then everything is working). In PG 7.2 it worked nicely, but in PG8 i must create trigger with DEFERRABLE INITIALLY DEFERRED to get code to work, otherwise it complains about missing key in table a2. Can anybody point out if i am missing something? Now when i got it to work in pg 8 i ask myself, why this code is even working on pg 7.2? -- Rigmor Ukuhe