lifetime of the old CTID

From: Matthias Apitz <guru(at)unixarea(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: lifetime of the old CTID
Date: 2022-07-05 07:51:19
Message-ID: 20220705075119.GA23@sh4-5.1blu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,

We're using the SQL function currtid2() to get the new CTID of a row
when this was UPDATEd.

Investigating cases of failing updates, it turns out that the old CTID
has only a limited lifetime; one can check this with SQL:

sisis=# select ctid, d01gsi from d01buch where d01gsi = '0240564';
ctid | d01gsi
------------+-----------------------------
(29036,11) | 0240564

now I update the row and afterwards pick up the new CTID based on the
old one (29036,11):

sisis=# UPDATE d01buch set d01ort='Wolfratshausen' where d01gsi='0240564';
UPDATE 1
sisis=# SELECT currtid2('d01buch'::text, '(29036,11)'::tid);
currtid2
-----------
(29036,7)

Now I go and pick up a coffe in our kitchen and check again:

sisis=# SELECT currtid2('d01buch'::text, '(29036,11)'::tid);
currtid2
------------
(29036,11)

i.e. the function now only returns it argument. and not the new CTID
anymore.

Why is this? And what triggers exactly that the old CTID can't be used
anymore?

Thanks

matthias
--
Matthias Apitz, ✉ guru(at)unixarea(dot)de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rajesh S 2022-07-05 08:22:32 - operator overloading not giving expected result
Previous Message Alban Hertroys 2022-07-05 07:01:57 Re: Getting data from a record variable dynamically