Re: unique index

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Gus List <guslist(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: unique index
Date: 2006-02-27 21:30:13
Message-ID: 20060227213013.GA57761@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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/interactive/tutorial-transactions.html
http://www.postgresql.org/docs/8.1/interactive/sql-savepoint.html

--
Michael Fuhr

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jesper Krogh 2006-02-28 08:28:16 Generic archive functions.
Previous Message Gus List 2006-02-27 21:11:07 unique index