BKI(FILES)

NAME
.../src/backend/obj/{local,dbdb}.bki — template scripts

DESCRIPTION
Backend Interface (BKI) files are scripts that describe the contents of the initial Postgres database. This database is constructed during system installation, by the initdb command. Initdb executes the Postgres backend with a special set of flags, that cause it to consume the BKI scripts and bootstrap a database.

These files are automatically generated from system header files during installation. They are not intended for use by humans, and you do not need to understand their contents in order to use Postgres. These files are copied to
.../files/{global1,local1_XXX}.bki
during system installation.

All new user databases will be created by copying the template database that Postgres constructs from the BKI files. Thus, a simple way to customize the template database is to let the Postgres initialization script create it for you, and then to run the terminal monitor to make the changes you want.

The Postgres backend interprets BKI files as described below. This description will be easier to understand if the example in “.../files/global1.bki” is at hand.

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.

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.

Lists of general commands and macro commands follow.

GENERAL COMMANDS

open classname
    Open the class called classname for further manipulation.

close [classname]
    Close the open class called classname. It is an error if classname is not already opened. If no classname is given, then the currently open class is closed.

print
    Print the currently open class.

insert [oid=oid_value] ( value1 value2 ... )
    Insert a new instance to the open class using value1, value2, etc., for its attribute values and oid_value for its OID. If oid_value is not “0”, then this value will be used as the instance's object identifier. Otherwise, it is an error.

insert ( value1 value2 ... )
    As above, but the system generates a unique object identifier.

create classname ( name1 = type1, name2 = type2, ... )
    Create a class named classname with the attributes given in parentheses.

open ( name1 = type1, name2 = type2,... ) as classname
    Open a class named classname for writing but do not record its existence in the system catalogs. (This is primarily to aid in bootstrapping.)

destroy classname
    Destroy the class named classname.

define index index-name on class-name using amname
    ( opclass attr | function({attr}) )
    Create an index named index_name on the class named classname using the amname access method. The fields to index are called name1, name2, etc., and the operator collections to use are collection_1, collection_2, etc., respectively.

MACRO COMMANDS

define function macro_name as rettype function_name ( args )
    Define a function prototype for a function named macro_name which has its value of type rettype computed from the execution function_name with the arguments args declared in a C-like manner.

define macro macro_name from file filename
    Define a macro named macname which has its value read from the file called filename.

EXAMPLE
The following set of commands will create the “pg_opclass” class containing the int_ops collection as object 421, print out the class, and then close it.
create pg_opclass (opcname=char16)
open pg_opclass
insert oid=421 (int_ops)
print
close pg_opclass

SEE ALSO
initdb(1), createdb(1), createdb(l), template(files).