Chapter 51. BKI Backend Interface

Backend Interface (BKI)
files are scripts in a special language that is understood by the
PostgreSQL backend when running
in the "bootstrap" mode. The bootstrap
mode allows system catalogs to be created and filled from
scratch, whereas ordinary SQL commands require the catalogs to
exist already. BKI files can
therefore be used to create the database system in the first
place. (And they are probably not useful for anything else.)

initdb uses a BKI file to do part of its job when creating
a new database cluster. The input file used by initdb is created as part of building and
installing PostgreSQL by a
program named genbki.sh, which reads
some specially formatted C header files in the src/include/catalog/ directory of the source
tree. The created BKI file is
called postgres.bki and is normally
installed in the share subdirectory of
the installation tree.

This section describes how the PostgreSQL backend interprets
BKI files. This description
will be easier to understand if the postgres.bki file is at hand as an example.

BKI input consists of a
sequence of commands. Commands are made up of a number of
tokens, depending on the syntax of the command. Tokens are
usually separated by whitespace, but need not be if there is no
ambiguity. There is no special command separator; the next
token that syntactically cannot belong to the preceding command
starts a new one. (Usually you would put a new command on a new
line, for clarity.) Tokens can be certain key words, special
characters (parentheses, commas, etc.), numbers, or
double-quoted strings. Everything is case sensitive.