Add tid_block() and tid_offset() accessor functions
Andres Freund <andres@anarazel.de>
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
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func/allfiles.sgml | modified | +1 −0 |
| doc/src/sgml/func/func.sgml | modified | +1 −0 |
| doc/src/sgml/func/func-tid.sgml | added | +70 −0 |
| src/backend/utils/adt/tid.c | modified | +29 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.dat | modified | +6 −0 |
| src/test/regress/expected/opr_sanity.out | modified | +2 −0 |
| src/test/regress/expected/tid.out | modified | +66 −0 |
| src/test/regress/sql/tid.sql | modified | +21 −0 |
Discussion
- tid_blockno() and tid_offset() accessor functions 19 messages · 2026-02-27 → 2026-04-05