pg_ferroid
pg_ferroid · PostgreSQL ULID type and generation functions backed by ferroid
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100719 | pg_ferroid | pg_ferroid | 3.1.1 | TYPE | MIT | Rust |
PostgreSQL · 15, 16, 17, 18
Usage
Sources:
pg_ferroid 3.1.0 is a pgrx extension that adds a native 16-byte ulid type. ULIDs encode a millisecond timestamp plus an 80-bit tail, have a 26-character Base32 representation, and support comparisons, B-tree and hash indexing, validation, and explicit conversions.
Generate and store ULIDs
gen_ulid() generates a time-ordered value with a random tail. gen_ulid_mono() increments the tail for calls in the same millisecond, but its monotonic state is per backend or thread, not cluster-wide. Do not interpret it as a global sequence.
Ordering and information exposure
Explicit casts connect ulid with text, bytea and timestamptz. Casting a timestamp to ulid sets the random portion to zero, which is useful as a lower range bound but does not generate a normal application identifier.
The embedded timestamp exposes approximate creation time at millisecond precision. Avoid ULIDs where identifier disclosure must not reveal age or ordering. The type uses a native extension representation, so test binary upgrades, logical decoding, dump and restore, drivers, and index rebuilds across PostgreSQL and extension versions. Version 3.0.0 is superuser-only and not trusted according to its control file.
Version 3.0 boundary
Requires PostgreSQL 15–18; PostgreSQL 13/14 support was removed. Direct casts between ulid and timestamp without time zone were removed. Specify the zone and convert through timestamptz:
Timestamp inputs must be finite, at or after the Unix epoch, and fit the 48-bit ULID time range. A backward clock adjustment can delay monotonic generation; cancellation and statement timeouts remain effective. The matching Rust/pgrx build uses pgrx 0.20.0.
Version 3.1.0
Version 3.1.0 updates the underlying ULID generation and random-mask implementation. The SQL type, functions and casts documented above remain the extension interface; generic Rust generator features are not additional SQL objects. PostgreSQL 15–18 and the 3.0 timestamp-cast boundary remain applicable. Deploy matching extension files and check the supplied SQL update path before upgrading an existing database.