postgres_web3
postgres_web3 · Optimized PostgreSQL types and operators for 128/256-bit signed and unsigned integers plus 160/256-bit hexadecimal web3 values.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101130 | postgres_web3 | postgres_web3 | 1.0 | TYPE | MIT | C |
PostgreSQL · 15
Usage
Sources:
postgres_web3 1.0 supplies fixed-width int128, uint128, int256, uint256, hex160, and hex256 types for blockchain-sized integers, addresses, and hashes. It defines arithmetic, comparison and bitwise operators, casts, B-tree and hash operator classes, and numeric aggregates.
Model Web3 values
Integer input uses base-10 text. Hex input is case-insensitive, contains no 0x prefix, and is emitted as lowercase text. Arithmetic is range checked, so operations that do not fit the destination type raise an error.
Build and precision constraints
The reviewed README requires C23 _BitInt, Clang 16, and a specially built PostgreSQL without LLVM support, and recommends its prebuilt Linux container instead of a source build. These constraints are historical and narrow; verify compiler, architecture, PostgreSQL ABI, backup, restore, replication, and client-driver behavior before storing durable production values.
The avg aggregates use a double-precision internal sum and the upstream documentation warns that results are inaccurate for large sums. Use an exact alternative when averages affect balances or accounting. Casts marked for assignment can still fail on negative or out-of-range values, and fixed-width hex output is not an Ethereum checksum-address implementation.