Chapter 19. BKI Backend Interface

Backend Interface (BKI) files are scripts that are written in a special language. These scripts can be input to the PostgreSQL backend running in the special "bootstrap" mode, which enables the backend to perform database functions without having a database system. This enables you to use BKI files to create the database system from scratch. (The files are not useful for anything else.)

initdb uses BKI files to do part of its job when creating a new database cluster. The input files used by initbd are created as part of building and installing PostgreSQL by a program named genbki.sh from some specially formatted C header files in the source tree. The created BKI files are called global.bki (for global catalogs) and template1.bki (for the catalogs initially stored in the template1 database and then duplicated in every created database) and are normally installed in the share subdirectory of the installation tree.

You can find related information in the documentation for initdb.

BKI File Format

This section describes how the PostgreSQL backend interprets BKI files. This description will be easier to understand if the global.bki file is at hand as an example. You should also study the source code of initdb to get an idea of how the backend is invoked.

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.

Lines starting with a # are ignored.