Re: [GENERAL] serial increments on failed insert

2005-01-15 Thread David Fetter
On Fri, Jan 14, 2005 at 04:48:12PM -0800, David Kammer wrote: > Ive noticed what seems to be an odd effect in psql 7.3. It works like this: > > 1> Create a table: > CREATE TABLE foo > ( > sval serial, > uval int UNIQUE > ); > > 2> Run 3 inserts, the second of which fails because it fails the

Re: [GENERAL] serial increments on failed insert

2005-01-15 Thread Bruno Wolff III
On Fri, Jan 14, 2005 at 17:49:42 -0800, Steve Atkins <[EMAIL PROTECTED]> wrote: > > That's correct, documented behaviour. A serial column is mostly just a > sequence in disguise. A sequence is guaranteed to give unique, > increasing values, but in many cases may miss a value (for several > reaso

[GENERAL] serial increments on failed insert

2005-01-14 Thread David Kammer
Ive noticed what seems to be an odd effect in psql 7.3. It works like this: 1> Create a table: CREATE TABLE foo ( sval serial, uval int UNIQUE ); 2> Run 3 inserts, the second of which fails because it fails the unique constraint: INSERT INTO foo VALUES (DEFAULT,1); INSERT INTO foo VALUES (D

Re: [GENERAL] serial increments on failed insert

2005-01-14 Thread Michael Fuhr
On Fri, Jan 14, 2005 at 04:57:19PM -0800, David Kammer wrote: > Notice that even though the second insert failed, it still incremented > the serial value. This seems counter intuative to the way that serial > should work. Is this truly a bug, or is there a good work around? See the "Sequence

Re: [GENERAL] serial increments on failed insert

2005-01-14 Thread Steve Atkins
On Fri, Jan 14, 2005 at 04:57:19PM -0800, David Kammer wrote: > Notice that even though the second insert failed, it still incremented > the serial value. This seems counter intuative to the way that serial > should work. Is this truly a bug, or is there a good work around? That's correct, do

Re: [GENERAL] serial increments on failed insert

2005-01-14 Thread Tom Lane
David Kammer <[EMAIL PROTECTED]> writes: > Notice that even though the second insert failed, it still incremented > the serial value. This seems counter intuative to the way that serial > should work. Is this truly a bug, No. nextval() calls never roll back; see the documentation. > is there

[GENERAL] serial increments on failed insert

2005-01-14 Thread David Kammer
I've noticed what seems to be an odd effect in psql 7.3. It works like this: 1> Create a table: CREATE TABLE foo ( sval serial, uval int UNIQUE ); 2> Run 3 inserts, the second of which fails because it fails the unique constraint: INSERT INTO foo VALUES (DEFAULT,1); INSERT INTO foo VALUES (D