Re: Enable partitionwise join for partition keys wrapped by RelabelType

From: "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com>
To: "Jan Nidzwetzki" <jan(at)planetscale(dot)com>, "jian he" <jian(dot)universality(at)gmail(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Enable partitionwise join for partition keys wrapped by RelabelType
Date: 2026-09-01 19:37:57
Message-ID: DL48F7MNP7V4.151HTVSU1WB3O@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue Sep 1, 2026 at 11:01 AM -03, Jan Nidzwetzki wrote:
> I think I found a problem in patch 4. group_by_has_partkey() has no
> opfamily check, so stripping the RelabelType from the partition key side
> means the grouping uses the argument type's equality. In contrast, the
> partitioning uses the result type's.

You're right, and thanks for catching it.

My reasoning when I wrote that patch was that the collation was still
validated separately, which is true but beside the point: collation is
only one dimension of equality semantics, and the type's operator family
is the other. Before the strip, requiring the two expressions to be
structurally equal implicitly guaranteed they had the same type and
therefore the same equality semantics. Stripping the RelabelType removed
that guarantee without replacing it.

> In patch 4, I added an op_in_opfamily() check in group_by_has_partkey().
> [...]
> What do you think?
>

I think it's right, the citext case now plans as partial aggregation and
returns the correct single group. So v8 looks good to me.

--
Matheus Alcantara
EDB: https://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Floris Van Nee 2026-09-01 19:53:05 OOM kill during planning - pg_terminate_backend is ignored
Previous Message Nathan Bossart 2026-09-01 19:23:58 Re: Speed up COPY FROM text/CSV parsing using SIMD