pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: DELETING then INSERTING record with same PK in the same TRANSACTION
Date: Wed, 9 Feb 2022 22:24:14 +0100
Message-ID: <f4b2ad22-3b3c-e87c-a1d0-93643d0aaf3a@gmx.net> (raw)
In-Reply-To: <CAKFQuwYke8ndVd1xS0gHnYJngCY-REx6aL-0HYiVux2+UHYQtQ@mail.gmail.com>
References: <CAKxhU8isUe6NUs7i7dJzdVeHHoK417Sv=z7jUoHZMHbezG_VkA@mail.gmail.com>
	<SY4PR01MB7076851903BD922E73E4988AA12E9@SY4PR01MB7076.ausprd01.prod.outlook.com>
	<CAKFQuwYke8ndVd1xS0gHnYJngCY-REx6aL-0HYiVux2+UHYQtQ@mail.gmail.com>

David G. Johnston schrieb am 09.02.2022 um 21:47:
> You cannot defer uniqueness checks to transaction commit so either it
> is going to fail on the insert or it will not fail at all.

You can defer unique constraints, but not primary key constraints.

create table t
(
   id integer
);

alter table t
    add constraint unique_id
    unique (id)
    deferrable initially deferred;






view thread (11+ messages)  latest in thread

Message-ID: <f4b2ad22-3b3c-e87c-a1d0-93643d0aaf3a@gmx.net>
Permalink:  ../f4b2ad22-3b3c-e87c-a1d0-93643d0aaf3a@gmx.net/
Also on:    postgresql.org/message-id/f4b2ad22-3b3c-e87c-a1d0-93643d0aaf3a@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: shammat@gmx.net
  Subject: Re: DELETING then INSERTING record with same PK in the same TRANSACTION
  In-Reply-To: <f4b2ad22-3b3c-e87c-a1d0-93643d0aaf3a@gmx.net>
  References: <CAKxhU8isUe6NUs7i7dJzdVeHHoK417Sv=z7jUoHZMHbezG_VkA@mail.gmail.com> <SY4PR01MB7076851903BD922E73E4988AA12E9@SY4PR01MB7076.ausprd01.prod.outlook.com> <CAKFQuwYke8ndVd1xS0gHnYJngCY-REx6aL-0HYiVux2+UHYQtQ@mail.gmail.com> <f4b2ad22-3b3c-e87c-a1d0-93643d0aaf3a@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox