| From: | Richard Ellis <rellis9(at)yahoo(dot)com> |
|---|---|
| To: | PgSQL General ML <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Replaceing records |
| Date: | 2003-09-04 11:25:22 |
| Message-ID: | 20030904112522.GB28458@i386.dp100.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, Sep 04, 2003 at 12:17:35PM +0200, Csaba Nagy wrote:
> [philosophical post regarding a missing feature of Postgres]
>
> I found there's no way to avoid failed inserts because of
> unique constraint violations, causing automatic roll-back of the running
> transaction.
>
> Now contention on insert has a quite high probability for this operation
> in our application.
Did you ever try this:
insert into test (a, b, c, d)
(select 1, 2, 3, 4 where not exists
(select 1 from test where a=1 and b=2 and c=3 and d=4)
);
If your table contains a=1, b=2, c=3, and d=4, nothing will happen, and
there will be no failed transaction. If your table does not contain a=1,
b=2, c=3, and d=4, you'll get an insert of a row containing 1, 2, 3, 4.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nigel J. Andrews | 2003-09-04 11:28:24 | tsearch2 and unexpected exists |
| Previous Message | Bernd Helmle | 2003-09-04 11:05:35 | Re: syntax error in eRServer.pm line 69 |