Skip to content

uint128

Native uint128 type

pg_uint128 : Native uint128 type

Overview

ID Extension Package Version Category License Language
3760 uint128 pg_uint128 1.3.0 TYPE PostgreSQL C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r No Yes No Yes yes no
Relationships
See Also uint pgmp numeral unit pg_rational seg cube
breaks on el8 since 1.1 ,fix el8 build problem by adding __has_builtin marco

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 1.3.0 19 18 17 16 15 pg_uint128 -
RPM PIGSTY 1.3.0 19 18 17 16 15 pg_uint128_$v -
DEB PIGSTY 1.3.0 19 18 17 16 15 postgresql-$v-pg-uint128 -
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el8.aarch64 N/A PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el9.x86_64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el9.aarch64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el10.x86_64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
el10.aarch64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
d12.x86_64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
d12.aarch64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
d13.x86_64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
d13.aarch64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u22.x86_64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u22.aarch64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u24.x86_64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u24.aarch64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u26.x86_64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
u26.aarch64 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0 PIGSTY 1.3.0
Package Version OS ORG SIZE File URL
pg_uint128_19 1.3.0 el9.x86_64 pigsty 387.4 KiB pg_uint128_19-1.3.0-1PGSTY.el9.x86_64.rpm
pg_uint128_19 1.3.0 el9.aarch64 pigsty 379.6 KiB pg_uint128_19-1.3.0-1PGSTY.el9.aarch64.rpm
pg_uint128_19 1.3.0 el10.x86_64 pigsty 389.5 KiB pg_uint128_19-1.3.0-1PGSTY.el10.x86_64.rpm
pg_uint128_19 1.3.0 el10.aarch64 pigsty 382.5 KiB pg_uint128_19-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-uint128 1.3.0 d12.x86_64 pigsty 330.8 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-uint128 1.3.0 d12.aarch64 pigsty 320.9 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-uint128 1.3.0 d13.x86_64 pigsty 329.7 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-uint128 1.3.0 d13.aarch64 pigsty 323.2 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-uint128 1.3.0 u22.x86_64 pigsty 368.3 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-uint128 1.3.0 u22.aarch64 pigsty 360.0 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-uint128 1.3.0 u24.x86_64 pigsty 358.0 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-uint128 1.3.0 u24.aarch64 pigsty 355.1 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-uint128 1.3.0 u26.x86_64 pigsty 359.8 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-uint128 1.3.0 u26.aarch64 pigsty 353.0 KiB postgresql-19-pg-uint128_1.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_uint128_18 1.3.0 el8.x86_64 pigsty 386.0 KiB pg_uint128_18-1.3.0-1PGSTY.el8.x86_64.rpm
pg_uint128_18 1.3.0 el8.aarch64 pigsty 372.4 KiB pg_uint128_18-1.3.0-1PGSTY.el8.aarch64.rpm
pg_uint128_18 1.3.0 el9.x86_64 pigsty 387.7 KiB pg_uint128_18-1.3.0-1PGSTY.el9.x86_64.rpm
pg_uint128_18 1.3.0 el9.aarch64 pigsty 379.7 KiB pg_uint128_18-1.3.0-1PGSTY.el9.aarch64.rpm
pg_uint128_18 1.3.0 el10.x86_64 pigsty 389.8 KiB pg_uint128_18-1.3.0-1PGSTY.el10.x86_64.rpm
pg_uint128_18 1.3.0 el10.aarch64 pigsty 382.8 KiB pg_uint128_18-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-uint128 1.3.0 d12.x86_64 pigsty 331.8 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-uint128 1.3.0 d12.aarch64 pigsty 320.6 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-uint128 1.3.0 d13.x86_64 pigsty 330.3 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-uint128 1.3.0 d13.aarch64 pigsty 323.0 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-uint128 1.3.0 u22.x86_64 pigsty 368.3 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-uint128 1.3.0 u22.aarch64 pigsty 360.0 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-uint128 1.3.0 u24.x86_64 pigsty 357.9 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-uint128 1.3.0 u24.aarch64 pigsty 355.1 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-uint128 1.3.0 u26.x86_64 pigsty 359.8 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-uint128 1.3.0 u26.aarch64 pigsty 353.0 KiB postgresql-18-pg-uint128_1.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_uint128_17 1.3.0 el8.x86_64 pigsty 385.9 KiB pg_uint128_17-1.3.0-1PGSTY.el8.x86_64.rpm
pg_uint128_17 1.3.0 el8.aarch64 pigsty 372.2 KiB pg_uint128_17-1.3.0-1PGSTY.el8.aarch64.rpm
pg_uint128_17 1.3.0 el9.x86_64 pigsty 387.3 KiB pg_uint128_17-1.3.0-1PGSTY.el9.x86_64.rpm
pg_uint128_17 1.3.0 el9.aarch64 pigsty 379.4 KiB pg_uint128_17-1.3.0-1PGSTY.el9.aarch64.rpm
pg_uint128_17 1.3.0 el10.x86_64 pigsty 389.7 KiB pg_uint128_17-1.3.0-1PGSTY.el10.x86_64.rpm
pg_uint128_17 1.3.0 el10.aarch64 pigsty 382.5 KiB pg_uint128_17-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-uint128 1.3.0 d12.x86_64 pigsty 331.8 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-uint128 1.3.0 d12.aarch64 pigsty 320.3 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-uint128 1.3.0 d13.x86_64 pigsty 329.4 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-uint128 1.3.0 d13.aarch64 pigsty 322.4 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-uint128 1.3.0 u22.x86_64 pigsty 385.4 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-uint128 1.3.0 u22.aarch64 pigsty 375.8 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-uint128 1.3.0 u24.x86_64 pigsty 358.1 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-uint128 1.3.0 u24.aarch64 pigsty 355.0 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-uint128 1.3.0 u26.x86_64 pigsty 359.7 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-uint128 1.3.0 u26.aarch64 pigsty 352.9 KiB postgresql-17-pg-uint128_1.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_uint128_16 1.3.0 el8.x86_64 pigsty 385.6 KiB pg_uint128_16-1.3.0-1PGSTY.el8.x86_64.rpm
pg_uint128_16 1.3.0 el8.aarch64 pigsty 372.1 KiB pg_uint128_16-1.3.0-1PGSTY.el8.aarch64.rpm
pg_uint128_16 1.3.0 el9.x86_64 pigsty 387.3 KiB pg_uint128_16-1.3.0-1PGSTY.el9.x86_64.rpm
pg_uint128_16 1.3.0 el9.aarch64 pigsty 379.5 KiB pg_uint128_16-1.3.0-1PGSTY.el9.aarch64.rpm
pg_uint128_16 1.3.0 el10.x86_64 pigsty 389.9 KiB pg_uint128_16-1.3.0-1PGSTY.el10.x86_64.rpm
pg_uint128_16 1.3.0 el10.aarch64 pigsty 382.3 KiB pg_uint128_16-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-uint128 1.3.0 d12.x86_64 pigsty 331.7 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-uint128 1.3.0 d12.aarch64 pigsty 320.9 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-uint128 1.3.0 d13.x86_64 pigsty 329.5 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-uint128 1.3.0 d13.aarch64 pigsty 322.8 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-uint128 1.3.0 u22.x86_64 pigsty 383.5 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-uint128 1.3.0 u22.aarch64 pigsty 374.1 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-uint128 1.3.0 u24.x86_64 pigsty 357.6 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-uint128 1.3.0 u24.aarch64 pigsty 354.4 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-uint128 1.3.0 u26.x86_64 pigsty 358.8 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-uint128 1.3.0 u26.aarch64 pigsty 352.2 KiB postgresql-16-pg-uint128_1.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_uint128_15 1.3.0 el8.x86_64 pigsty 387.8 KiB pg_uint128_15-1.3.0-1PGSTY.el8.x86_64.rpm
pg_uint128_15 1.3.0 el8.aarch64 pigsty 373.6 KiB pg_uint128_15-1.3.0-1PGSTY.el8.aarch64.rpm
pg_uint128_15 1.3.0 el9.x86_64 pigsty 388.3 KiB pg_uint128_15-1.3.0-1PGSTY.el9.x86_64.rpm
pg_uint128_15 1.3.0 el9.aarch64 pigsty 381.4 KiB pg_uint128_15-1.3.0-1PGSTY.el9.aarch64.rpm
pg_uint128_15 1.3.0 el10.x86_64 pigsty 391.1 KiB pg_uint128_15-1.3.0-1PGSTY.el10.x86_64.rpm
pg_uint128_15 1.3.0 el10.aarch64 pigsty 384.2 KiB pg_uint128_15-1.3.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-uint128 1.3.0 d12.x86_64 pigsty 335.4 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-uint128 1.3.0 d12.aarch64 pigsty 324.4 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-uint128 1.3.0 d13.x86_64 pigsty 333.8 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-uint128 1.3.0 d13.aarch64 pigsty 326.2 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-uint128 1.3.0 u22.x86_64 pigsty 386.0 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-uint128 1.3.0 u22.aarch64 pigsty 377.1 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-uint128 1.3.0 u24.x86_64 pigsty 361.0 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-uint128 1.3.0 u24.aarch64 pigsty 358.4 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-uint128 1.3.0 u26.x86_64 pigsty 360.9 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-uint128 1.3.0 u26.aarch64 pigsty 354.0 KiB postgresql-15-pg-uint128_1.3.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_uint128;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_uint128;		# install via package name, for the active PG version
pig install uint128;		# install by extension name, for the current active PG version

