pgsql: Add data type oid8, 64-bit unsigned identifier

Started by Michael Paquier7 months ago3 messagescomitters
Jump to latest
#1Michael Paquier
michael@paquier.xyz

Add data type oid8, 64-bit unsigned identifier

This new identifier type provides support for 64-bit unsigned values,
to be used in catalogs, like OIDs. An advantage of a new data type is
that it becomes easier to grep for it in the code when assigning this
type to a catalog attribute, linking it to dedicated APIs and internal
structures.

The following operators are added in this commit, with dedicated tests:
- Casts with integer types and OID.
- btree and hash operators
- min/max functions.
- C type with related macros and defines, named around "Oid8".

This has been mentioned as useful on its own on the thread to add
support for 64-bit TOAST values, so as it becomes possible to attach
this data type to the TOAST code and catalog definitions. However, as
this concept can apply to many more areas, it is implemented as its own
independent change. This is based on a discussion with Andres Freund
and Tom Lane.

Bump catalog version.

Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Greg Burd <greg@burd.me>
Reviewed-by: Nikhil Kumar Veldanda <veldanda.nikhilkumar17@gmail.com>
Discussion: /messages/by-id/1891064.1754681536@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b139bd3b6ef000ab5d00dd47128e366a726da5f9

Modified Files
--------------
doc/src/sgml/datatype.sgml | 16 +-
doc/src/sgml/func/func-aggregate.sgml | 8 +-
src/backend/access/nbtree/nbtcompare.c | 82 +++++++
src/backend/bootstrap/bootstrap.c | 2 +
src/backend/utils/adt/Makefile | 1 +
src/backend/utils/adt/int8.c | 8 +
src/backend/utils/adt/meson.build | 1 +
src/backend/utils/adt/oid8.c | 168 ++++++++++++++
src/fe_utils/print.c | 1 +
src/include/c.h | 10 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_aggregate.dat | 6 +
src/include/catalog/pg_amop.dat | 23 ++
src/include/catalog/pg_amproc.dat | 12 +
src/include/catalog/pg_cast.dat | 14 ++
src/include/catalog/pg_opclass.dat | 4 +
src/include/catalog/pg_operator.dat | 26 +++
src/include/catalog/pg_opfamily.dat | 4 +
src/include/catalog/pg_proc.dat | 64 ++++++
src/include/catalog/pg_type.dat | 5 +
src/include/fmgr.h | 2 +
src/include/postgres.h | 20 ++
src/test/regress/expected/hash_func.out | 10 +
src/test/regress/expected/oid8.out | 368 ++++++++++++++++++++++++++++++
src/test/regress/expected/opr_sanity.out | 7 +
src/test/regress/expected/type_sanity.out | 1 +
src/test/regress/parallel_schedule | 2 +-
src/test/regress/sql/hash_func.sql | 7 +
src/test/regress/sql/oid8.sql | 87 +++++++
src/test/regress/sql/type_sanity.sql | 1 +
30 files changed, 953 insertions(+), 9 deletions(-)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Paquier (#1)
Re: pgsql: Add data type oid8, 64-bit unsigned identifier

Michael Paquier <michael@paquier.xyz> writes:

Add data type oid8, 64-bit unsigned identifier

sifaka doesn't like this, evidently because it uses
-DSTRESS_SORT_INT_MIN.

Personally I'd just drop those tests of btoid8cmp --- what are they
going to catch that's not caught by other tests?

regards, tom lane

#3Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#2)
Re: pgsql: Add data type oid8, 64-bit unsigned identifier

On Tue, Jan 06, 2026 at 10:03:01PM -0500, Tom Lane wrote:

sifaka doesn't like this, evidently because it uses
-DSTRESS_SORT_INT_MIN.

Yes, I have noticed that. I was just going to push a workaround that
uses '>' and '<' comparators instead of the direct outputs..

Personally I'd just drop those tests of btoid8cmp --- what are they
going to catch that's not caught by other tests?

btoid8cmp() is not tested directly by other tests, which is why, like
for the xid8 case, I have just added direct calls because that's
cheaper.
--
Michael