BKI (5)
*.bki
DESCRIPTION
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 -- 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.
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).
Commands are composed of a command name followed by space separated
arguments. Arguments to a command which begin with a \*(lq$\*(rq are
treated specially. If \*(lq$$\*(rq are the first two characters, then
the first \*(lq$\*(rq is ignored and the argument is then processed
normally. If the \*(lq$\*(rq is followed by space, then it is treated
as a
value. Otherwise, the characters following the \*(lq$\*(rq 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 \*(lq0\*(rq, 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 .
|