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

53.10. pg_cast #

The catalog <structname>pg_cast</structname> stores data type conversion paths, both built-in and user-defined. pg_castカタログにはデータ型変換パスが格納されます。 ここには、組み込みのパスとユーザ定義のパスが存在します。

It should be noted that <structname>pg_cast</structname> does not represent every type conversion that the system knows how to perform; only those that cannot be deduced from some generic rule. For example, casting between a domain and its base type is not explicitly represented in <structname>pg_cast</structname>. Another important exception is that <quote>automatic I/O conversion casts</quote>, those performed using a data type's own I/O functions to convert to or from <type>text</type> or other string types, are not explicitly represented in <structname>pg_cast</structname>. pg_castは、システムがどのように動作するかわかっているような、あらゆる型変換を表しているわけではないということに注意してください。 いくつかの一般的な規則から推測できないような型変換についてのみ表しています。 例えば、ドメインとその基本の型は明示的にpg_cast内で表されていません。 他の重要な例外は自動I/O変換キャストです。 これらのキャストは、text型やほかの文字列型から変換したりされたりするのにデータ型自身のI/O関数を用いていますが、これらのキャストは明示的にpg_cast内において表されていません。

表53.10 pg_castの列

<title><structname>pg_cast</structname> Columns</title>

Column Type 列 型

Description 説明

oid oid

Row identifier 行識別子

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

OID of the source data type 変換元データ型のOID

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

OID of the target data type 対象データ型のOID

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

The OID of the function to use to perform this cast. Zero is stored if the cast method doesn't require a function. このキャストを実行するために使用する関数のOID。 キャストメソッドが関数を必要としない場合はゼロが格納されます。

castcontext char

Indicates what contexts the cast can be invoked in. <literal>e</literal> means only as an explicit cast (using <literal>CAST</literal> or <literal>::</literal> syntax). <literal>a</literal> means implicitly in assignment to a target column, as well as explicitly. <literal>i</literal> means implicitly in expressions, as well as the other cases. キャストがどの文脈で呼び出し可能かを示します。 e = 明示のキャストとしてのみ起動されることを意味します(CASTまたは::構文を使用します)。 a = 対象となる列を明示的に特定するだけでなく暗黙的にも特定することを意味します。 i = 他の場合と同様に演算式内で暗黙的であることを意味します。

castmethod char

Indicates how the cast is performed. <literal>f</literal> means that the function specified in the <structfield>castfunc</structfield> field is used. <literal>i</literal> means that the input/output functions are used. <literal>b</literal> means that the types are binary-coercible, thus no conversion is required. どのようにキャストが実行されるかを示します。 f = castfuncフィールド内で示される関数が使用されていることを意味します。 i = 入出力関数が使用されていることを示します。 b = 型がバイナリを強制しているため、変換が必要ないことを意味します。


The cast functions listed in <structname>pg_cast</structname> must always take the cast source type as their first argument type, and return the cast destination type as their result type. A cast function can have up to three arguments. The second argument, if present, must be type <type>integer</type>; it receives the type modifier associated with the destination type, or -1 if there is none. The third argument, if present, must be type <type>boolean</type>; it receives <literal>true</literal> if the cast is an explicit cast, <literal>false</literal> otherwise. pg_cast内に挙げられているキャスト関数は、第1番目の引数の型として、キャスト元の型をいつも取らなければいけません。 また、キャスト関数は、結果の型としてキャスト先の型を返します。 キャスト関数は3つまで引数を持つことができます。 もし存在するなら、2番目の引数はinteger型でなくてはなりません。 この引数はキャスト先の型に関連付けられた型修飾子を受け取ります。 2番目の引数がない場合は、-1です。 3番目の引数は、もし存在する場合は、boolean型でなくてはなりません。 この引数は、もしキャストが明示的なキャストであればtrueを受け取り、そうでない場合はfalseを受け取ります。

It is legitimate to create a <structname>pg_cast</structname> entry in which the source and target types are the same, if the associated function takes more than one argument. Such entries represent <quote>length coercion functions</quote> that coerce values of the type to be legal for a particular type modifier value. もし関連のある関数が複数の引数を持つ場合、キャストの元と先で型が同じであるpg_cast項目を作成することが妥当です。 このような項目は、length coercion functionsを表現します。 length coercion functionsは型の値を特定の型の修飾子の値に適するように修正します。

When a <structname>pg_cast</structname> entry has different source and target types and a function that takes more than one argument, it represents converting from one type to another and applying a length coercion in a single step. When no such entry is available, coercion to a type that uses a type modifier involves two steps, one to convert between data types and a second to apply the modifier. pg_cast項目が異なるキャスト元とキャスト先の型を持っていて、かつ関数が複数の引数を持つ時は、1つの型から別の型への変換し、かつ、1つの手順で長さの修正を適用することを意味します。 このような項目が利用できない時は、型修飾子を使用した型の修正は2つの手順が必要です。 1つはデータ型の間での変換で、2つ目は修飾子を適用することです。