# F.46. uuid-ossp
F.46.1.uuid-ossp
FunctionsF.46.2. Buildinguuid-ossp
F.46.3. Author
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. This module is only necessary for special requirements beyond what is available in core PostgreSQL. SeeSection 9.14for built-in ways to generate UUIDs.
This module is considered “trusted”, that is, it can be installed by non-superusers who haveCREATE
privilege on the current database.
# F.46.1.uuid-ossp
Functions
Table F.33shows the functions available to generate UUIDs. The relevant standards ITU-T Rec. X.667, ISO/IEC 9834-8:2005, andRFC 4122 (opens new window)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.33. Functions for UUID Generation
Function Description |
---|
uuid_generate_v1 () →uuid 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 () →uuid 生成版本 1 UUID,但使用随机多播 MAC 地址而不是计算机的真实 MAC 地址。 |
uuid_generate_v3 (命名空间 uuid ,姓名 文本 ) →uuid 使用指定的输入名称在给定的命名空间中生成版本 3 UUID。命名空间应该是由 uuid_ns_*() 所示功能表 F.34.(理论上它可以是任何 UUID。)名称是所选命名空间中的标识符。例如: <br/>SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');<br/><br/> name 参数将经过 MD5 哈希处理,因此无法从生成的 UUID 派生明文。通过这种方法生成的 UUID 没有随机或环境相关的元素,因此是可重现的。 |
uuid_generate_v4 () →uuid 生成完全从随机数派生的版本 4 UUID。 |
uuid_generate_v5 (命名空间 uuid ,姓名 文本 ) →乌伊德 生成版本5的UUID,除了SHA-1用作散列方法外,它的工作方式与版本3的UUID类似。版本5应该优先于版本3,因为SHA-1被认为比MD5更安全。 |
表F.34.返回UUID常量的函数
作用 描述 |
---|
uuid_nil () →乌伊德 返回一个“nil”UUID常量,该常量不是真实的UUID。 |
uuid_ns_dns () →乌伊德 返回指定UUID的DNS命名空间的常量。 |
uuid_ns_url () →乌伊德 返回一个常量,指定UUID的URL命名空间。 |
uuid_ns_oid () →乌伊德 返回一个常量,指定UUID的ISO对象标识符(OID)命名空间。(这与ASN.1 OID有关,与PostgreSQL中使用的OID无关。) |
uuid_ns_x500 () →乌伊德 返回一个常量,指定UUID的X.500可分辨名称(DN)命名空间。 |
# F.46.2.建筑uuid ossp
从历史上看,该模块依赖于OSSP UUID库,该库解释了该模块的名称。而OSSP UUID库仍然可以在http://www.ossp.org/pkg/lib/uuid/ (opens new window),它没有得到很好的维护,并且越来越难以移植到更新的平台。uuid ossp
在某些平台上,现在可以在没有OSSP库的情况下构建。在FreeBSD、NetBSD和其他一些BSD衍生平台上,内核中包含了合适的UUID创建函数libc
图书馆在Linux、macOS和其他一些平台上,在libuuid
图书馆,最初来自e2fsprogs
项目(尽管在现代Linux上它被认为是util linux ng
).当调用配置
具体说明--uuid=bsd时
使用BSD功能,或--uuid=e2fs时
使用e2fsprogs
' libuuid
或--uuid=ossp时
使用OSSP UUID库。在一台特定的机器上可能有不止一个这样的库,所以配置
不会自动选择一个。
# F.46.3.作者
彼得·艾森特<[peter_e@gmx.net](邮寄地址:彼得)_e@gmx.net)>