pgsql: Add tid_block() and tid_offset() accessor functions - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Add tid_block() and tid_offset() accessor functions
Date
Msg-id E1w9T9x-0037aL-0g@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: pgsql: Check that the tranche name is unique in RequestNamedLWLockTranc
Next
From: Andres Freund
Date:
Subject: pgsql: Fixups for a4f774cf1c7