Chapter 3. SQL の拡張: 概要

Table of Contents
どのように拡張機能が動作するのか
Postgres の型システム
Postgres システムカタログについて

In the sections that follow, we will discuss how you can extend the Postgres SQL query language by adding:

以下を追加することによってどのように Postgres SQL 問い 合わせ言語を拡張できるのかについて、以降の節で説明します。

どのように拡張機能が動作するのか

Postgres is extensible because its operation is catalog-driven. If you are familiar with standard relational systems, you know that they store information about databases, tables, columns, etc., in what are commonly known as system catalogs. (Some systems call this the data dictionary). The catalogs appear to the user as classes, like any other, but the DBMS stores its internal bookkeeping in them. One key difference between Postgres and standard relational systems is that Postgres stores much more information in its catalogs -- not only information about tables and columns, but also information about its types, functions, access methods, and so on. These classes can be modified by the user, and since Postgres bases its internal operation on these classes, this means that Postgres can be extended by users. By comparison, conventional database systems can only be extended by changing hardcoded procedures within the DBMS or by loading modules specially-written by the DBMS vendor.

Postgres は、その操作がカタログ起動型で あるため、拡張性があります。標準的なリレーショナルシステムを良く知 っている方は、システムが一般にシステムカタログと呼ばれるものの内部 に、データベースやテーブル、カラムといったものの情報を保存している ということを理解していると思います。(システムによってはシステムカ タログのことをデータ辞書と呼んでいます。)このカタログは、ユーザに は他のものと同じようにクラスとして見えますが、 DBMS は内部的な帳面をそこに保存します。 Postgres は、標準的なリレーショナルシス テムと大きく異なり、カタログの中にもっと多くの情報、つまり、テーブ ルやカラムの情報だけでなく、型、関数、アクセスメソッドなどの情報を 保存しています。これらのクラスはユーザによって変更可能です。また、 Postgres はこれらのクラスに基づいて動作 していますので、 Postgres はユーザ によって拡張することができることができます。これに対して、従来 のデータベースシステムでは、DBMS 内に直接プログ ラミングされたプロシージャを変更するか、または、その DBMS ベンダによって特別に作成されたモジュールを 読み込むことでしか拡張することができません。

Postgres is also unlike most other data managers in that the server can incorporate user-written code into itself through dynamic loading. That is, the user can specify an object code file (e.g., a compiled .o file or shared library) that implements a new type or function and Postgres will load it as required. Code written in SQL are even more trivial to add to the server. This ability to modify its operation "on the fly" makes Postgres uniquely suited for rapid prototyping of new applications and storage structures.

Postgres はまた、ユーザが作成したコー ドを動的読み込みを通してサーバ内に組み込むことができるという点で も、他のほとんどのデータ管理システムと異なっています。つまり、ユ ーザは新しい型や関数を実装した(コンパイル後にできる .o ファイル や共有ライブラリといった)オブジェクトコードファイルを指定で き、Postgres は必要に応じてそのファイ ルを読み込むことができます。SQL 内で記述された コードをサーバに追加することはもっと簡単にできます。"その場ですぐ に" データベースの動作を変更できるというこの機能は、 Postgres を比類稀なく新しいアプリケーシ ョンや記憶領域の構成に対する素早いプロトタイプ開発に適したものに しています。