Re: GUC tables - use designated initializers

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: GUC tables - use designated initializers
Дата
Msg-id 3800142.1664295661@sss.pgh.pa.us
обсуждение исходный текст
Ответ на GUC tables - use designated initializers  (Peter Smith <smithpb2250@gmail.com>)
Ответы Re: GUC tables - use designated initializers  (Peter Smith <smithpb2250@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Nazir Bilal Yavuz
Дата:
Сообщение: Re: kerberos/001_auth test fails on arm CPU darwin
Следующее
От: John Morris
Дата:
Сообщение: Re: Temporary file access API