Re: Usability or Data Bug in SERIAL column declarations - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Usability or Data Bug in SERIAL column declarations
Date
Msg-id 26562.1098925321@sss.pgh.pa.us
Whole thread Raw
In response to Re: Usability or Data Bug in SERIAL column declarations  (elein <elein@varlena.com>)
List pgsql-bugs
elein <elein@varlena.com> writes:
> But shouldn't it wrap when it hits the max?

No, absolutely not.  The default sequence behavior is NO CYCLE, meaning
you'll start getting errors from nextval() when you reach the max.
I don't see a lot of difference between getting that error and getting
an int8-to-int4 conversion error.

If someone actually wants wrapping in a serial column, they can adjust
the sequence CYCLE parameter with ALTER SEQUENCE, and fix the maxval
to be what they want at the same time.

Memo to whoever feels like hacking on pg_dump: I believe that any such
manual adjustment to a serial sequence's parameters would be lost over a
dump-n-restore, since pg_dump doesn't emit any CREATE SEQUENCE for it.
Maybe we need an ALTER SEQUENCE in there instead.

            regards, tom lane

pgsql-bugs by date:

Previous
From: elein
Date:
Subject: Re: Usability or Data Bug in SERIAL column declarations
Next
From: Kris Jurka
Date:
Subject: Re: PREPARE(d) statements and modifying columns