Re: GUC tables - use designated initializers - Mailing list pgsql-hackers

From Tom Lane
Subject Re: GUC tables - use designated initializers
Date
Msg-id 3800142.1664295661@sss.pgh.pa.us
Whole thread Raw
In response to GUC tables - use designated initializers  (Peter Smith <smithpb2250@gmail.com>)
Responses Re: GUC tables - use designated initializers
List pgsql-hackers
Peter Smith <smithpb2250@gmail.com> writes:
> Enums index a number of the GUC tables. This all relies on the
> elements being carefully arranged to be in the same order as those
> enums. There are comments to say what enum index belongs to each table
> element.
> But why not use designated initializers to enforce what the comments
> are hoping for?

Interesting proposal, but it's not clear to me that this solution makes
the code more bulletproof rather than less so.  Yeah, you removed the
order dependency, but the other concern here is that the array gets
updated at all when adding a new enum entry.  This method seems like
it'd help disguise such an oversight.  In particular, the adjacent
StaticAssertDecls about the array lengths are testing something different
than they used to, and I fear they lost some of their power.  Can we
improve those checks so they'd catch a missing entry again?

> Furthermore, with this change, now the GUC table elements are able to
> be rearranged into any different order - eg alphabetical - if that
> would be useful (my patch does not do this).

If anything, that's an anti-feature IMV.  I quite dislike code where
the same set of items are dealt with in randomly different orders
in different places.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Nazir Bilal Yavuz
Date:
Subject: Re: kerberos/001_auth test fails on arm CPU darwin
Next
From: John Morris
Date:
Subject: Re: Temporary file access API