1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-27 07:42:10 +03:00

Disallow partitionwise join when collations don't match

If the collation of any join key column doesn’t match the collation of
the corresponding partition key, partitionwise joins can yield incorrect
results. For example, rows that would match under the join key collation
might be located in different partitions due to the partitioning
collation. In such cases, a partitionwise join would yield different
results from a non-partitionwise join, so disallow it in such cases.

Reported-by: Tender Wang <tndrwang@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Reviewed-by: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com
Backpatch-through: 12
This commit is contained in:
Amit Langote
2024-11-08 16:30:22 +09:00
parent 0a620659c5
commit 33040b1715
3 changed files with 144 additions and 0 deletions

View File

@@ -1810,6 +1810,10 @@ have_partkey_equi_join(RelOptInfo *joinrel,
if (ipk1 != ipk2)
continue;
/* Reject if the partition key collation differs from the clause's. */
if (rel1->part_scheme->partcollation[ipk1] != opexpr->inputcollid)
return false;
/*
* The clause allows partitionwise join only if it uses the same
* operator family as that specified by the partition key.