Re: PartitionKeyData->partattrs, refactor some 0 to InvalidAttrNumber - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: PartitionKeyData->partattrs, refactor some 0 to InvalidAttrNumber
Date
Msg-id aRdf07a1bCT3l6Sr@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to PartitionKeyData->partattrs, refactor some 0 to InvalidAttrNumber  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
Hi,

On Fri, Nov 14, 2025 at 11:47:35PM +0800, jian he wrote:
> hi.
> 
> if PartitionKeyData->partattrs is 0, then it means that partition key is
> expression, else it's column reference.
> 
> we can change from
> if (key->partattrs[i] == 0)
> to

yes, I think that makes sense to not compare an AttrNumber type to 0, but...

> if (key->partattrs[i] == InvalidAttrNumber)

I think that we should make use of AttributeNumberIsValid() instead. Same
spirit as we've done in a2b02293bc6.

FWIW, I'm looking at the Oid/OidIsValid() cases currently (writing a coccinelle
script).

I can look at the AttrNumber/AttributeNumberIsValid() cases after (that should be
as easy as changing Oid to AttrNumber and OidIsValid() to AttributeNumberIsValid()
in the coccinelle script), unless you want to take care of the AttrNumber case?

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Rafia Sabih
Date:
Subject: Re: Bypassing cursors in postgres_fdw to enable parallel plans
Next
From: Nathan Bossart
Date:
Subject: enhance wraparound warnings