Re: functions, transactions, key violations

From: Ioannis Tambouras <ioannis(at)akroninc(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: functions, transactions, key violations
Date: 2008-06-05 13:25:38
Message-ID: 20080605132538.GA6342@akroninc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Apart from concurrency issues, it is possible that you
have sequence generation problems. Depending on how
you inserted the original rows into the 'purchases' table, it is possible
that the nextval number has not kept-up and is lagging behind.

You need to ensure that 'purchases_purchase_id_seq' is pointing
to the correct next value! That is, if it is current nextval
is number 100, but you already have 110 rows on the table (without gaps),
it is no wonder you will receive primary key violations for the
next 10 inserts but will work fine afterwards. ( Assuming, of course,
you are the only one receiving values from the sequence.)

Thanks
Ioannis Tambouras

Browse pgsql-general by date

  From Date Subject
Next Message Tino Wildenhain 2008-06-05 13:28:55 Re: How can I compare sql create script with running database?
Previous Message Richard Broersma 2008-06-05 13:10:43 Re: Tripping up on my first attempt at building PG from source