Re: BUG #18568: BUG: Result wrong when do group by on partition table!

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: 1105066510(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18568: BUG: Result wrong when do group by on partition table!
Date: 2024-10-23 10:42:40
Message-ID: CAHewXN=vbRDiEtdtC0WxbFNyyAUdys=_0Umh3EJ_xhKU-shd5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tender Wang <tndrwang(at)gmail(dot)com> 于2024年10月23日周三 14:25写道:

>
>
> And I found some codes only use equal not check the collation, for
> example, in match_expr_to_partition_keys():
> if (equal(lfirst(lc), expr))
> lfirst(lc) is partkeys.
> I thinks other codes assume that the collation of partexprs in RelOptInfo
> is same with pg_partitioned_table. But it is not.
>
>
It seems that only partition pruning logic not only does equal() but also
checks the collation match. I find below codes in
match_clause_to_partition_key():

/*
* Partition key match also requires collation match. There may be
* multiple partkeys with the same expression but different
* collations, so failure is NOMATCH.
*/
if (!PartCollMatchesExprColl(partcoll, opclause->inputcollid))
return PARTCLAUSE_NOMATCH;

Others only do equal(), as far as I know.

I tried the patch I provided in [1], and the regression test cases all
passed.

[1]
https://www.postgresql.org/message-id/CAHewXNnKLrZYG4iqaYw%3DuB3XWRrYRZHo7VtcMsbUEbdbajQg2Q%40mail.gmail.com

--
Thanks,
Tender Wang

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Maxim Orlov 2024-10-23 13:31:32 Re: BUG #18658: Assert in SerialAdd() due to race condition
Previous Message Hayato Kuroda (Fujitsu) 2024-10-23 10:12:43 RE: BUG #18644: ALTER PUBLICATION ... SET (publish_via_partition_root) wrong/undocumented behavior.