Unix Technical Forum

unique index

This is a discussion on unique index within the pgsql Novice forums, part of the PostgreSQL category; --> Greetings, I have a very strange problem that I realy dont now if it should work this way or ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 10:38 PM
Gus List
 
Posts: n/a
Default unique index

Greetings,

I have a very strange problem that I realy dont now if it should work this
way or if it is a bug or a enviroment problem.

I'm running postgres 8.1.0 on a 'White Box Enterprise release 4' Linux box.

I've created a unique constraint for multiple fields (3) with a condition.
Those fields are: bigint, varchar and varchar and the condition is status =
1 (status is a integer field) .
The condition works fine. It only lets me insert onde possible combination
and if the status condition complies.

The problem is that when I try to insert an duplicate entry for testing I
receive te error (ERROR: duplicate key violates unique constraint
"new_idx_UNIQ") but ALL RECORDS are DELETED. I don't think that this should
happen.

Can any one give me some help on that ?

Regards,
Gus

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 10:38 PM
Michael Fuhr
 
Posts: n/a
Default Re: unique index

On Mon, Feb 27, 2006 at 06:11:07PM -0300, Gus List wrote:
> The problem is that when I try to insert an duplicate entry for testing I
> receive te error (ERROR: duplicate key violates unique constraint
> "new_idx_UNIQ") but ALL RECORDS are DELETED. I don't think that this should
> happen.


Are you in a transaction? If so then the error is causing the
transaction to fail, which causes all of the transaction's work to
be rolled back (discarded). That's how transactions work: either
everything succeeds or nothing does. However, it's possible to
continue a transaction after an error if you use savepoints.

http://www.postgresql.org/docs/8.1/i...nsactions.html
http://www.postgresql.org/docs/8.1/i...savepoint.html

--
Michael Fuhr

---------------------------(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 04:22 PM.


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