The uuid-ossp
module provides functions to generate universally
unique identifiers (UUIDs) using one of several standard algorithms. There
are also functions to produce certain special UUID constants.
This module is only necessary for special requirements beyond what is
available in core LightDB. See Section 10.13 for built-in ways to generate UUIDs.
This module is considered “trusted”, that is, it can be
installed by non-superusers who have CREATE
privilege
on the current database.
uuid-ossp
FunctionsTable F.73 shows the functions available to generate UUIDs. The relevant standards ITU-T Rec. X.667, ISO/IEC 9834-8:2005, and RFC 4122 specify four algorithms for generating UUIDs, identified by the version numbers 1, 3, 4, and 5. (There is no version 2 algorithm.) Each of these algorithms could be suitable for a different set of applications.
Table F.73. Functions for UUID Generation
Function Description |
---|
Generates a version 1 UUID. This involves the MAC address of the computer and a time stamp. Note that UUIDs of this kind reveal the identity of the computer that created the identifier and the time at which it did so, which might make it unsuitable for certain security-sensitive applications. |
Generates a version 1 UUID, but uses a random multicast MAC address instead of the real MAC address of the computer. |
Generates a version 3 UUID in the given namespace using
the specified input name. The namespace should be one of the special
constants produced by the For example: SELECT uuid_generate_v3(uuid_ns_url(), 'https://light-pg.com'); The name parameter will be MD5-hashed, so the cleartext cannot be derived from the generated UUID. The generation of UUIDs by this method has no random or environment-dependent element and is therefore reproducible. |
Generates a version 4 UUID, which is derived entirely from random numbers. |
Generates a version 4 UUID, which is derived entirely
from random numbers. Equivalent with function |
Generates a version 5 UUID, which works like a version 3 UUID except that SHA-1 is used as a hashing method. Version 5 should be preferred over version 3 because SHA-1 is thought to be more secure than MD5. |
Table F.74. Functions Returning UUID Constants
Function Description |
---|
Returns a “nil” UUID constant, which does not occur as a real UUID. |
Returns a constant designating the DNS namespace for UUIDs. |
Returns a constant designating the URL namespace for UUIDs. |
Returns a constant designating the ISO object identifier (OID) namespace for UUIDs. (This pertains to ASN.1 OIDs, which are unrelated to the OIDs used in LightDB.) |
Returns a constant designating the X.500 distinguished name (DN) namespace for UUIDs. |