Re: serial increments on failed insert

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Kammer <djkammer(at)u(dot)washington(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: serial increments on failed insert
Date: 2005-01-15 01:42:41
Message-ID: 27882.1105753361@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Kammer <djkammer(at)u(dot)washington(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2005-01-15 01:49:42 Re: serial increments on failed insert
Previous Message David Kammer 2005-01-15 00:57:19 serial increments on failed insert