From: | paul cannon <pik(at)debian(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: rule causes nextval() to be invoked twice |
Date: | 2003-07-23 02:08:53 |
Message-ID: | 20030723020853.GG24912@fslc.usu.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)debian(dot)org |
| http://people.debian.org/~pik/ |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-07-23 04:41:55 | Re: rule causes nextval() to be invoked twice |
Previous Message | paul cannon | 2003-07-23 01:47:00 | rule causes nextval() to be invoked twice |