Re: Should we add xid_current() or a int8->xid cast?

Thomas Munro <thomas.munro@gmail.com>

From: Thomas Munro <thomas.munro@gmail.com>
To: Mark Dilger <mark.dilger@enterprisedb.com>
Cc: Andres Freund <andres@anarazel.de>, Alvaro Herrera <alvherre@2ndquadrant.com>, Fujii Masao <masao.fujii@oss.nttdata.com>, Mark Dilger <hornschnorter@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2020-04-07T00:14:32Z
Lists: pgsql-hackers
On Sun, Apr 5, 2020 at 11:31 AM Thomas Munro <thomas.munro@gmail.com> wrote:
> On Sun, Apr 5, 2020 at 10:34 AM Mark Dilger
> <mark.dilger@enterprisedb.com> wrote:
> > The "xid8_" warts are partly motivated by having a type named "xid8", which is a bit of a wart in itself.
>
> Just a thought for the future, not sure if it's a good one: would it
> seem less warty in years to come if we introduced xid4 as an alias for
> xid, and preferred the name xid4?  Then it wouldn't look so much like
> xid is the "real" transaction ID type and xid8 is some kind of freaky
> extended version; instead it would look like xid4 and xid8 are narrow
> and wide transaction IDs, and xid is just a historical name for xid4.

I'll look into proposing that for PG14.  One reason I like that idea
is that system view names like backend_xid could potentially retain
their names while switching to xid8 type, (maybe?) breaking fewer
queries and avoiding ugly names, on the theory that _xid doesn't
specify whether it's xid4 or an xid8.

> > >  pg_current_xact_id()
> > >  pg_current_xact_id_if_assigned()
> > >  pg_xact_status(xid8)

> > >  pg_current_snapshot()
> > >  pg_snapshot_xmin(pg_snapshot)
> > >  pg_snapshot_xmax(pg_snapshot)
> > >  pg_snapshot_xip(pg_snapshot)
> > >  pg_visible_in_snapshot(xid8, pg_snapshot)

> > As such, I'm ±0 for the change.
>
> I'll let this sit for another day and see if some more reactions appear.

Hearing no objections, pushed.  Happy to reconsider these names before
release if someone finds a problem with this scheme.



Commits

  1. Introduce xid8-based functions to replace txid_XXX.

  2. Add SQL type xid8 to expose FullTransactionId to users.

  3. Replace the former method of determining snapshot xmax --- to wit, calling