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

53.64. pg_type #

The catalog <structname>pg_type</structname> stores information about data types. Base types and enum types (scalar types) are created with <link linkend="sql-createtype"><command>CREATE TYPE</command></link>, and domains with <link linkend="sql-createdomain"><command>CREATE DOMAIN</command></link>. A composite type is automatically created for each table in the database, to represent the row structure of the table. It is also possible to create composite types with <command>CREATE TYPE AS</command>. pg_typeカタログはデータ型の情報を保存します。 基本型と列挙型(スカラ型)はCREATE TYPEで作成され、ドメインはCREATE DOMAINで作成されます。 複合型がテーブルの行構成を表すためデータベースの個々のテーブルに対して自動的に作成されます。 複合型をCREATE TYPE ASで作成することもできます。

表53.64 pg_typeの列

<title><structname>pg_type</structname> Columns</title>

Column Type 列 型

Description 説明

oid oid

Row identifier 行識別子

typname name

Data type name データ型名

typnamespace oid (references <link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.<structfield>oid</structfield>) (参照先 pg_namespace.oid

The OID of the namespace that contains this type この型を含む名前空間のOID

typowner oid (references <link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.<structfield>oid</structfield>) (参照先 pg_authid.oid

Owner of the type 型の所有者

typlen int2

For a fixed-size type, <structfield>typlen</structfield> is the number of bytes in the internal representation of the type. But for a variable-length type, <structfield>typlen</structfield> is negative. -1 indicates a <quote>varlena</quote> type (one that has a length word), -2 indicates a null-terminated C string. 固定長型では、typlenは型の内部表現内でのバイト数です。 しかし、可変長型ではtyplenは負です。 -1はvarlena型(最初の4バイトにデータ長を含むもの)を意味し、-2はヌル終端のC言語の文字列を示します。

typbyval bool

<structfield>typbyval</structfield> determines whether internal routines pass a value of this type by value or by reference. <structfield>typbyval</structfield> had better be false if <structfield>typlen</structfield> is not 1, 2, or 4 (or 8 on machines where Datum is 8 bytes). Variable-length types are always passed by reference. Note that <structfield>typbyval</structfield> can be false even if the length would allow pass-by-value. typbyvalは内部関数がこの型の値を値渡しか、参照渡しかを決定します。 typlenが1、2、4バイト長(もしくはDatumが8バイトのマシン上では8バイト長)以外であれば、typbyvalをfalseにする必要があります。 可変長型は必ず参照渡しになります。 typbyvalは長さが値渡し可能でもfalseになり得ることに注意してください。

typtype char

<structfield>typtype</structfield> is <literal>b</literal> for a base type, <literal>c</literal> for a composite type (e.g., a table's row type), <literal>d</literal> for a domain, <literal>e</literal> for an enum type, <literal>p</literal> for a pseudo-type, <literal>r</literal> for a range type, or <literal>m</literal> for a multirange type. See also <structfield>typrelid</structfield> and <structfield>typbasetype</structfield>. typtypeでは、 b = 基本型、 c = 複合型(例えばテーブルの行の型)、 d = 派生型(ドメインなど)、 e = 列挙型、 p = 疑似型、 r = 範囲型、 m = 多重範囲型です。 typrelidおよびtypbasetypeも参照してください。

typcategory char

<structfield>typcategory</structfield> is an arbitrary classification of data types that is used by the parser to determine which implicit casts should be <quote>preferred</quote>. See <xref linkend="catalog-typcategory-table"/>. typcategoryは、パーサがどの暗黙のキャストが選択されるべきか決定するのに使用されるデータ型の任意の分類です。 表 53.65を参照してください。

typispreferred bool

True if the type is a preferred cast target within its <structfield>typcategory</structfield> 型がtypcategory内で選択されたキャスト対象である場合はtrue

typisdefined bool

True if the type is defined, false if this is a placeholder entry for a not-yet-defined type. When <structfield>typisdefined</structfield> is false, nothing except the type name, namespace, and OID can be relied on. 型が定義されている場合はtrue。 ここが未定義型に対する予備の場所である場合はfalse。 typisdefinedがfalseの場合、型名と名前空間とOID以外は信頼すべきでありません。

typdelim char

Character that separates two values of this type when parsing array input. Note that the delimiter is associated with the array element data type, not the array data type. 配列入力の構文解析をする際にこの型の2つの値を分離する文字。 区切り文字は配列データ型ではなく配列要素データ型に関連付けられることに注意してください。

typrelid oid (references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>) (参照先 pg_class.oid

If this is a composite type (see <structfield>typtype</structfield>), then this column points to the <link linkend="catalog-pg-class"><structname>pg_class</structname></link> entry that defines the corresponding table. (For a free-standing composite type, the <link linkend="catalog-pg-class"><structname>pg_class</structname></link> entry doesn't really represent a table, but it is needed anyway for the type's <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link> entries to link to.) Zero for non-composite types. もしこれが複合型(typtypeを参照)であれば、この列は関連するテーブルを定義するpg_class項目を指します。 (独立の複合型の場合、pg_class項目は実際にはテーブルを表しませんが、いずれにしても型のpg_attribute項目をリンクするために必要です。) 複合型でない場合はゼロです。

typsubscript regproc (references <link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.<structfield>oid</structfield>) (参照先 pg_proc.oid

Subscripting handler function's OID, or zero if this type doesn't support subscripting. Types that are <quote>true</quote> array types have <structfield>typsubscript</structfield> = <function>array_subscript_handler</function>, but other types may have other handler functions to implement specialized subscripting behavior. 添字ハンドラ関数のOID、あるいはこの型が添え字付けをサポートしていなければゼロ。 本当の配列型では、typsubscript = array_subscript_handlerとなります。 しかし、他の型では特別な添え字付けの振る舞いを実装するハンドラ関数を持つかもしれません。

typelem oid (references <link linkend="catalog-pg-type"><structname>pg_type</structname></link>.<structfield>oid</structfield>) (参照先 pg_type.oid

If <structfield>typelem</structfield> is not zero then it identifies another row in <structname>pg_type</structname>, defining the type yielded by subscripting. This should be zero if <structfield>typsubscript</structfield> is zero. However, it can be zero when <structfield>typsubscript</structfield> isn't zero, if the handler doesn't need <structfield>typelem</structfield> to determine the subscripting result type. Note that a <structfield>typelem</structfield> dependency is considered to imply physical containment of the element type in this type; so DDL changes on the element type might be restricted by the presence of this type. typelemがゼロでない場合、これは添字付けによって生成された型を定義するpg_typeの別の列を特定します。 typsubscriptがゼロなら、これはゼロとなるはずです。 しかし、添字付けの結果型を決定するためにハンドラがtypelemを必要としてなければ、typsubscriptがゼロでなくても、ゼロとなることがあります。 typelem依存性は、この型の要素型を物理的に含むことを暗示すると考えられることに注意してください。 ですからこの要素型に対するDDL変更は、この型に存在に制限されるかもしれません。

typarray oid (references <link linkend="catalog-pg-type"><structname>pg_type</structname></link>.<structfield>oid</structfield>) (参照先 pg_type.oid

If <structfield>typarray</structfield> is not zero then it identifies another row in <structname>pg_type</structname>, which is the <quote>true</quote> array type having this type as element typarrayがゼロでない場合、typarraypg_type内のもうひとつの行を特定します。 もうひとつの行は、この型を要素として持っている本当の配列型です。

typinput regproc (references <link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.<structfield>oid</structfield>) (参照先 pg_proc.oid

Input conversion function (text format) 入力変換関数(テキスト形式)

typoutput regproc (references <link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.<structfield>oid</structfield>) (参照先 pg_proc.oid

Output conversion function (text format) 出力変換関数(テキスト形式)

typreceive regproc (references <link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.<structfield>oid</structfield>) (参照先 pg_proc.oid

Input conversion function (binary format), or zero if none 入力変換関数(バイナリ形式)、なければゼロ

typsend regproc (references <link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.<structfield>oid</structfield>) (参照先 pg_proc.oid

Output conversion function (binary format), or zero if none 出力変換関数(バイナリ形式)、なければゼロ

typmodin regproc (references <link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.<structfield>oid</structfield>) (参照先 pg_proc.oid

Type modifier input function, or zero if type does not support modifiers 型修飾子の入力関数。型が修飾子をサポートしていない場合はゼロ

typmodout regproc (references <link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.<structfield>oid</structfield>) (参照先 pg_proc.oid

Type modifier output function, or zero to use the standard format 型修飾子の出力関数。標準書式を使用する場合はゼロ

typanalyze regproc (references <link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.<structfield>oid</structfield>) (参照先 pg_proc.oid

Custom <xref linkend="sql-analyze"/> function, or zero to use the standard function 独自のANALYZE関数。標準関数を使用する場合はゼロ

typalign char

<structfield>typalign</structfield> is the alignment required when storing a value of this type. It applies to storage on disk as well as most representations of the value inside <productname>PostgreSQL</productname>. When multiple values are stored consecutively, such as in the representation of a complete row on disk, padding is inserted before a datum of this type so that it begins on the specified boundary. The alignment reference is the beginning of the first datum in the sequence. Possible values are: typalignはこの型の値を格納する際に必要な整列です。 ディスク上での格納だけでなく、PostgreSQL内部の値の表現にも適用されます。 ディスク上の完全な行の表現のように、複数の値が隣接して格納される際には、指定された境界で始まるように、この型のデータの前にパディングが挿入されます。 アライメントの参照先は、連続しているデータ中の先頭のデータの開始位置です。 使用可能な値は以下の通りです。

  • <para><literal>c</literal> = <type>char</type> alignment, i.e., no alignment needed.</para>

    c = char整列(すなわち、整列は必要ありません)。

  • <para><literal>s</literal> = <type>short</type> alignment (2 bytes on most machines).</para>

    s = short整列(多くのマシンでは2バイトになります)。

  • <para><literal>i</literal> = <type>int</type> alignment (4 bytes on most machines).</para>

    i = int整列(多くのマシンでは4バイトになります)。

  • <para><literal>d</literal> = <type>double</type> alignment (8 bytes on many machines, but by no means all).</para>

    d = double整列(多くのマシンでは8バイトになりますが、必ずしもすべてがそうであるとは限りません)。

typstorage char

<structfield>typstorage</structfield> tells for varlena types (those with <structfield>typlen</structfield> = -1) if the type is prepared for toasting and what the default strategy for attributes of this type should be. Possible values are: typstorageは、varlena型(typlen = -1であるもの)において、その型がトーストされる予定であるか、この型においてアトリビュートに対するデフォルトの戦略が何であるかを示します。 可能な値は以下です。

  • <literal>p</literal> (plain): Values must always be stored plain (non-varlena types always use this value). p (plain):値は常にplainで格納されなければなりません(非varlena型は常にこの値を使います)。

  • <literal>e</literal> (external): Values can be stored in a secondary <quote>TOAST</quote> relation (if relation has one, see <literal>pg_class.reltoastrelid</literal>). e (external):値は従属的リレーションに格納できます(リレーションがあるとき。リレーションに関してはpg_class.reltoastrelidを参照してください)。

  • <literal>m</literal> (main): Values can be compressed and stored inline. m (main):値は圧縮してインラインで格納できます。

  • <literal>x</literal> (extended): Values can be compressed and/or moved to a secondary relation. x (extended):値は圧縮することもできますし、圧縮した上で更に従属的リレーションに移動することもできます。

<literal>x</literal> is the usual choice for toast-able types. Note that <literal>m</literal> values can also be moved out to secondary storage, but only as a last resort (<literal>e</literal> and <literal>x</literal> values are moved first). トースト可能な型に対しては x が通常の選択です。 m 値も、どうしても必要なら従属的格納に移動できることに注意してください(ex 値は、まず最初に移動します)。

typnotnull bool

<structfield>typnotnull</structfield> represents a not-null constraint on a type. Used for domains only. typnotnullは型に対し非NULL制約を表します。 ドメインでのみ使用されます。

typbasetype oid (references <link linkend="catalog-pg-type"><structname>pg_type</structname></link>.<structfield>oid</structfield>) (参照先 pg_type.oid

If this is a domain (see <structfield>typtype</structfield>), then <structfield>typbasetype</structfield> identifies the type that this one is based on. Zero if this type is not a domain. もしこれがドメイン(typtypeを参照)であれば、typbasetypeはこれが基づいている型を指定します。 ドメインでない場合はゼロです。

typtypmod int4

Domains use <structfield>typtypmod</structfield> to record the <literal>typmod</literal> to be applied to their base type (-1 if base type does not use a <literal>typmod</literal>). -1 if this type is not a domain. ドメインはtyptypmodを使用して、基本型に適用されるtypmodを記録します (基本型がtypmodを使用しない場合は-1)。 この型がドメインでない場合は-1です。

typndims int4

<structfield>typndims</structfield> is the number of array dimensions for a domain over an array (that is, <structfield>typbasetype</structfield> is an array type). Zero for types other than domains over array types. typndimsは配列であるドメインの配列の次元数です (つまり、typbasetypeは配列型です)。 配列型のドメインでない場合はゼロです。

typcollation oid (references <link linkend="catalog-pg-collation"><structname>pg_collation</structname></link>.<structfield>oid</structfield>) (参照先 pg_collation.oid

<structfield>typcollation</structfield> specifies the collation of the type. If the type does not support collations, this will be zero. A base type that supports collations will have a nonzero value here, typically <symbol>DEFAULT_COLLATION_OID</symbol>. A domain over a collatable type can have a collation OID different from its base type's, if one was specified for the domain. typcollationは型の照合順序を指定します。 型が照合順序をサポートしない場合、ゼロになります。 照合順序をサポートする基本型はここでゼロ以外の値を持ちます。典型的にはDEFAULT_COLLATION_OIDです。 照合順序の設定可能な型全体のドメインは、そのドメインで照合順序が指定されていれば、基本型とは異なる照合順序OIDを持つことができます。

typdefaultbin pg_node_tree

If <structfield>typdefaultbin</structfield> is not null, it is the <function>nodeToString()</function> representation of a default expression for the type. This is only used for domains. typdefaultbinがNULLでない場合、これは型のデフォルト式のnodeToString()表現です。 ドメインでのみ使用されます。

typdefault text

<structfield>typdefault</structfield> is null if the type has no associated default value. If <structfield>typdefaultbin</structfield> is not null, <structfield>typdefault</structfield> must contain a human-readable version of the default expression represented by <structfield>typdefaultbin</structfield>. If <structfield>typdefaultbin</structfield> is null and <structfield>typdefault</structfield> is not, then <structfield>typdefault</structfield> is the external representation of the type's default value, which can be fed to the type's input converter to produce a constant. 関連するデフォルト値を持たない型であればtypdefaultはNULLです。 typdefaultbinがNULLでない場合、typdefaultは、typdefaultbinによって表される人間が見てわかる形式のデフォルト式を含む必要があります。 typdefaultbinがNULLでtypdefaultがNULLでない場合、typdefaultは型のデフォルト値の外部表現です。 これは、定数を生成するために型の入力変換処理に渡されることがあります。

typacl aclitem[]

Access privileges; see <xref linkend="ddl-priv"/> for details アクセス権限。 詳細は5.7を参照してください


注記

For fixed-width types used in system tables, it is critical that the size and alignment defined in <structname>pg_type</structname> agree with the way that the compiler will lay out the column in a structure representing a table row. 固定長型のシステムテーブルでは、pg_typeで定義されているサイズとアライメントと、コンパイラがテーブル行を表現する構造体の中で列を格納する方法とで合意が取れていることが重要です。

<xref linkend="catalog-typcategory-table"/> lists the system-defined values of <structfield>typcategory</structfield>. Any future additions to this list will also be upper-case ASCII letters. All other ASCII characters are reserved for user-defined categories. 表 53.65はシステムで定義されたtypcategoryの値の一覧です。 今後この一覧に追加されるものは同様に大文字のASCII文字になります。 他のすべてのASCII文字はユーザ定義のカテゴリのために予約されています。

表53.65 typcategoryのコード

<title><structfield>typcategory</structfield> Codes</title>
コードカテゴリ
A配列型
B論理値型
C複合型
D日付時刻型
E列挙型
G幾何学型
Iネットワークアドレス型
N数値型
P仮想型
R範囲型
S文字列型
T時間間隔型
Uユーザ定義型
Vビット列型
Xunknown
Z内部利用の型