Postgres の型システム

The Postgres type system can be broken down in several ways. Types are divided into base types and composite types. Base types are those, like int4, that are implemented in a language such as C. They generally correspond to what are often known as "abstract data types"; Postgres can only operate on such types through methods provided by the user and only understands the behavior of such types to the extent that the user describes them. Composite types are created whenever the user creates a class. EMP is an example of a composite type.

Postgres の型システムは幾つかの方法で分 類することができます。型は基本型と複合型に分けられます。基本型は、 int4 のようなもので、 C で代表されるような言語で実装されていま す。基本型は、よく「抽象データ型」として知られるものに普通対応してい ます。 Postgres は、ユーザが作成したメソッドを通 してしかこれらの型を操作することができず、また、ユーザが記述した範囲 でしかこれらの型の振舞いを解読しません。複合型はユー ザがクラスを定義した段階で作成されます。EMP は複合型の例です。

Postgres stores these types in only one way (within the file that stores all instances of the class) but the user can "look inside" at the attributes of these types from the query language and optimize their retrieval by (for example) defining indices on the attributes. Postgres base types are further divided into built-in types and user-defined types. Built-in types (like int4) are those that are compiled into the system. User-defined types are those created by the user in the manner to be described below.

Postgres はこれらの型をたった 1 つの方 法で(そのクラスの全インスタンスを保存するファイル内に)保存しま す。しかし、ユーザは問い合わせ言語を使って型の属性の "内部を見る" ことができ、(例えば)その属性のインデックスを定義することでその抽 出を最適化することができます。Postgres の基本型は更に組み込み型とユーザ定義型に分けられます。( int4 といった)組み込み型は、システム中に コンパイルされたものです。ユーザ定義型は後述の方法を使ってユーザ によって作成されたものです。