Should SERIAL column have MAXVAL set on sequence

From: "Woody Woodring" <george(dot)woodring(at)iglass(dot)net>
To: "'pgsql-general General'" <pgsql-general(at)postgresql(dot)org>
Subject: Should SERIAL column have MAXVAL set on sequence
Date: 2007-07-23 16:02:55
Message-ID: 017901c7cd42$ee6090b0$80b1a8c0@istructure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

I have a table in our DB that functions as a queue with a SERIAL column for
its primary key. At 4am this weekend I started getting the error:

ERROR: integer out of range

Which was attributed to the sequence incrementing past the size of the int4
serial column after several years of operation.

I was able to set the sequence back to 1 and everything was happy.

I was wondering if the SERIAL column should set the MAXVAL=2147483647 when
it creates the sequence?

I ended up fixing my queue table with the following to avoid the issue in
the future:

ALTER SEQUENCE transfer_transferid_seq MAXVALUE 2147483647 CYCLE;

Thanks,
Woody

----------------------------------------
iGLASS Networks
211-A S. Salem St
Apex NC 27502
(919) 387-3550 x813
www.iglass.net

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message christof.elmiger 2007-07-23 16:25:40 BUG #3481: wrong link on website?
Previous Message Gregory Stark 2007-07-23 15:34:54 Re: BUG #3479: contraint exclusion and locks

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-07-23 17:44:03 Re: [HACKERS] 8.2.4 signal 11 with large transaction
Previous Message Csaba Nagy 2007-07-23 15:56:58 Delete/update with limit