Skip to content

uuid_v7

PL/Rust trusted-language example for timestamp-based UUID v7 values

pg_tle · PL/Rust trusted-language example for timestamp-based UUID v7 values

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102130uuid_v7pg_tle1.0FUNCApache-2.0Rust
Relationships
Requiresplrust

Usage

Sources:

uuid_v7 is an AWS Trusted Language Extensions example implemented in PL/Rust. It generates time-based UUIDs, creates one for a supplied timestamp and extracts its millisecond timestamp.

Core Workflow

CREATE EXTENSION plrust;
CREATE EXTENSION uuid_v7;
SELECT generate_uuid_v7();
SELECT timestamptz_to_uuid_v7('2026-10-06 00:00:00+00'::timestamptz);
SELECT uuid_v7_to_timestamptz(generate_uuid_v7());

Operational Boundaries

Install pg_tle and PL/Rust 1.2.0 or later, then register the example through its documented TLE installation process. Once it appears among available extensions, create it in the database. The control’s SQL dependency is plrust; this is not a separate native pgrx shared library.

generate_uuid_v7 uses the current time; timestamptz_to_uuid_v7 embeds a supplied timestamp; uuid_v7_to_timestamptz decodes the first timestamp bits. The decoder does not establish that an arbitrary UUID is a valid version-7 value. Time is millisecond-granular and random suffixes do not provide strict total ordering within a millisecond. The example was developed against a UUID v7 draft; assess its semantics before using it as a standards-conformance boundary.

Table reader