Re: Usability or Data Bug in SERIAL column declarations

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: elein <elein(at)varlena(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Usability or Data Bug in SERIAL column declarations
Date: 2004-10-28 01:02:01
Message-ID: 26562.1098925321@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

elein <elein(at)varlena(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Scott Eade 2004-10-28 02:20:54 PostgreSQL 8.0 Beta 4 - Qualified ORDER BY column name not working on UNION query
Previous Message elein 2004-10-28 00:54:09 Re: Usability or Data Bug in SERIAL column declarations