Re: insert bug

From: Andrew Sullivan <andrew(at)libertyrms(dot)info>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: insert bug
Date: 2003-07-15 14:11:50
Message-ID: 20030715141150.GE27367@libertyrms.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)libertyrms(dot)info> M2P 2A8
+1 416 646 3304 x110

In response to

  • insert bug at 2003-07-15 14:01:01 from Scott Cain

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-07-15 14:15:21 Re: Large Objects in serializable transaction question
Previous Message Andrew Sullivan 2003-07-15 14:02:38 Re: more performance questions