Re: functions, transactions, key violations

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Glaesemann <grzm(at)seespotcode(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: functions, transactions, key violations
Date: 2008-06-04 21:39:38
Message-ID: 5957.1212615578@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael Glaesemann <grzm(at)seespotcode(dot)net> writes:
> We have a function which has been throwing a key violation. We're
> tracking the purchase history for a limited number of unique items,
> and flagging the most recent purchase with purchase_status = 1.

Um, the function is ensuring that there is no conflicting row with
the same item_id, but the unique constraint is on purchase_id.
Plus, since purchase_id is declared PRIMARY KEY, the additional
unique constraint is surely a no-op.

I think you've anonymized the example into nonsense :-(.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2008-06-04 21:56:23 Re: functions, transactions, key violations
Previous Message Michael Glaesemann 2008-06-04 21:27:02 functions, transactions, key violations