Chapter 28. バックエンドインターフェイス

Table of Contents
BKI ファイルフォーマット
汎用コマンド
マクロコマンド
デバッグ命令

Backend Interface (BKI) files are scripts that are input to the Postgres backend running in the special "bootstrap" mode that allows it to perform database functions without a database system already existing. BKI files can therefore be used to create the database system in the first place. initdb uses BKI files to do just that: to create a database system. However, initdb's BKI files are generated internally. It generates them using the files global1.bki.source and local1.template1.bki.source, which it finds in the Postgres "library" directory. They get installed there as part of installing Postgres. These .source files get build as part of the Postgres build process, by a build program called genbki. genbki takes as input Postgres source files that double as genbki input that builds tables and C header files that describe those tables.

バックエンドインターフェイス (BKI) ファイルは特殊な "ブート"モードで立ち上がった Postgres バックエンド に入力されるスクリプトで、データベースシステムが未だ存在しなくてもデータベース の機能を使えるようにするものです。ですから BKI ファイルは一番最初にデータベースシステムを作成するときに使われます。 initdbBKI ファイルを データベースシステム作成のために使用するだけです。 しかし、initdbBKI ファイルは内部的に生成されるものです。そのファイルはそれ自身を Postgres の "library" ディレクトリにある global1.bki.source ファイルと local1.template1.bki.source ファイルを使用して生成 します。BKI ファイルは Postgres のインストールの一部 としてインストールされます。これらの .source ファイルは Postgres の組み立ての過程で genbki と呼ばれる組み立てプログラムにより組み立てられます。 genbki は入力として、Postgres ソースファイルを取り込み、 テーブルとテーブルを記述する C ヘッダーファイルを組み立てます。

Related information may be found in documentation for initdb, createdb, and the SQL command CREATE DATABASE.

関連情報は initdbcreatedb および SQL コマンド CREATE DATABASE にあります。

BKI ファイルフォーマット

The Postgres backend interprets BKI files as described below. This description will be easier to understand if the global1.bki.source file is at hand as an example. (As explained above, this .source file isn't quite a BKI file, but you'll be able to guess what the resulting BKI file would be anyway).

Postgres バックエンドは BKI ファイルを 下記のようにして解釈します。この説明は、手元に global1.bki.source ファイルが用意されていればより理解しやすいでしょう。 (上で述べたように、この .source ファイルは正確には BKI ファイルではありませんが、最終的にどんな BKIファイルになるかはきっと想像がつくでしょう。)

Commands are composed of a command name followed by space separated arguments. Arguments to a command which begin with a "$" are treated specially. If "$$" are the first two characters, then the first "$" is ignored and the argument is then processed normally. If the "$" is followed by space, then it is treated as a NULL value. Otherwise, the characters following the "$" are interpreted as the name of a macro causing the argument to be replaced with the macro's value. It is an error for this macro to be undefined.

コマンドはコマンド名とそれに引き続くスペースで区切られた引数からなります。 "$" で始まるコマンドに対する引数は特別に扱われます。もし、 "$$" が始めの二つの文字であれば、最初の "$" は 無視されて引数が通常通り処理されます。もし "$" の後にスペースが 続けば NULL 値として扱われます。さもなければ、"$" に続く文字が 引数をマクロの値で置換する、マクロの名前として翻訳されます。このマクロ が定義されてないとエラーになります。

Macros are defined using

define macro macro_name = macro_value
and are undefined using
undefine macro macro_name
and redefined using the same syntax as define.

マクロは

define macro マクロ名 = マクロ値
で定義され
undefine macro マクロ名
で定義が解除されます。 再定義は define と同じ構文で行います。

Lists of general commands and macro commands follow.

汎用コマンドとマクロコマンドの一覧は以下の通りです。