Re: Use pg_current_xact_id() instead of deprecated txid_current()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: "Shinya Kato" <shinya11(dot)kato(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use pg_current_xact_id() instead of deprecated txid_current()
Date: 2026-02-08 16:24:44
Message-ID: 2645118.1770567884@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?UTF-8?Q?=C3=81lvaro_Herrera?= <alvherre(at)kurilemu(dot)de> writes:
> On 2026-02-08, Shinya Kato wrote:
>> Since pg_current_xact_id() returns xid8 which does not support
>> arithmetic operators, places that need "xid + 1" cast the result via
>> ::text::bigint first.

> I think it may be better to add some operators, or was there a rationale for these not being there?

I'm fairly concerned about overloading the arithmetic operators with
unsigned versions. The reason we never invented SQL-level uint8 and
such is fear of getting a lot of "ambiguous operator" errors. Now,
if we are careful not to create implicit casts between xid[8] and
any ordinary type, maybe it'd be okay to invent xid+int, xid8-int,
and a few more.

As things stand, I don't find the proposed patch to be an improvement.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2026-02-08 17:21:43 Re: Add 64-bit XIDs into PostgreSQL 15
Previous Message Henson Choi 2026-02-08 16:05:10 Re: Row pattern recognition