Re: [PATCH] Add pg_current_vxact_id() function to expose virtual transaction IDs - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: [PATCH] Add pg_current_vxact_id() function to expose virtual transaction IDs
Date
Msg-id aWBK3fVZk4cgPPJq@paquier.xyz
Whole thread Raw
In response to [PATCH] Add pg_current_vxact_id() function to expose virtual transaction IDs  ("Pavlo Golub" <pavlo.golub@cybertec.at>)
Responses Re: [PATCH] Add pg_current_vxact_id() function to expose virtual transaction IDs
List pgsql-hackers
On Mon, Dec 08, 2025 at 12:09:58PM +0000, Pavlo Golub wrote:
> Virtual transaction IDs are fundamental to PostgreSQL's transaction
> tracking,
> appearing in pg_locks.virtualtransaction, log output via %v placeholder, and
> internal transaction management. However, there's currently no direct SQL
> function to retrieve the current VXID, forcing applications to query
> pg_locks
> or parse log files to obtain this information.

This is replacing one SQL in a given session by another, as a session
currently running a transaction can query itself pg_locks and match an
entry with its own pg_backend_pid().  Hence I don't see the need for
this function, except simplicity in retrieving a session's state with
less characters typed at the end?

Thoughts and opinions from others are welcome.  I'm always OK to be
outvoted.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Henson Choi
Date:
Subject: Re: Re[2]: [PATCH] Add pg_current_vxact_id() function to expose virtual transaction IDs
Next
From: Andres Freund
Date:
Subject: Re: Buffer locking is special (hints, checksums, AIO writes)