pig install uint128 -v 19;   # install for PG 19
pig install uint128 -v 18;   # install for PG 18
pig install uint128 -v 17;   # install for PG 17
pig install uint128 -v 16;   # install for PG 16
pig install uint128 -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION uint128;

Usage

Sources:

uint128 adds unsigned integers and signed 8-bit and 128-bit integer types. Version 1.3.0 supports PostgreSQL 12–18 and fixes operator metadata that could make indexed comparisons return incorrect results.

Store and Query Integers

Installation requires a superuser; the control file does not mark the extension trusted. It is relocatable and requires no preload.

CREATE EXTENSION uint128;
CREATE TABLE ids (id uint16 PRIMARY KEY);
INSERT INTO ids VALUES ('340282366920938463463374607431768211455'::uint16);
SELECT * FROM ids WHERE id > '18446744073709551615'::uint16;
SELECT * FROM generate_series(1::uint4, 3::uint4);

The unsigned types uint1, uint2, uint4, uint8 and uint16 occupy 1, 2, 4, 8 and 16 bytes. Their range is zero through 2 raised to the bit width minus one. int1 and int16 are signed 1-byte and 16-byte types.

Operators and Indexes

The types provide arithmetic, comparisons, bitwise operations, B-tree and hash indexes, binary I/O, casts and generate_series. Corresponding range types, including uint1range and uint16range, support GiST indexes; multiranges depend on server support. SUM and AVG use numeric internally; MIN and MAX are also available.

Mixed signed/unsigned arithmetic is sensitive to operand order and result type. Cast explicitly when a negative result is possible: an unsigned result cannot represent it. Conversions and arithmetic may raise range errors; do not assume wraparound.

Upgrade to 1.3.0

Install the matching files, then run as a superuser:

ALTER EXTENSION uint128 UPDATE TO '1.3.0';

This corrects comparison commutators and removes invalid mixed-type addition/subtraction commutators. It also fixes installation with the stricter operator checks in PostgreSQL 17.12. The supplied SQL updates operator metadata in place while preserving data, indexes, views and materialized views. Check the installed version and representative indexed comparisons after upgrading.

Table reader