Re: functions, transactions, key violations - Mailing list pgsql-general

From Tom Lane
Subject Re: functions, transactions, key violations
Date
Msg-id 5957.1212615578@sss.pgh.pa.us
Whole thread Raw
In response to functions, transactions, key violations  (Michael Glaesemann <grzm@seespotcode.net>)
Responses Re: functions, transactions, key violations  (Michael Glaesemann <grzm@seespotcode.net>)
List pgsql-general
Michael Glaesemann <grzm@seespotcode.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

pgsql-general by date:

Previous
From: Ralph Smith
Date:
Subject: Script errors on run
Next
From: Michael Glaesemann
Date:
Subject: Re: functions, transactions, key violations