On 06.12.24 19:45, Jack Bay wrote:
> Unsigned integers are a widely used type and can be important for
> compact and well-aligned data structures, but are not currently
> available in PostgreSQL.
>
> In particular unsigned 64-bit integers and unsigned 32-bit integers
> are desirable as identifiers. They unambiguously correspond to
> specific hexadecimal or other human-readable encoded representations.
> Although signed integers can be used for this purpose, there is the
> potential for human error in confusing a positive value for a negative
> value, corner cases around maximum and minimum values (which are
> statistically certain to be encountered when random bits are used for
> the integer), the potential for human error in interconverting hex and
> other encoded representations, text representation nonuniformity (the
> need for a space for the minus sign), and a variety of associated
> nuisances.
>
> Would it be possible to add support for unsigned 64-bit and unsigned
> 32-bit integers to postgresql?
Here is an extension that implements this: https://github.com/petere/pguint
You can use this for production use and perhaps also as the basis for
experimentation about different behaviors and trade-off that have been
mentioned.