バージョンごとのドキュメント一覧

F.49. uuid-ossp — UUID生成器 #

<title>uuid-ossp &mdash; a UUID generator</title>

The <filename>uuid-ossp</filename> 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 <productname>PostgreSQL</productname>. See <xref linkend="functions-uuid"/> for built-in ways to generate UUIDs. uuid-osspモジュールは複数の標準的なアルゴリズムの1つを使用して汎用一意識別子(UUID)を生成する関数を提供します。 また、特殊なUUID定数を生成する関数も提供します。 このモジュールは、コアのPostgreSQLで利用可能なものを超える特別な要件にのみ必要となります。 UUIDを生成する組み込みの方法は9.14を参照してください。

This module is considered <quote>trusted</quote>, that is, it can be installed by non-superusers who have <literal>CREATE</literal> privilege on the current database. このモジュールはtrustedと見なされます。 つまり、現在のデータベースに対してCREATE権限を持つ非スーパーユーザがインストールできます。

F.49.1. uuid-ossp関数 #

<title><literal>uuid-ossp</literal> Functions</title>

<xref linkend="uuid-ossp-functions"/> shows the functions available to generate UUIDs. The relevant standards ITU-T Rec. X.667, ISO/IEC 9834-8:2005, and <ulink url="https://tools.ietf.org/html/rfc4122">RFC 4122</ulink> 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. UUIDを生成するために利用できる関数を表 F.34に示します。 関連する標準ITU-T Rec. X.667、ISO/IEC 9834-8:2005、RFC 4122はUUIDの生成に関して、バージョン番号1、3、4、5で識別される4つのアルゴリズムを規定します。 (バージョン2アルゴリズムは存在しません。) これらのアルゴリズムのそれぞれは、異なるアプリケーション群に適切でしょう。

表F.34 UUID生成用関数

<title>Functions for UUID Generation</title>

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. バージョン1 UUIDを生成します。 これはコンピュータのMACアドレスとタイムスタンプが含まれます。 この種のUUIDは識別子を生成したコンピュータを識別できる情報や生成した時刻をあばくことができますので、ある種のセキュリティに注意すべきアプリケーションでは適しません。

uuid_generate_v1mc () → uuid

Generates a version 1 UUID, but uses a random multicast MAC address instead of the real MAC address of the computer. コンピュータの実MACアドレスではなくランダムなマルチキャストMACアドレスを使用して、バージョン1 UUIDを作成します。

uuid_generate_v3 ( namespace uuid, name text ) → uuid

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 <function>uuid_ns_*()</function> functions shown in <xref linkend="uuid-ossp-constants"/>. (It could be any UUID in theory.) The name is an identifier in the selected namespace. 入力で指定されたnameを使用して、与えられた名前空間でバージョン3 UUIDを生成します。 名前空間は、表 F.35に示されるuuid_ns_*()関数で生成される特殊な定数の1つでなければなりません。 (理論上これは何らかのUUIDになります。) nameは選択された名前空間内の識別子です。

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. nameパラメータはMD5でハッシュ化されます。 このため、生成されたUUIDから平文が分かることはありません。 この方法によるUUIDの生成は不規則性はなく、また、環境に依存する要素もないため、再度生成されます。

uuid_generate_v4 () → uuid

Generates a version 4 UUID, which is derived entirely from random numbers. バージョン4 UUIDを生成します。 これは完全にランダムな数から生成されます。

uuid_generate_v5 ( namespace uuid, name text ) → uuid

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. バージョン5 UUIDを生成します。 バージョン3 UUIDと似ていますが、ハッシュ方式としてSHA-1を使用することが異なります。 SHA-1がMD5より安全であることから、バージョン5はバージョン3に比べて好まれるはずです。


表F.35 UUID定数を返す関数

<title>Functions Returning UUID Constants</title>

Function 関数

Description 説明

uuid_nil () → uuid

Returns a <quote>nil</quote> UUID constant, which does not occur as a real UUID. nil」UUID定数を返します。これは実際のUUIDになることはありません。

uuid_ns_dns () → uuid

Returns a constant designating the DNS namespace for UUIDs. DNS名前空間をUUIDに選定した定数を返します。

uuid_ns_url () → uuid

Returns a constant designating the URL namespace for UUIDs. URL名前空間をUUIDに選定した定数を返します。

uuid_ns_oid () → uuid

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 <productname>PostgreSQL</productname>.) ISOオブジェクト識別子(OID)をUUIDに選定した定数を返します。 (これはASN.1のOIDに関するもので、PostgreSQLで使われるOIDとは関係ありません。)

uuid_ns_x500 () → uuid

Returns a constant designating the X.500 distinguished name (DN) namespace for UUIDs. X.500区分名(DN)をUIDに選定した定数を返します。


F.49.2. uuid-osspの構築 #

<title>Building <filename>uuid-ossp</filename></title>

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 at <ulink url="http://www.ossp.org/pkg/lib/uuid/"></ulink>, it is not well maintained, and is becoming increasingly difficult to port to newer platforms. <filename>uuid-ossp</filename> 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 core <filename>libc</filename> library. On Linux, macOS, and some other platforms, suitable functions are provided in the <filename>libuuid</filename> library, which originally came from the <literal>e2fsprogs</literal> project (though on modern Linux it is considered part of <literal>util-linux-ng</literal>). When invoking <filename>configure</filename>, specify <option>&#45;-with-uuid=bsd</option> to use the BSD functions, or <option>&#45;-with-uuid=e2fs</option> to use <literal>e2fsprogs</literal>' <filename>libuuid</filename>, or <option>&#45;-with-uuid=ossp</option> to use the OSSP UUID library. More than one of these libraries might be available on a particular machine, so <filename>configure</filename> does not automatically choose one. 歴史的にこのモジュールは、モジュールの名前の由来となったOSSP UUIDライブラリに依存していました。 OSSP UUIDライブラリはまだhttp://www.ossp.org/pkg/lib/uuid/にありますが、あまりよく維持されておらず、より新しいプラットフォームへ移植することがますます困難になってきています。 uuid-osspは今やいくつかのプラットフォームではOSSPライブラリなしで構築できます。 FreeBSD、その他のBSDから派生したプラットフォームでは、適切なUUID生成関数がコアlibcライブラリに含まれています。 Linux、macOS、その他のプラットフォームでは、適切な関数がlibuuidライブラリで提供されており、(現在のLinuxではutil-linux-ngの一部と考えられていますが)そのライブラリはe2fsprogsプロジェクトに由来します。 configureを実行する時に、BSD関数を使うのなら--with-uuid=bsdを、e2fsprogslibuuidを使うのなら--with-uuid=e2fsを、OSSP UUIDライブラリを使うのなら--with-uuid=osspを指定してください。 あるマシンではこのライブラリのうち二つ以上が利用可能かもしれませんので、configureは自動的に一つを選びません。

F.49.3. 作者 #

<title>Author</title>

Peter Eisentraut