|
217 | 217 | <replaceable>value</replaceable> pairs. The
|
218 | 218 | allowed <replaceable>key</replaceable>s are the names of the catalog's
|
219 | 219 | columns, plus the metadata keys <literal>oid</literal>,
|
220 |
| - <literal>oid_symbol</literal>, and <literal>descr</literal>. |
| 220 | + <literal>oid_symbol</literal>, |
| 221 | + <literal>array_type_oid</literal>, and <literal>descr</literal>. |
221 | 222 | (The use of <literal>oid</literal> and <literal>oid_symbol</literal>
|
222 |
| - is described in <xref linkend="system-catalog-oid-assignment"/> |
223 |
| - below. <literal>descr</literal> supplies a description string for |
224 |
| - the object, which will be inserted |
225 |
| - into <structname>pg_description</structname> |
| 223 | + is described in <xref linkend="system-catalog-oid-assignment"/> below, |
| 224 | + while <literal>array_type_oid</literal> is described in |
| 225 | + <xref linkend="system-catalog-auto-array-types"/>. |
| 226 | + <literal>descr</literal> supplies a description string for the object, |
| 227 | + which will be inserted into <structname>pg_description</structname> |
226 | 228 | or <structname>pg_shdescription</structname> as appropriate.)
|
227 | 229 | While the metadata keys are optional, the catalog's defined columns
|
228 | 230 | must all be provided, except when the catalog's <literal>.h</literal>
|
|
282 | 284 | <para>
|
283 | 285 | Within each pair of curly braces, the metadata
|
284 | 286 | fields <literal>oid</literal>, <literal>oid_symbol</literal>,
|
285 |
| - and <literal>descr</literal> (if present) come first, in that |
286 |
| - order, then the catalog's own fields appear in their defined order. |
| 287 | + <literal>array_type_oid</literal>, and <literal>descr</literal> |
| 288 | + (if present) come first, in that order, then the catalog's own |
| 289 | + fields appear in their defined order. |
287 | 290 | </para>
|
288 | 291 | </listitem>
|
289 | 292 |
|
|
498 | 501 | </para>
|
499 | 502 | </sect2>
|
500 | 503 |
|
| 504 | + <sect2 id="system-catalog-auto-array-types"> |
| 505 | + <title>Automatic Creation of Array Types</title> |
| 506 | + |
| 507 | + <para> |
| 508 | + Most scalar data types should have a corresponding array type (that is, |
| 509 | + a standard varlena array type whose element type is the scalar type, and |
| 510 | + which is referenced by the <structfield>typarray</structfield> field of |
| 511 | + the scalar type's <structname>pg_type</structname> |
| 512 | + entry). <filename>genbki.pl</filename> is able to generate |
| 513 | + the <structname>pg_type</structname> entry for the array type |
| 514 | + automatically in most cases. |
| 515 | + </para> |
| 516 | + |
| 517 | + <para> |
| 518 | + To use this facility, just write an <literal>array_type_oid |
| 519 | + => <replaceable>nnnn</replaceable></literal> metadata field in the |
| 520 | + scalar type's <structname>pg_type</structname> entry, specifying the OID |
| 521 | + to use for the array type. You may then omit |
| 522 | + the <structfield>typarray</structfield> field, since it will be filled |
| 523 | + automatically with that OID. |
| 524 | + </para> |
| 525 | + |
| 526 | + <para> |
| 527 | + The generated array type's name is the scalar type's name with an |
| 528 | + underscore prepended. The array entry's other fields are filled from |
| 529 | + <literal>BKI_ARRAY_DEFAULT(<replaceable>value</replaceable>)</literal> |
| 530 | + annotations in <filename>pg_type.h</filename>, or if there isn't one, |
| 531 | + copied from the scalar type. (There's also a special case |
| 532 | + for <structfield>typalign</structfield>.) Then |
| 533 | + the <structfield>typelem</structfield> |
| 534 | + and <structfield>typarray</structfield> fields of the two entries are |
| 535 | + set to cross-reference each other. |
| 536 | + </para> |
| 537 | + </sect2> |
| 538 | + |
501 | 539 | <sect2 id="system-catalog-recipes">
|
502 | 540 | <title>Recipes for Editing Data Files</title>
|
503 | 541 |
|
|
0 commit comments