11<!--
2- $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.12 2003/11/29 19:51:36 pgsql Exp $
2+ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.13 2005/01/05 23:42:03 tgl Exp $
33 -->
44
55<chapter id="bki">
66 <title><acronym>BKI</acronym> Backend Interface</title>
77
88 <para>
99 Backend Interface (<acronym>BKI</acronym>) files are scripts in a
10- special language that are input to the
11- <productname>PostgreSQL</productname> backend running in the special
12- <quote>bootstrap</quote> mode that allows it to perform database
13- functions without a database system already existing.
10+ special language that is understood by the
11+ <productname>PostgreSQL</productname> backend when running in the
12+ <quote>bootstrap</quote> mode. The bootstrap mode allows system catalogs
13+ to be created and filled from scratch, whereas ordinary SQL commands
14+ require the catalogs to exist already.
1415 <acronym>BKI</acronym> files can therefore be used to create the
1516 database system in the first place. (And they are probably not
1617 useful for anything else.)
@@ -21,8 +22,9 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.12 2003/11/29 19:51:36 pgsql Exp $
2122 to do part of its job when creating a new database cluster. The
2223 input file used by <application>initdb</application> is created as
2324 part of building and installing <productname>PostgreSQL</productname>
24- by a program named <filename>genbki.sh</filename> from some
25- specially formatted C header files in the source tree. The created
25+ by a program named <filename>genbki.sh</filename>, which reads some
26+ specially formatted C header files in the <filename>src/include/catalog/</>
27+ directory of the source tree. The created
2628 <acronym>BKI</acronym> file is called <filename>postgres.bki</filename> and is
2729 normally installed in the
2830 <filename>share</filename> subdirectory of the installation tree.
@@ -40,9 +42,7 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.12 2003/11/29 19:51:36 pgsql Exp $
4042 This section describes how the <productname>PostgreSQL</productname>
4143 backend interprets <acronym>BKI</acronym> files. This description
4244 will be easier to understand if the <filename>postgres.bki</filename>
43- file is at hand as an example. You should also study the source
44- code of <application>initdb</application> to get an idea of how the
45- backend is invoked.
45+ file is at hand as an example.
4646 </para>
4747
4848 <para>
@@ -67,6 +67,61 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.12 2003/11/29 19:51:36 pgsql Exp $
6767 <title><acronym>BKI</acronym> Commands</title>
6868
6969 <variablelist>
70+ <varlistentry>
71+ <term>
72+ create
73+ <optional>bootstrap</optional>
74+ <optional>shared_relation</optional>
75+ <optional>without_oids</optional>
76+ <replaceable class="parameter">tablename</replaceable>
77+ (<replaceable class="parameter">name1</replaceable> =
78+ <replaceable class="parameter">type1</replaceable> <optional>,
79+ <replaceable class="parameter">name2</replaceable> = <replaceable
80+ class="parameter">type2</replaceable>, ...</optional>)
81+ </term>
82+
83+ <listitem>
84+ <para>
85+ Create a table named <replaceable
86+ class="parameter">tablename</replaceable> with the columns given
87+ in parentheses.
88+ </para>
89+
90+ <para>
91+ The following column types are supported directly by
92+ <filename>bootstrap.c</>: <type>bool</type>,
93+ <type>bytea</type>, <type>char</type> (1 byte),
94+ <type>name</type>, <type>int2</type>,
95+ <type>int4</type>, <type>regproc</type>, <type>regclass</type>,
96+ <type>regtype</type>, <type>text</type>,
97+ <type>oid</type>, <type>tid</type>, <type>xid</type>,
98+ <type>cid</type>, <type>int2vector</type>, <type>oidvector</type>,
99+ <type>_int4</type> (array), <type>_text</type> (array),
100+ <type>_aclitem</type> (array). Although it is possible to create
101+ tables containing columns of other types, this cannot be done until
102+ after <structname>pg_type</> has been created and filled with
103+ appropriate entries.
104+ </para>
105+
106+ <para>
107+ When <literal>bootstrap</> is specified,
108+ the table will only be created on disk; nothing is entered into
109+ <structname>pg_class</structname>,
110+ <structname>pg_attribute</structname>, etc, for it. Thus the
111+ table will not be accessible by ordinary SQL operations until
112+ such entries are made the hard way (with <literal>insert</>
113+ commands). This option is used for creating
114+ <structname>pg_class</structname> etc themselves.
115+ </para>
116+
117+ <para>
118+ The table is created as shared if <literal>shared_relation</> is
119+ specified.
120+ It will have OIDs unless <literal>without_oids</> is specified.
121+ </para>
122+ </listitem>
123+ </varlistentry>
124+
70125 <varlistentry>
71126 <term>
72127 open <replaceable class="parameter">tablename</replaceable>
@@ -98,51 +153,6 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.12 2003/11/29 19:51:36 pgsql Exp $
98153 </listitem>
99154 </varlistentry>
100155
101- <varlistentry>
102- <term>
103- create <replaceable class="parameter">tablename</replaceable>
104- (<replaceable class="parameter">name1</replaceable> =
105- <replaceable class="parameter">type1</replaceable> <optional>,
106- <replaceable class="parameter">name2</replaceable> = <replaceable
107- class="parameter">type2</replaceable>, ...</optional>)
108- </term>
109-
110- <listitem>
111- <para>
112- Create a table named <replaceable
113- class="parameter">tablename</replaceable> with the columns given
114- in parentheses.
115- </para>
116-
117- <para>
118- The <replaceable>type</replaceable> is not necessarily the data
119- type that the column will have in the SQL environment; that is
120- determined by the <structname>pg_attribute</structname> system
121- catalog. The type here is essentially only used to allocate
122- storage. The following types are allowed: <type>bool</type>,
123- <type>bytea</type>, <type>char</type> (1 byte),
124- <type>name</type>, <type>int2</type>, <type>int2vector</type>,
125- <type>int4</type>, <type>regproc</type>, <type>regclass</type>,
126- <type>regtype</type>, <type>text</type>,
127- <type>oid</type>, <type>tid</type>, <type>xid</type>,
128- <type>cid</type>, <type>oidvector</type>, <type>smgr</type>,
129- <type>_int4</type> (array), <type>_aclitem</type> (array).
130- Array types can also be indicated by writing
131- <literal>[]</literal> after the name of the element type.
132- </para>
133-
134- <note>
135- <para>
136- The table will only be created on disk, it will not
137- automatically be registered in the system catalogs and will
138- therefore not be accessible unless appropriate rows are
139- inserted in <structname>pg_class</structname>,
140- <structname>pg_attribute</structname>, etc.
141- </para>
142- </note>
143- </listitem>
144- </varlistentry>
145-
146156 <varlistentry>
147157 <term>
148158 insert <optional>OID = <replaceable class="parameter">oid_value</replaceable></optional> (<replaceable class="parameter">value1</replaceable> <replaceable class="parameter">value2</replaceable> ...)
@@ -190,6 +200,8 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.12 2003/11/29 19:51:36 pgsql Exp $
190200 classes to use are <replaceable
191201 class="parameter">opclass1</replaceable>, <replaceable
192202 class="parameter">opclass2</replaceable> etc., respectively.
203+ The index file is created and appropriate catalog entries are
204+ made for it, but the index contents are not initialized by this command.
193205 </para>
194206 </listitem>
195207 </varlistentry>
@@ -199,7 +211,7 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.12 2003/11/29 19:51:36 pgsql Exp $
199211
200212 <listitem>
201213 <para>
202- Build the indices that have previously been declared.
214+ Fill in the indices that have previously been declared.
203215 </para>
204216 </listitem>
205217 </varlistentry>
@@ -212,7 +224,7 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.12 2003/11/29 19:51:36 pgsql Exp $
212224
213225 <para>
214226 The following sequence of commands will create the
215- <literal>test_table</literal>table with the two columns
227+ table <literal>test_table</literal> with two columns
216228 <literal>cola</literal> and <literal>colb</literal> of type
217229 <type>int4</type> and <type>text</type>, respectively, and insert
218230 two rows into the table.