Re: serial increments on failed insert - Mailing list pgsql-general

From Tom Lane
Subject Re: serial increments on failed insert
Date
Msg-id 27882.1105753361@sss.pgh.pa.us
Whole thread Raw
In response to serial increments on failed insert  (David Kammer <djkammer@u.washington.edu>)
List pgsql-general
David Kammer <djkammer@u.washington.edu> 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 a good work around?

Don't assume that a serial column is without gaps.  It's only intended
to be unique.

            regards, tom lane

pgsql-general by date:

Previous
From: David Kammer
Date:
Subject: serial increments on failed insert
Next
From: Steve Atkins
Date:
Subject: Re: serial increments on failed insert