Skip site navigation (1) Skip section navigation (2)

Re: probably a bug of data-type serial

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Ralf Miller <rm(at)topnet(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: probably a bug of data-type serial
Date: 2001-10-15 15:45:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On Wed, 10 Oct 2001, Ralf Miller wrote:

> First question:
> The example shows that the column number of type serial is incremented
> as if the preceding insert-statement was successfull, even if it was
> not.
> Are the values for the column number of type serial inserted into the
> corresponding
> sequence before the attempt to insert into the table and are not deleted
> if the
> latter fails ?
> But maybe this behaviour was intended to log succcessless attempts to
> insert into the table.

This is intentional. If the sequence number were to roll back, then a
later transaction trying to get the next sequence number would have
to wait to determine if you've rolled back before getting the number.
Sequences are defined to try to give unique, increasing numbers, not
actually sequential ones.

> Second question:
> The SEQUENCE corresponding to a column of type serial is not beeing
> droped
> automatically when the table containing the serial-column is droped.
> Does it make sense to store a sequence without a corresponding table ?

The serial sequence probably should go away, but there isn't anything
that would stop you from referencing the sequence somewhere else using
nextval or currval.

In response to

pgsql-bugs by date

Next:From: pgsql-bugsDate: 2001-10-15 16:22:23
Subject: Bug #482: psql (7.1.3) doesn't like sysid=0
Previous:From: Bruce MomjianDate: 2001-10-15 15:35:57
Subject: Re: probably a bug of data-type serial

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group