Re: probably a bug of data-type serial - Mailing list pgsql-bugs

From Stephan Szabo
Subject Re: probably a bug of data-type serial
Date
Msg-id Pine.BSF.4.21.0110150841360.11740-100000@megazone23.bigpanda.com
Whole thread Raw
In response to probably a bug of data-type serial  (Ralf Miller <rm@topnet.de>)
List 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.

pgsql-bugs by date:

Previous
From: "Lou Picciano"
Date:
Subject: initdb failed: mkdir cannot create directory - No space left on device
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #482: psql (7.1.3) doesn't like sysid=0