Re: insert bug - Mailing list pgsql-general

From Andrew Sullivan
Subject Re: insert bug
Date
Msg-id 20030715141150.GE27367@libertyrms.info
Whole thread Raw
In response to insert bug  (Scott Cain <cain@cshl.org>)
List pgsql-general
On Tue, Jul 15, 2003 at 10:01:01AM -0400, Scott Cain wrote:

>not null default nextval('public.fdata _fid_seq'::text)
                          ^^^^^^^^^^^^^^^^^^^^^

Someone must have inserted some data beyond the range of that
sequence into your primary key.  When you do the nextval() on the
sequence, you get the next value, and it may clash with something
already inserted in fid.  A way to check is to select everything from
the sequence, and select the maximum value from your primary key; if
the latter is higher than the former, that's your problem.

You can use setval() to fix this.

It's probably useful to note that inserting something into a
serial field does not automatically increment the sequence
itself.  Indeed, the datatype "serial" is just a handy shorthand: it
creates the sequence for you, and sets the column to default
nextval() on the sequence.

A

--
----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: plperl language_handler Problems
Next
From: Tom Lane
Date:
Subject: Re: Large Objects in serializable transaction question