X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 071FAD1C942 for ; Wed, 23 Jul 2003 02:08:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 11823-06 for ; Tue, 22 Jul 2003 23:08:08 -0300 (ADT) Received: from fslc.usu.edu (fslc.usu.edu [129.123.41.3]) by svr1.postgresql.org (Postfix) with ESMTP id 2BC11D1C941 for ; Tue, 22 Jul 2003 23:08:49 -0300 (ADT) Received: from paul by fslc.usu.edu with local (Exim 3.36 #1 (Debian)) id 19f93l-0004ZT-00 for ; Tue, 22 Jul 2003 20:08:53 -0600 Date: Tue, 22 Jul 2003 20:08:53 -0600 From: paul cannon To: pgsql-sql@postgresql.org Subject: Re: rule causes nextval() to be invoked twice Message-ID: <20030723020853.GG24912@fslc.usu.edu> References: <20030723014700.GE24912@fslc.usu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030723014700.GE24912@fslc.usu.edu> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/334 X-Sequence-Number: 14448 On Tue, Jul 22, 2003 at 07:47:00PM -0600, paul cannon wrote: > Until then, I'll have to make a function to do nextval('main_id_seq') > with every insert, and have the primary key be INTEGER. Nevermind- that doesn't work either! Here's the new sample code: -- Begin demo SQL CREATE SEQUENCE main_id_seq; CREATE TABLE main ( id INTEGER PRIMARY KEY, contents VARCHAR ); CREATE TABLE othertable ( main_id INTEGER REFERENCES main(id) ); CREATE RULE main_insert AS ON INSERT TO main DO INSERT INTO othertable VALUES (new.id); INSERT INTO main(id, contents) VALUES (nextval('main_id_seq'), 'Fails here'); -- End demo SQL The same thing happens. The rule tries to put 2 into othertable. Surely this is a bug? -- .------------------------------------------------------------. | paul cannon pik@debian.org | | http://people.debian.org/~pik/ |