Andrew Dunstan <and...@dunslane.net> writes: > On 11/13/2016 11:11 AM, Tom Lane wrote: >> 1. Are we going to try to keep these things in the .h files, or split >> them out? I'd like to get them out, as that eliminates both the need >> to keep the things looking like macro calls, and the need for the data >> within the macro call to be at least minimally parsable as C.
> That would work fine for pg_proc.h, less so for pg_type.h where we have > a whole lot of > #define FOOOID nn > directives in among the data lines. Moving these somewhere remote from > the catalog lines they relate to seems like quite a bad idea. We certainly don't want multiple files to be sources of truth for that. What I was anticipating is that those #define's would also be generated from the same input files, much as fmgroids.h is handled today. We could imagine driving the creation of a macro off an additional, optional field in the data entries, say "macro=FOOOID", if we want only selected entries to have #defines. Or we could do like we do with pg_proc.h and generate macros for everything according to some fixed naming rule. I could see approaching pg_type that way, but am less excited about pg_operator, pg_opclass, etc, where we only need macros for a small fraction of the entries. >> 2. Andrew's example above implies some sort of mapping between the >> keywords and the actual column names (or at least column positions). >> Where and how is that specified? > There are several possibilities. The one I was leaning towards was to > parse out the Anum_pg_foo_* definitions. I'm okay with that if the field labels used in the data entries are to be exactly the same as the column names. Your example showed abbreviated names (omitting "pro"), which is something I doubt we want to try to hard-wire a rule for. Also, if we are going to abbreviate at all, I think it might be useful to abbreviate *a lot*, say like "v" for "provolatile", and that would be something that ought to be set up with some explicit manually-provided declarations. >> 3. Also where are we going to provide the per-column default values? >> How does the converter script know which columns to convert to type oids, >> proc oids, etc? Is it going to do any data validation beyond that, and >> if so on what basis? > a) something like DATA_DEFAULTS( foo=bar ); > b) something like DATA_TYPECONV ( rettype argtypes allargtypes ); I'm thinking a bit about per-column declarations in the input file, along the line of this for provolatile: declare v col=15 type=char default='v' Some of those items could be gotten out of pg_proc.h, but not all. I guess a second alternative would be to add the missing info to pg_proc.h and have the conversion script parse it out of there. >> I think we want to do them all. pg_proc.h is actually one of the easier >> catalogs to work on presently, IMO, because the only kind of >> cross-references it has are type OIDs. Things like pg_amop are a mess. >> And I really don't want to be dealing with multiple notations for catalog >> data. Also I think this will be subject to Polya's paradox: designing a >> general solution will be easier and cleaner than a hack that works only >> for one catalog. > I don't know that we need to handle everything at once, as long as the > solution is sufficiently general. Well, we could convert the catalogs one at a time if that seems useful, but I don't want to be rewriting the bki-generation script repeatedly. regards, tom lane -- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers