Re: Improve readability by using designated initializers when possible

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Japin Li <japinli@hotmail.com>, jian he <jian.universality@gmail.com>, Jelte Fennema-Nio <postgres@jeltef.nl>, Jeff Davis <pgsql@j-davis.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>, pgsql-hackers@lists.postgresql.org
Date: 2024-03-01T09:26:45Z
Lists: pgsql-hackers

Attachments

On 01.03.24 05:08, Michael Paquier wrote:
> On Thu, Feb 29, 2024 at 12:41:38PM +0100, Peter Eisentraut wrote:
>> On 27.02.24 08:57, Alvaro Herrera wrote:
>>> On 2024-Feb-27, Michael Paquier wrote:
>>>> These would cause compilation failures.  Saying that, this is a very
>>>> nice cleanup, so I've fixed these and applied the patch after checking
>>>> that the one-one replacements were correct.
>>>
>>> Oh, I thought we were going to get rid of ObjectClass altogether -- I
>>> mean, have getObjectClass() return ObjectAddress->classId, and then
>>> define the OCLASS values for each catalog OID [... tries to ...]  But
>>> this(*) doesn't work for two reasons:
>>
>> I have long wondered what the point of ObjectClass is.  I find the extra
>> layer of redirection, which is used only in small parts of the code, and the
>> similarity to ObjectType confusing.  I happened to have a draft patch for
>> its removal lying around, so I'll show it here, rebased over what has
>> already been done in this thread.
> 
> The elimination of getObjectClass() seems like a good end goal IMO, so
> the direction of the patch is interesting.  Would object_type_map and
> ObjectProperty follow the same idea of relying on the catalogs OID
> instead of the OBJECT_*?
> 
> Note that there are still two dependencies to getObjectClass() in
> event_trigger.c and dependency.c.

Oops, there was a second commit in my branch that I neglected to send 
in.  Here is my complete patch set.

Commits

  1. Remove ObjectClass type

  2. Simplify pg_enc2gettext_tbl[] with C99-designated initializer syntax

  3. Use C99-designated initializer syntax for arrays related to encodings

  4. Remove last NULL element in config_group_names[]

  5. Use C99-designated initializer syntax for more arrays

  6. Remove unnecessary array object_classes[] in dependency.c

  7. Add trailing commas to enum definitions