pg_uuid_v8
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_uuid_v8 | 1.1.0 | FUNC | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4530 | pg_uuid_v8 | No | Yes | No | Yes | No | No | public |
Upstream 1.1.0 ships on PGXN only; pinned to public so uuid operator commutators resolve on PostgreSQL 17 and 18.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.0 | 1817161514 | pg_uuid_v8 | - |
| RPM | PIGSTY | 1.1.0 | 1817161514 | pg_uuid_v8_$v | openssl |
| DEB | PIGSTY | 1.1.0 | 1817161514 | postgresql-$v-pg-uuid-v8 | `libssl3 |
Build
You can build the RPM / DEB packages for pg_uuid_v8 using pig build:
Install
You can install pg_uuid_v8 directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources:
- pg_uuid_v8 1.1.0 on PGXN
- pg_uuid_v8 1.1.0 README
- pg_uuid_v8 1.1.0 control file
- pg_uuid_v8 1.0 base SQL
- pg_uuid_v8 1.0 to 1.1 upgrade SQL
- Pigsty pg_uuid_v8 package matrix
pg_uuid_v8 1.1.0 generates UUID values with UUID-v4 version and variant bits while embedding an obfuscated creation time in the random payload. Its uuid_v8_* convenience functions mirror the lower-level uuid_stego_* API. Use it when hidden time extraction and time-range indexing are useful, but do not treat the embedded value as an authentication token or a substitute for a separate trusted creation timestamp.
Generate Values
The upstream implementation defaults to a published built-in seed and XOR mode. Set a deployment-specific secret before generating values. AES128 and AES256 are also available, but the same seed and mode must be selected when extracting a value.
Extract and Index the Hidden Time
uuid_v8_extract_timestamp(uuid) returns a microsecond-scaled bigint so it remains compatible with timestamp_to_stego_time() and stego_time_to_timestamp(). In version 1.1 the internal 48-bit field stores milliseconds, so the returned value has millisecond resolution and its last three decimal digits are zero.
uuid_stego_in_range() offers a boolean timestamp-range helper. A functional B-tree index on the extraction function is the explicit and predictable path for indexed time predicates.
Compare Hidden Times
uuid_v8_compare(uuid, uuid) and uuid_stego_compare(uuid, uuid) return ordering by extracted hidden time. The extension also defines <, <=, >, and >= operators for UUID arguments.
Pigsty packages install these added operators in public and qualify their commutator and negator references for PostgreSQL 17 and 18 compatibility. PostgreSQL already has built-in UUID ordering operators, so use the comparison functions or a schema-qualified OPERATOR(public.<) expression when hidden-time semantics must be unambiguous.
Seed and Mode Controls
The seed is exposed as uuid_v8.stego_seed and the mode as uuid_v8.encryption_mode. Setter functions change the current session; configuration settings can establish defaults for later sessions. uuid_v8_get_seed() returns the active seed, so restrict database access accordingly and never log its result.
Upgrade and Compatibility Boundaries
Version 1.1 changes timestamp storage from microseconds to milliseconds. The old 48-bit microsecond field rolled over about every 8.9 years and could not reliably recover current absolute dates; the 48-bit millisecond field lasts about 8,925 years. Relative ordering of pre-1.1 values was unaffected, but absolute time extraction and range predicates for those existing values remain unreliable after the upgrade because their encoded representation is not rewritten.
The PGXN metadata targets PostgreSQL 12 or later; current Pigsty packages cover PostgreSQL 14–18. Pigsty packages pin the extension to public and make it non-relocatable so the added operators resolve consistently. Keep an ordinary created_at column when provenance, auditability, sub-millisecond precision, or migrations across seeds and modes matter.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)