Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
F.60. uuid-ossp
Prev UpAppendix F. Additional Supplied ModulesHome Next

F.60. uuid-ossp

Theuuid-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.

F.60.1. uuid-ossp Functions

Table F.35 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.35. Functions for UUID Generation

FunctionDescription
uuid_generate_v1()

This function 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.

uuid_generate_v1mc()

This function generates a version 1 UUID but uses a random multicast MAC address instead of the real MAC address of the computer.

uuid_generate_v3(namespace uuid, name text)

This function 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 theuuid_ns_*() functions shown inTable F.36. (It could be any UUID in theory.) The name is an identifier in the selected namespace.

For example:

SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');

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.

uuid_generate_v4()

This function generates a version 4 UUID, which is derived entirely from random numbers.

uuid_generate_v5(namespace uuid, name text)

This 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.36. Functions Returning UUID Constants

uuid_nil()

Anil UUID constant, which does not occur as a real UUID.

uuid_ns_dns()

Constant designating the DNS namespace for UUIDs.

uuid_ns_url()

Constant designating the URL namespace for UUIDs.

uuid_ns_oid()

Constant designating the ISO object identifier (OID) namespace for UUIDs. (This pertains to ASN.1 OIDs, which are unrelated to the OIDs used inPostgres Pro.)

uuid_ns_x500()

Constant designating the X.500 distinguished name (DN) namespace for UUIDs.


F.60.2. Buildinguuid-ossp

Historically this module depended on the OSSP UUID library, which accounts for the module's name. While the OSSP UUID library can still be found athttp://www.ossp.org/pkg/lib/uuid/, it is not well maintained, and is becoming increasingly difficult to port to newer platforms.uuid-ossp can now be built without the OSSP library on some platforms. On FreeBSD and some other BSD-derived platforms, suitable UUID creation functions are included in the corelibc library. On Linux, macOS, and some other platforms, suitable functions are provided in thelibuuid library, which originally came from thee2fsprogs project (though on modern Linux it is considered part ofutil-linux-ng). When invokingconfigure, specify--with-uuid=bsd to use the BSD functions, or--with-uuid=e2fs to usee2fsprogs'libuuid, or--with-uuid=ossp to use the OSSP UUID library. More than one of these libraries might be available on a particular machine, soconfigure does not automatically choose one.

Note

If you only need randomly-generated (version 4) UUIDs, consider using thegen_random_uuid() function from thepgcrypto module instead.

F.60.3. Author

Peter Eisentraut<peter_e@gmx.net>


Prev Up Next
F.59. unaccent Home F.61. xml2
epubpdf
Go to Postgres Pro Standard 10
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp