From 3dc820c43e427371b66d217f2bd5481fc9ef2e2d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 20 Sep 2018 15:14:46 -0400 Subject: Teach genbki.pl to auto-generate pg_type entries for array types. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This eliminates some more tedium in adding new catalog entries, specifically the need to set up an array type when adding a new built-in data type. Now it's sufficient to assign an OID for the array type and write it in an "array_type_oid" metadata field. You don't have to fill the base type's typarray link explicitly, either. No catversion bump since the contents of pg_type aren't changed. (Well, their order might be different, but that doesn't matter.) John Naylor, reviewed and whacked around a bit by Dagfinn Ilmari Mannsåker, and some more by me. Discussion: https://postgr.es/m/CAJVSVGVTb6m9pJF49b3SuA8J+T-THO9c0hxOmoyv-yGKh-FbNg@mail.gmail.com --- doc/src/sgml/bki.sgml | 52 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/bki.sgml b/doc/src/sgml/bki.sgml index e3ba73a9a8d..0fb309a1bd9 100644 --- a/doc/src/sgml/bki.sgml +++ b/doc/src/sgml/bki.sgml @@ -217,12 +217,14 @@ value pairs. The allowed keys are the names of the catalog's columns, plus the metadata keys oid, - oid_symbol, and descr. + oid_symbol, + array_type_oid, and descr. (The use of oid and oid_symbol - is described in - below. descr supplies a description string for - the object, which will be inserted - into pg_description + is described in below, + while array_type_oid is described in + . + descr supplies a description string for the object, + which will be inserted into pg_description or pg_shdescription as appropriate.) While the metadata keys are optional, the catalog's defined columns must all be provided, except when the catalog's .h @@ -282,8 +284,9 @@ Within each pair of curly braces, the metadata fields oid, oid_symbol, - and descr (if present) come first, in that - order, then the catalog's own fields appear in their defined order. + array_type_oid, and descr + (if present) come first, in that order, then the catalog's own + fields appear in their defined order. @@ -498,6 +501,41 @@ + + Automatic Creation of Array Types + + + Most scalar data types should have a corresponding array type (that is, + a standard varlena array type whose element type is the scalar type, and + which is referenced by the typarray field of + the scalar type's pg_type + entry). genbki.pl is able to generate + the pg_type entry for the array type + automatically in most cases. + + + + To use this facility, just write an array_type_oid + => nnnn metadata field in the + scalar type's pg_type entry, specifying the OID + to use for the array type. You may then omit + the typarray field, since it will be filled + automatically with that OID. + + + + The generated array type's name is the scalar type's name with an + underscore prepended. The array entry's other fields are filled from + BKI_ARRAY_DEFAULT(value) + annotations in pg_type.h, or if there isn't one, + copied from the scalar type. (There's also a special case + for typalign.) Then + the typelem + and typarray fields of the two entries are + set to cross-reference each other. + + + Recipes for Editing Data Files -- cgit v1.2.3