Re: Array initialisation notation in syscache.c

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Array initialisation notation in syscache.c
Date: 2022-12-21 00:33:20
Message-ID: CA+hUKGKoPH31RBTAqq9MaTSocc2C28b9yFd9CJeYNrekc+oKgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 21, 2022 at 12:05 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
> > Do you think this is better?
>
> I'm not at all on board with adding runtime overhead to
> save maintaining the nkeys fields.

I don't see how to do it at compile time without getting the
preprocessor involved. What do you think about this version?

[ATTNUM] = {
AttributeRelationId,
AttributeRelidNumIndexId,
KEY(Anum_pg_attribute_attrelid,
Anum_pg_attribute_attnum),
128
},

> I'm kind of neutral on using "[N] = " as a substitute for
> ordering the entries correctly. While that does remove
> one failure mode, it seems like it adds another (ie
> failure to provide an entry at all would be masked).

It fails very early in testing if you do that. Admittedly, the
assertion is hard to understand, but if I add a new assertion close to
the cause with a new comment to say what you did wrong, I think that
should be good enough?

Attachment Content-Type Size
v2-0001-Improve-notation-of-cacheinfo-table-in-syscache.c.patch text/x-patch 23.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2022-12-21 00:51:34 Re: Small miscellaneus fixes (Part II)
Previous Message Ranier Vilela 2022-12-21 00:14:48 Avoid lost result of recursion (src/backend/optimizer/util/inherit.c)