Re: using SysCacheGetAttrNotNull in place of heap_getattr

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: using SysCacheGetAttrNotNull in place of heap_getattr
Date: 2023-08-23 17:04:26
Message-ID: 3366977.1692810266@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> I was about to push a quick patch to replace the use of heap_getattr()
> in get_primary_key_attnos() with SysCacheGetAttrNotNull(), because that
> makes the code a few lines shorter and AFAICS there's no downside.
> However, I realized that the commit that added the function
> (d435f15fff3c) did not make any such change at all -- it only changed
> SysCacheGetAttr calls to use the new function, but no heap_getattr.
> And we don't seem to have added such calls after.

Seems to me it'd be more consistent to invent a wrapper function
heap_getattr_notnull() that adds the same sort of error check,
instead of abusing the syscache function as you suggest. For one
thing, then the functionality could be used whether there's a
suitable syscache or not.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-08-23 17:08:18 Re: cataloguing NOT NULL constraints
Previous Message Jeff Davis 2023-08-23 16:36:01 Re: PG 16 draft release notes ready