From: | Fran Fabrizio <ffabrizio(at)mmrd(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Adding a rule makes my sequence increment twice |
Date: | 2001-11-27 19:07:49 |
Message-ID: | 3C03E485.83A1664E@mmrd.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I have a table (table1) with a column called 'id' which has a default
value of nextval('id_seq'). I insert into table1, it increments, all is
happy. I add a totally unrelated rule (rule1) to this table, one which
just changes the value of a field in another table (table2) (and table2
is in no way connected to the id_seq), and now when I insert into
table1, the sequence gets incremented twice. I'm wondering if this is a
product of the way that rules rewrite the query or something. Any
insight?
Unfortunately, I cannot duplicate this behavior using simple test
tables, but I am quite sure that table2 in no way alters the value of
id_seq. If for instance the value of the sequence before the insert was
10000, I see something like this:
sequence value = 10000
I insert a row into table 1
At the start of the rule1 execution value of sequence is 10001
At the end of the rule1 execution value of sequence is 10001
insert returns
sequence value = 10002
It's got me baffled after exploring it all morning.
Thanks,
Fran
From | Date | Subject | |
---|---|---|---|
Next Message | Aasmund Midttun Godal | 2001-11-27 19:40:18 | Re: check constriaint for BLOB |
Previous Message | Bruce Momjian | 2001-11-27 18:22:52 | Re: Supporting PostgreSQL infrastructure |