uniqueidentifier
uniqueidentifier · Legacy 16-byte uniqueidentifier data type, comparison operators, casts, and newid() generation for PostgreSQL.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100306 | uniqueidentifier | uniqueidentifier | 1.0 | TYPE | LGPL-2.1 | C |
PostgreSQL · 16
Usage
Sources:
uniqueidentifier is a legacy 16-byte UUID-like type with generation, text conversion, comparisons, concatenation, and B-tree/hash operator classes. It was originally written in 2001–2003 and later packaged as a PostgreSQL extension; prefer PostgreSQL’s built-in uuid type for new schemas unless compatibility with this exact legacy type is required.
Core Workflow
The native library depends on the e2fsprogs libuuid implementation. After installing the matching binary, create the extension and use newid() for generated defaults:
newid(text) parses text explicitly. The extension also declares implicit casts in both directions:
SQL Surface
newid()generates a value usinglibuuidand is volatile.newid(text)parses text;text(uniqueidentifier)formats a value.<,<=,=,<>,>=, and>support comparisons.- Default B-tree and hash operator classes support primary keys, equality lookup, ordering, and indexes.
||overloads concatenate a value withtextin either argument order.
Migration and Compatibility
- This type is not PostgreSQL’s built-in
uuid, even though both occupy 16 bytes and use familiar text. Test semantic, ordering, binary, replication, driver, dump/restore, and cast differences before migrating between them. - Bidirectional implicit casts with
textcan change overload resolution and hide malformed boundaries. Use explicit casts in new SQL and test expressions after upgrades. - The reviewed install SQL hard-codes
publicfor concatenation operators and changes helper-function ownership to the rolepostgres. Review the script against the intended schema and role model before installation. - Do not infer current PostgreSQL compatibility from the README’s PostgreSQL 9.1 packaging note. Build and test the exact source/package against the target major version.
- If compatibility is not required, use core
uuidwith the server’s supported UUID generator and migrate with an explicit, validated text conversion.