rent
PostgreSQL extensions

uuid-ossp

What it is

uuid-ossp is a PostgreSQL-supplied extension for generating UUIDs using standard version 1, 3, 4, and 5 algorithms. Modern PostgreSQL provides random UUID generation in core; this extension remains useful for namespace-derived and other specialized UUID forms.

What it provides

  • Random version 4 UUIDs
  • Deterministic version 3 and 5 UUIDs derived from a namespace and name
  • Version 1 timestamp-and-MAC-based UUIDs and standard namespace constants

Use it for importing systems that already rely on UUID algorithms, generating the same ID for the same logical name, or creating IDs through a database default.

Use it with Rent

extension uuid_ossp {
  name = "uuid-ossp"
}

The RSL declaration makes installation and migration intent part of the reviewed application schema. Register the typed pack at runtime to call its APIs:

let uuids = extensions.register_pack::<UuidOssp>()?;
let random_default = uuids.v4();
let stable = uuids.v5(
    Namespace::Dns,
    "customer.example.com",
);

let id = uuids
    .client(&pool)
    .v4()
    .await?;

Run the application

cargo run -p rent --example extension_11_uuid_ossp

Set DATABASE_URL to a disposable PostgreSQL server whose role can create databases and install uuid-ossp. The application checks that importing the same name twice gives the same version 5 ID, that changing the name changes the ID, and that the DNS, OID, and X.500 namespaces each give a different ID for the same name. It also checks random version 4 generation. The extension runs in a custom schema in an isolated database that is removed afterward.

Namespace-derived IDs are deterministic identifiers, not secret tokens. Keep the namespace and input-name normalization stable when using them to deduplicate imports. Its standalone extension declaration is crates/rent/examples/extension_11_uuid_ossp/schema.rsl.

On this page