From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add tid_block() and tid_offset() accessor functions
Date: Sun, 05 Apr 2026 19:29:26 +0000
Message-ID: <E1w9T9x-0037aL-0g@gemulon.postgresql.org> (raw)
Add tid_block() and tid_offset() accessor functions
The two new functions allow to extract the block number and offset from a tid.
There are existing ways to do so (e.g. by doing (ctid::text::point)[0]), but
they are hard to remember and not pretty.
tid_block() returns int8 (bigint) because BlockNumber is uint32, which exceeds
the range of int4. tid_offset() returns int4 (integer) because OffsetNumber is
uint16, which fits safely in int4.
Bumps catversion.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWUzok2+mvSYkbVUwq_SWWg-GdHqCuYumN82AU97SjwjCA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/df6949ccf7a6d5160e3068ed843eb46ab7bc2601
Modified Files
--------------
doc/src/sgml/func/allfiles.sgml | 1 +
doc/src/sgml/func/func-tid.sgml | 70 ++++++++++++++++++++++++++++++++
doc/src/sgml/func/func.sgml | 1 +
src/backend/utils/adt/tid.c | 29 +++++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 6 +++
src/test/regress/expected/opr_sanity.out | 2 +
src/test/regress/expected/tid.out | 66 ++++++++++++++++++++++++++++++
src/test/regress/sql/tid.sql | 21 ++++++++++
9 files changed, 197 insertions(+), 1 deletion(-)
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Add tid_block() and tid_offset() accessor functions
In-Reply-To: <E1w9T9x-0037aL-0g@gemulon.postgresql.org>
* 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