pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karsten Hilbert <Karsten.Hilbert@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: lifetime of the old CTID
Date: Wed, 6 Jul 2022 11:48:08 +0200
Message-ID: <YsVaWIma6SrZNGEo@hermes.hilbert.loc> (raw)
In-Reply-To: <193fd8fb631c7e8078de9d25bffcb1a04f6e1943.camel@cybertec.at>
References: <20220705075119.GA23@sh4-5.1blu.de>
	<03ca00a881de408016a907e31d832175b04aeac7.camel@cybertec.at>
	<20220705102201.GA9@sh4-5.1blu.de>
	<1c03b94b606f493bc6448b8559c4cccf806d3607.camel@cybertec.at>
	<YsReJL8fvHK0D8On@c720-r368166>
	<f363b79595205d42764ad7485aa46ab534f2d318.camel@cybertec.at>
	<YsUfHqpk4Ll1Dej3@c720-r368166>
	<9B418AE6-EA48-4493-B1D1-566708ADC9AC@thebuild.com>
	<YsUpQsTgf2rv1hk+@c720-r368166>
	<193fd8fb631c7e8078de9d25bffcb1a04f6e1943.camel@cybertec.at>

Am Wed, Jul 06, 2022 at 08:41:58AM +0200 schrieb Laurenz Albe:

> Using the primary key is the proper solution.  To be safe from concurrent
> modifications, use a logic like in this pseudo-code:
>
> FOR b IN SELECT pk, other_columns FROM books WHERE condition
>    UPDATE books SET ... WHERE pk = ... AND condition
>
> Checking the condition again on the inner UPDATE will detect concurrent
> data modifications.  If the UPDATE changes nothing, then a book has been
> removed or updated by a concurrent transaction, and you ignore it.

UPDATEing conditional on XMIN not having changed might be
another solution for detecting concurrent transacations if
one is bent on using system columns for that.

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B





view thread (25+ messages)  latest in thread

Message-ID: <YsVaWIma6SrZNGEo@hermes.hilbert.loc>
Permalink:  ../YsVaWIma6SrZNGEo@hermes.hilbert.loc/
Also on:    postgresql.org/message-id/YsVaWIma6SrZNGEo@hermes.hilbert.loc

 · 

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: Karsten.Hilbert@gmx.net
  Subject: Re: lifetime of the old CTID
  In-Reply-To: <YsVaWIma6SrZNGEo@hermes.hilbert.loc>
  References: <20220705075119.GA23@sh4-5.1blu.de> <03ca00a881de408016a907e31d832175b04aeac7.camel@cybertec.at> <20220705102201.GA9@sh4-5.1blu.de> <1c03b94b606f493bc6448b8559c4cccf806d3607.camel@cybertec.at> <YsReJL8fvHK0D8On@c720-r368166> <f363b79595205d42764ad7485aa46ab534f2d318.camel@cybertec.at> <YsUfHqpk4Ll1Dej3@c720-r368166> <9B418AE6-EA48-4493-B1D1-566708ADC9AC@thebuild.com> <YsUpQsTgf2rv1hk+@c720-r368166> <193fd8fb631c7e8078de9d25bffcb1a04f6e1943.camel@cybertec.at> <YsVaWIma6SrZNGEo@hermes.hilbert.loc>

* 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