Re: PartitionKeyData->partattrs, refactor some 0 to InvalidAttrNumber

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PartitionKeyData->partattrs, refactor some 0 to InvalidAttrNumber
Date: 2025-11-14 16:58:59
Message-ID: aRdf07a1bCT3l6Sr@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-11-14 17:05:13 enhance wraparound warnings
Previous Message Rafia Sabih 2025-11-14 16:06:08 Re: Bypassing cursors in postgres_fdw to enable parallel plans