Re: Partial update on an postgres upsert violates constraint - Mailing list pgsql-general

From Tom Lane
Subject Re: Partial update on an postgres upsert violates constraint
Date
Msg-id 29141.1479932382@sss.pgh.pa.us
Whole thread Raw
In response to Re: Partial update on an postgres upsert violates constraint  (Andreas Terrius <gotenwinz99@gmail.com>)
List pgsql-general
Andreas Terrius <gotenwinz99@gmail.com> writes:
> 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.

I'm not really sure why you expect this to be able to work.  The data
you are supplying is insufficient to satisfy the INSERT case, so why do
you think that an insert-or-update should be possible?

ISTM that you could try the UPDATE first and notice whether it updates
any rows or not.  I'm not sure what you're going to do if it doesn't,
though, since you still haven't got enough data to do an INSERT.

            regards, tom lane


pgsql-general by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: Backup "Best Practices"
Next
From: Poul Kristensen
Date:
Subject: Re: Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used