pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Disallow partitionwise grouping when collations don't match 7+ messages / 1 participants [nested] [flat]
* pgsql: Disallow partitionwise grouping when collations don't match @ 2024-11-08 07:14 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Amit Langote @ 2024-11-08 07:14 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in different partitions under the partitioning collation. In such cases, full partitionwise grouping would produce results that differ from those without partitionwise grouping, so disallowed that. Partial partitionwise aggregation is still allowed, as the Finalize step reconciles partition-level aggregates with grouping requirements across all partitions, ensuring that the final output remains consistent. This commit also fixes group_by_has_partkey() by ensuring the RelabelType node is stripped from grouping expressions when matching them to partition key expressions to avoid false mismatches. Bug: #18568 Reported-by: Webbo Han <1105066510@qq.com> Author: Webbo Han <1105066510@qq.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/18568-2a9afb6b9f7e6ed3@postgresql.org Discussion: https://postgr.es/m/tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.com Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com Backpatch-through: 12 Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/46d9be5efb1a36328743d07e456cac5a1a40ec70 Modified Files -------------- src/backend/optimizer/plan/planner.c | 44 ++++++++++--- src/test/regress/expected/collate.icu.utf8.out | 90 ++++++++++++++++++++++++++ src/test/regress/sql/collate.icu.utf8.sql | 37 +++++++++++ 3 files changed, 163 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Disallow partitionwise grouping when collations don't match @ 2024-11-08 07:14 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Amit Langote @ 2024-11-08 07:14 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in different partitions under the partitioning collation. In such cases, full partitionwise grouping would produce results that differ from those without partitionwise grouping, so disallowed that. Partial partitionwise aggregation is still allowed, as the Finalize step reconciles partition-level aggregates with grouping requirements across all partitions, ensuring that the final output remains consistent. This commit also fixes group_by_has_partkey() by ensuring the RelabelType node is stripped from grouping expressions when matching them to partition key expressions to avoid false mismatches. Bug: #18568 Reported-by: Webbo Han <1105066510@qq.com> Author: Webbo Han <1105066510@qq.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/18568-2a9afb6b9f7e6ed3@postgresql.org Discussion: https://postgr.es/m/tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.com Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com Backpatch-through: 12 Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ff65f695c0d322365a7b6f2571e232197d962a91 Modified Files -------------- src/backend/optimizer/plan/planner.c | 44 ++++++++++--- src/test/regress/expected/collate.icu.utf8.out | 90 ++++++++++++++++++++++++++ src/test/regress/sql/collate.icu.utf8.sql | 37 +++++++++++ 3 files changed, 163 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Disallow partitionwise grouping when collations don't match @ 2024-11-08 07:14 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Amit Langote @ 2024-11-08 07:14 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in different partitions under the partitioning collation. In such cases, full partitionwise grouping would produce results that differ from those without partitionwise grouping, so disallowed that. Partial partitionwise aggregation is still allowed, as the Finalize step reconciles partition-level aggregates with grouping requirements across all partitions, ensuring that the final output remains consistent. This commit also fixes group_by_has_partkey() by ensuring the RelabelType node is stripped from grouping expressions when matching them to partition key expressions to avoid false mismatches. Bug: #18568 Reported-by: Webbo Han <1105066510@qq.com> Author: Webbo Han <1105066510@qq.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/18568-2a9afb6b9f7e6ed3@postgresql.org Discussion: https://postgr.es/m/tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.com Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com Backpatch-through: 12 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/96f9b29a3e1ea3dd58e728814bf630d40ff77caa Modified Files -------------- src/backend/optimizer/plan/planner.c | 44 ++++++++++--- src/test/regress/expected/collate.icu.utf8.out | 90 ++++++++++++++++++++++++++ src/test/regress/sql/collate.icu.utf8.sql | 37 +++++++++++ 3 files changed, 163 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Disallow partitionwise grouping when collations don't match @ 2024-11-08 07:14 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Amit Langote @ 2024-11-08 07:14 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in different partitions under the partitioning collation. In such cases, full partitionwise grouping would produce results that differ from those without partitionwise grouping, so disallowed that. Partial partitionwise aggregation is still allowed, as the Finalize step reconciles partition-level aggregates with grouping requirements across all partitions, ensuring that the final output remains consistent. This commit also fixes group_by_has_partkey() by ensuring the RelabelType node is stripped from grouping expressions when matching them to partition key expressions to avoid false mismatches. Bug: #18568 Reported-by: Webbo Han <1105066510@qq.com> Author: Webbo Han <1105066510@qq.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/18568-2a9afb6b9f7e6ed3@postgresql.org Discussion: https://postgr.es/m/tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.com Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com Backpatch-through: 12 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0a620659c549f05881800fddd1859f3e373dd9cf Modified Files -------------- src/backend/optimizer/plan/planner.c | 44 ++++++++++--- src/test/regress/expected/collate.icu.utf8.out | 90 ++++++++++++++++++++++++++ src/test/regress/sql/collate.icu.utf8.sql | 37 +++++++++++ 3 files changed, 163 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Disallow partitionwise grouping when collations don't match @ 2024-11-08 07:15 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Amit Langote @ 2024-11-08 07:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in different partitions under the partitioning collation. In such cases, full partitionwise grouping would produce results that differ from those without partitionwise grouping, so disallowed that. Partial partitionwise aggregation is still allowed, as the Finalize step reconciles partition-level aggregates with grouping requirements across all partitions, ensuring that the final output remains consistent. This commit also fixes group_by_has_partkey() by ensuring the RelabelType node is stripped from grouping expressions when matching them to partition key expressions to avoid false mismatches. Bug: #18568 Reported-by: Webbo Han <1105066510@qq.com> Author: Webbo Han <1105066510@qq.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/18568-2a9afb6b9f7e6ed3@postgresql.org Discussion: https://postgr.es/m/tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.com Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com Backpatch-through: 12 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/dd2f8ebee221f8c2a8bcdd71be836f1482f17310 Modified Files -------------- src/backend/optimizer/plan/planner.c | 44 ++++++++++--- src/test/regress/expected/collate.icu.utf8.out | 90 ++++++++++++++++++++++++++ src/test/regress/sql/collate.icu.utf8.sql | 37 +++++++++++ 3 files changed, 163 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Disallow partitionwise grouping when collations don't match @ 2024-11-08 07:15 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Amit Langote @ 2024-11-08 07:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in different partitions under the partitioning collation. In such cases, full partitionwise grouping would produce results that differ from those without partitionwise grouping, so disallowed that. Partial partitionwise aggregation is still allowed, as the Finalize step reconciles partition-level aggregates with grouping requirements across all partitions, ensuring that the final output remains consistent. This commit also fixes group_by_has_partkey() by ensuring the RelabelType node is stripped from grouping expressions when matching them to partition key expressions to avoid false mismatches. Bug: #18568 Reported-by: Webbo Han <1105066510@qq.com> Author: Webbo Han <1105066510@qq.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/18568-2a9afb6b9f7e6ed3@postgresql.org Discussion: https://postgr.es/m/tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.com Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com Backpatch-through: 12 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b6484ca9535e947a068da01015620dfde0b9b488 Modified Files -------------- src/backend/optimizer/plan/planner.c | 44 ++++++++++--- src/test/regress/expected/collate.icu.utf8.out | 90 ++++++++++++++++++++++++++ src/test/regress/sql/collate.icu.utf8.sql | 37 +++++++++++ 3 files changed, 163 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Disallow partitionwise grouping when collations don't match @ 2024-11-08 07:15 Amit Langote <amitlan@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: Amit Langote @ 2024-11-08 07:15 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in different partitions under the partitioning collation. In such cases, full partitionwise grouping would produce results that differ from those without partitionwise grouping, so disallowed that. Partial partitionwise aggregation is still allowed, as the Finalize step reconciles partition-level aggregates with grouping requirements across all partitions, ensuring that the final output remains consistent. This commit also fixes group_by_has_partkey() by ensuring the RelabelType node is stripped from grouping expressions when matching them to partition key expressions to avoid false mismatches. Bug: #18568 Reported-by: Webbo Han <1105066510@qq.com> Author: Webbo Han <1105066510@qq.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Aleksander Alekseev <aleksander@timescale.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/18568-2a9afb6b9f7e6ed3@postgresql.org Discussion: https://postgr.es/m/tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.com Discussion: https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.com Backpatch-through: 12 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/90fe6251c816547b9cb4e1895dd8e6620bae94e1 Modified Files -------------- src/backend/optimizer/plan/planner.c | 44 ++++++++++--- src/test/regress/expected/collate.icu.utf8.out | 90 ++++++++++++++++++++++++++ src/test/regress/sql/collate.icu.utf8.sql | 37 +++++++++++ 3 files changed, 163 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2024-11-08 07:15 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-11-08 07:14 pgsql: Disallow partitionwise grouping when collations don't match Amit Langote <amitlan@postgresql.org> 2024-11-08 07:14 pgsql: Disallow partitionwise grouping when collations don't match Amit Langote <amitlan@postgresql.org> 2024-11-08 07:14 pgsql: Disallow partitionwise grouping when collations don't match Amit Langote <amitlan@postgresql.org> 2024-11-08 07:14 pgsql: Disallow partitionwise grouping when collations don't match Amit Langote <amitlan@postgresql.org> 2024-11-08 07:15 pgsql: Disallow partitionwise grouping when collations don't match Amit Langote <amitlan@postgresql.org> 2024-11-08 07:15 pgsql: Disallow partitionwise grouping when collations don't match Amit Langote <amitlan@postgresql.org> 2024-11-08 07:15 pgsql: Disallow partitionwise grouping when collations don't match Amit Langote <amitlan@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox