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

From Bruce Momjian
Subject Re: probably a bug of data-type serial
Date
Msg-id 200110151535.f9FFZv627397@candle.pha.pa.us
Whole thread Raw
In response to probably a bug of data-type serial  (Ralf Miller <rm@topnet.de>)
List pgsql-bugs
> 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.

For performance reasons, failed INSERT's stull use a sequence number.
That way, multiple users can use the sequence without waiting to see if
the transactions commit.  This is intended.

> 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 ?

For SERIAL, it should drop the sequence but currently doesn't.  As for
using sequences, you can use a sequence for multiple tables so automatic
dropping is probalby not what we want, _except_ for SERIAL.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: ecpg - GRANT bug
Next
From: pgsql-bugs@postgresql.org
Date:
Subject: Bug #500: Cannot create View and Problems With the UNION clause