Unix Technical Forum

Problems with unique restrictions

This is a discussion on Problems with unique restrictions within the Pgsql General forums, part of the PostgreSQL category; --> Hi all I have a PL/PGSQL conversion procedure that reads a "source table" and then inserts tuples into several ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 01:22 PM
Marcel Gsteiger
 
Posts: n/a
Default Problems with unique restrictions

Hi all

I have a PL/PGSQL conversion procedure that reads a "source table" and then inserts tuples into several related tables. Recently I upgraded from 8.1 to 8.2.0, then to 8.2.1.

With 8.1 everything worked fine.

Now since I upgraded to 8.2 I have problems inserting data into tables that have unique indexes. Ugly enough, I get the message 'duplicate key violates unique constraint' when inserting the very first record into a table. This happens everytime when the new tuple references another tuple that has been inserted just before this one in the same transaction.

Putting a "SET CONSTRAINTS ALL DEFERRED" in my procedure does not help.

To me it looks that something with referential integrity checking goes wrong, but in this case the error message would be misleading.

Is there any known change/problem in this area? If not, I will try to strip down my procedure to something simple that documents my problems.

Regards
--Marcel


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 01:22 PM
Tom Lane
 
Posts: n/a
Default Re: Problems with unique restrictions

"Marcel Gsteiger" <Marcel.Gsteiger@milprog.ch> writes:
> Now since I upgraded to 8.2 I have problems inserting data into tables that have unique indexes. Ugly enough, I get the message 'duplicate key violates unique constraint' when inserting the very first record into a table. This happens everytime when the new tuple references another tuple that has been inserted just before this one in the same transaction.


> Putting a "SET CONSTRAINTS ALL DEFERRED" in my procedure does not help.


> To me it looks that something with referential integrity checking goes wrong, but in this case the error message would be misleading.


RI would not have anything to do with a duplicate-key error.

Do you have any SERIAL-type columns in these tables? My first thought
is of a sequence that hasn't been updated to be above the existing ID
values. It's fairly easy to get into such a state if you do anything
but a plain vanilla dump-all-and-reload-all update process ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:34 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com