11<!--
2- $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
2+ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.16 2005/04/14 01:38:15 tgl Exp $
33 -->
44
55<chapter id="bki">
@@ -58,7 +58,7 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
5858 </para>
5959
6060 <para>
61- Lines starting witha <literal>#</literal> are ignored.
61+ Lines starting with <literal>#</literal> are ignored.
6262 </para>
6363
6464 </sect1>
@@ -69,11 +69,12 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
6969 <variablelist>
7070 <varlistentry>
7171 <term>
72- create
73- <optional>bootstrap</optional>
74- <optional>shared_relation</optional>
75- <optional>without_oids</optional>
72+ <literal> create</>
73+ <optional><literal> bootstrap</> </optional>
74+ <optional><literal> shared_relation</> </optional>
75+ <optional><literal> without_oids</> </optional>
7676 <replaceable class="parameter">tablename</replaceable>
77+ <replaceable class="parameter">tableoid</replaceable>
7778 (<replaceable class="parameter">name1</replaceable> =
7879 <replaceable class="parameter">type1</replaceable> <optional>,
7980 <replaceable class="parameter">name2</replaceable> = <replaceable
@@ -83,8 +84,9 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
8384 <listitem>
8485 <para>
8586 Create a table named <replaceable
86- class="parameter">tablename</replaceable> with the columns given
87- in parentheses.
87+ class="parameter">tablename</replaceable>, and having the OID
88+ <replaceable class="parameter">tableoid</replaceable>,
89+ with the columns given in parentheses.
8890 </para>
8991
9092 <para>
@@ -101,7 +103,9 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
101103 <type>_aclitem</type> (array). Although it is possible to create
102104 tables containing columns of other types, this cannot be done until
103105 after <structname>pg_type</> has been created and filled with
104- appropriate entries.
106+ appropriate entries. (That effectively means that only these
107+ column types can be used in bootstrapped tables, but non-bootstrap
108+ catalogs can contain any built-in type.)
105109 </para>
106110
107111 <para>
@@ -125,38 +129,34 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
125129
126130 <varlistentry>
127131 <term>
128- open <replaceable class="parameter">tablename</replaceable>
132+ <literal> open</> <replaceable class="parameter">tablename</replaceable>
129133 </term>
130134
131135 <listitem>
132136 <para>
133- Open the tablecalled
137+ Open the tablenamed
134138 <replaceable class="parameter">tablename</replaceable>
135- forfurther manipulation .
139+ forinsertion of data. Any currently open table is closed .
136140 </para>
137141 </listitem>
138142 </varlistentry>
139143
140144 <varlistentry>
141145 <term>
142- close <optional><replaceable class="parameter">tablename</replaceable></optional>
146+ <literal> close</> <optional><replaceable class="parameter">tablename</replaceable></optional>
143147 </term>
144148
145149 <listitem>
146150 <para>
147- Close the open table called <replaceable
148- class="parameter">tablename</replaceable>. It is an error if
149- <replaceable class="parameter">tablename</replaceable> is not
150- already opened. If no <replaceable
151- class="parameter">tablename</replaceable> is given, then the
152- currently open table is closed.
151+ Close the open table. The name of the table can be given as a
152+ cross-check, but this is not required.
153153 </para>
154154 </listitem>
155155 </varlistentry>
156156
157157 <varlistentry>
158158 <term>
159- insert <optional>OID = <replaceable class="parameter">oid_value</replaceable></optional>(< replaceable class="parameter">value1</replaceable> <replaceable class="parameter">value2</replaceable> ...)
159+ <literal> insert</> <optional><literal> OID =</> <replaceable class="parameter">oid_value</replaceable></optional><literal>(</> < replaceable class="parameter">value1</replaceable> <replaceable class="parameter">value2</replaceable> ... <literal>)</>
160160 </term>
161161
162162 <listitem>
@@ -181,19 +181,23 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
181181
182182 <varlistentry>
183183 <term>
184- declare <optional>unique</optional> index <replaceable
185- class="parameter">indexname</replaceable> on <replaceable
186- class="parameter">tablename</replaceable> using <replaceable
187- class="parameter">amname</replaceable> (<replaceable
188- class="parameter">opclass1</replaceable> <replaceable
189- class="parameter">name1</replaceable> <optional>, ...</optional>)
184+ <literal>declare</> <optional><literal>unique</></optional>
185+ <literal>index</> <replaceable class="parameter">indexname</replaceable>
186+ <replaceable class="parameter">indexoid</replaceable>
187+ <literal>on</> <replaceable class="parameter">tablename</replaceable>
188+ <literal>using</> <replaceable class="parameter">amname</replaceable>
189+ <literal>(</> <replaceable class="parameter">opclass1</replaceable>
190+ <replaceable class="parameter">name1</replaceable>
191+ <optional>, ...</optional> <literal>)</>
190192 </term>
191193
192194 <listitem>
193195 <para>
194196 Create an index named <replaceable
195- class="parameter">indexname</replaceable> on the table named
196- <replaceable class="parameter">tablename</replaceable> using the
197+ class="parameter">indexname</replaceable>, having OID
198+ <replaceable class="parameter">indexoid</replaceable>,
199+ on the table named
200+ <replaceable class="parameter">tablename</replaceable>, using the
197201 <replaceable class="parameter">amname</replaceable> access
198202 method. The fields to index are called <replaceable
199203 class="parameter">name1</replaceable>, <replaceable
@@ -208,7 +212,7 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
208212 </varlistentry>
209213
210214 <varlistentry>
211- <term>build indices</term>
215+ <term><literal> build indices</> </term>
212216
213217 <listitem>
214218 <para>
@@ -220,17 +224,97 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.15 2005/04/13 18:54:55 tgl Exp $
220224
221225 </sect1>
222226
227+ <sect1 id="bki-structure">
228+ <title>Structure of the Bootstrap <acronym>BKI</acronym> File</title>
229+
230+ <para>
231+ The <literal>open</> command cannot be used until the tables it uses
232+ exist and have entries for the table that is to be opened.
233+ (These minimum tables are <structname>pg_class</>,
234+ <structname>pg_attribute</>, <structname>pg_proc</>, and
235+ <structname>pg_type</>.) To allow those tables themselves to be filled,
236+ <literal>create</> with the <literal>bootstrap</> option implicitly opens
237+ the created table for data insertion.
238+ </para>
239+
240+ <para>
241+ Thus, the structure of the <filename>postgres.bki</filename> file has to
242+ be:
243+ <orderedlist>
244+ <listitem>
245+ <para>
246+ <literal>create bootstrap</> one of the critical tables
247+ </para>
248+ </listitem>
249+ <listitem>
250+ <para>
251+ <literal>insert</> data describing at least the critical tables
252+ </para>
253+ </listitem>
254+ <listitem>
255+ <para>
256+ <literal>close</>
257+ </para>
258+ </listitem>
259+ <listitem>
260+ <para>
261+ Repeat for the other critical tables.
262+ </para>
263+ </listitem>
264+ <listitem>
265+ <para>
266+ <literal>create</> (without <literal>bootstrap</>) a noncritical table
267+ </para>
268+ </listitem>
269+ <listitem>
270+ <para>
271+ <literal>open</>
272+ </para>
273+ </listitem>
274+ <listitem>
275+ <para>
276+ <literal>insert</> desired data
277+ </para>
278+ </listitem>
279+ <listitem>
280+ <para>
281+ <literal>close</>
282+ </para>
283+ </listitem>
284+ <listitem>
285+ <para>
286+ Repeat for the other noncritical tables.
287+ </para>
288+ </listitem>
289+ <listitem>
290+ <para>
291+ Define indexes.
292+ </para>
293+ </listitem>
294+ <listitem>
295+ <para>
296+ <literal>build indices</>
297+ </para>
298+ </listitem>
299+ </orderedlist>
300+ </para>
301+
302+ <para>
303+ There are doubtless other, undocumented ordering dependencies.
304+ </para>
305+ </sect1>
306+
223307 <sect1 id="bki-example">
224308 <title>Example</title>
225309
226310 <para>
227311 The following sequence of commands will create the
228- table <literal>test_table</literal> with two columns
312+ table <literal>test_table</literal> withOID 420, having two columns
229313 <literal>cola</literal> and <literal>colb</literal> of type
230314 <type>int4</type> and <type>text</type>, respectively, and insert
231315 two rows into the table.
232316<programlisting>
233- create test_table (cola = int4, colb = text)
317+ create test_table420 (cola = int4, colb = text)
234318open test_table
235319insert OID=421 ( 1 "value1" )
236320insert OID=422 ( 2 _null_ )