Re: Bug: Sequence generator insert

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Burr, Colin" <CBurr(at)herald(dot)com>
Cc: "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Bug: Sequence generator insert
Date: 2003-11-28 21:38:28
Message-ID: 20031128213828.GA24904@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Nov 25, 2003 at 18:37:41 -0500,
"Burr, Colin" <CBurr(at)herald(dot)com> wrote:
>
> However, even though the new record failed to be inserted into the table,
> the sequence generator was still updated.
>
> The sequence generator should only be updated if the record is successfully
> inserted into the table, and should not be updated if the insert fails.

That isn't how sequences work. If you need a sequence of numbers without
gaps then you need to use something else. Note that the something else
will need to have a way to let only one transaction at a time update
the counter which may be a performance problem.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-11-28 21:57:18 Re: explicit joins wrong planning
Previous Message Rod Taylor 2003-11-28 21:04:28 Re: rules and return values question