Re: WIP: a way forward on bootstrap data
От | John Naylor |
---|---|
Тема | Re: WIP: a way forward on bootstrap data |
Дата | |
Msg-id | CAJVSVGVzrqsDFvy4hHNBq0qE8i36kSfVSdiT3D2SgzowniLUHA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: WIP: a way forward on bootstrap data (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: WIP: a way forward on bootstrap data
|
Список | pgsql-hackers |
On 4/6/18, Tom Lane <tgl@sss.pgh.pa.us> wrote: > I experimented with converting all frontend code to include just the > catalog/pg_foo_d.h files instead of catalog/pg_foo.h, as per the > proposed new policy. I soon found that we'd overlooked one thing: > some clients expect to see the relation OID macros, eg > LargeObjectRelationId. Attached is a patch that changes things around > so that those appear in the _d files instead of the master files. [...] > Some of the CATALOG lines spill well past 80 characters with this, > although many of the affected ones already were overlength, eg > > -#define DatabaseRelationId 1262 > -#define DatabaseRelation_Rowtype_Id 1248 > - > -CATALOG(pg_database,1262) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248) > BKI_SCHEMA_MACRO > +CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION > BKI_ROWTYPE_OID(1248,DatabaseRelation_Rowtype_Id) BKI_SCHEMA_MACRO [ to which I responded with an inadequate alternative ] Thinking about this some more, a way occurred to me to shorten the CATALOG lines while still treating all headers the same, and with very little code (Patch 0001). What we do is automate the use of 'RelationId' and 'Relation_Rowtype_Id' so that the CATALOG macro only needs the part pertaining to the table name, and the BKI_ROWTYPE_OID macro can go back to just having the OID, eg: CATALOG(pg_database,1262,Database) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248) BKI_SCHEMA_MACRO This is shorter, but not quite as short as before the conversion. If we really wanted to, we could also leave off the BKI_ prefix from the CATALOG options (Patch 0002), eg: CATALOG(pg_database,1262,Database) SHARED_RELATION ROWTYPE_OID(1248) SCHEMA_MACRO CATALOG itself lacks a prefix, and its options can only go in one place, so we'd lose some consistency but perhaps we don't lose any clarity. (This isn't true for the attribute-level options for nullability etc, which can appear all over the place.) Results below - number of CATALOG lines with more than 80 characters, and the longest line: grep -E '^CATALOG\(' src/include/catalog/pg_*.h | sed 's/.*://' | awk '{ print length, $0 }' | sort -n -r -- before conversion: 6 lines > 80 chars 105 CATALOG(pg_auth_members,1261) BKI_SHARED_RELATION BKI_WITHOUT_OIDS BKI_ROWTYPE_OID(2843) BKI_SCHEMA_MACRO -- after conversion: 14 lines > 80 chars 162 CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(4066,SharedSecLabelRelation_Rowtype_Id) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO -- with Patch 0001: 11 lines > 80 chars 118 CATALOG(pg_shseclabel,3592,SharedSecLabel) BKI_SHARED_RELATION BKI_ROWTYPE_OID(4066) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO -- with Patch 0002: 5 lines > 80 chars 102 CATALOG(pg_shseclabel,3592,SharedSecLabel) SHARED_RELATION ROWTYPE_OID(4066) WITHOUT_OIDS SCHEMA_MACRO -John Naylor
Вложения
В списке pgsql-hackers по дате отправления: