On 11/21/2016 2:32 AM, Andreas Terrius wrote:
Is there any way to check whether the row already exists before checking constraints ? I still want it to fail if it turns out to be a new row (which would violate the not null constraint), but updates the row if it already exists.
just do an update. if the row doesn't exist, it will fail, you then rollback the transaction or savepoint.
Since if that is not possible, I would need to do a query to determine whether the row exists in the database which kinda eliminates the use of upsert. (in this case, partial upsert).
in general, anything that relies on those sorts of checks will fail under concurrent loads.
-- john r pierce, recycling bits in santa cruz -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general