Re: BUG #18568: BUG: Result wrong when do group by on partition table!
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: 狂奔的蜗牛 <1105066510@qq.com>
Cc: Tender Wang <tndrwang@gmail.com>,
pgsql-bugs <pgsql-bugs@lists.postgresql.org>, aleksander <aleksander@timescale.com>
Date: 2024-08-07T15:04:08Z
Lists: pgsql-bugs
On Wed, Aug 7, 2024 at 9:08 PM 狂奔的蜗牛 <1105066510@qq.com> wrote: > > I readd RelabelType to branch in v5 patch, and add case to cover the code. > > In new adding case: `SELECT c collate "C", count(c) FROM pagg_tab3 GROUP BY c collate "C" HAVING count(c) > 1 ORDER BY 1;` > According to original logic, group_by_has_partkey() will return false, it will lead to cannot do having filter in sub table, the result is correct but the performance is poor. > Our logic will get better performance. > > > About InvalidOid collation, non-character type's collation is 0(InvalidOid) always. > src/test/regress/sql/partition_aggregate.sql suppose to run with or without ICU, your new test requires ICU, which will make some buildfarm fail? put the test to src/test/regress/sql/collate.icu.utf8.sql seems a little bit of strange. also. see beginning of partition_aggregate.sql -- Note: to ensure plan stability, it's a good idea to make the partitions of -- any one partitioned table in this test all have different numbers of rows. you may want to adjust the pagg_tab3 partitions rows. some white space error. git diff --check src/backend/optimizer/plan/planner.c:8041: trailing whitespace. + * Set collation in group by clause using COLLATE syntax, src/backend/optimizer/plan/planner.c:8051: trailing whitespace. + }
Commits
-
Disallow partitionwise grouping when collations don't match
- 90fe6251c816 18.0 landed
- b6484ca9535e 17.1 landed
- dd2f8ebee221 16.5 landed
- 0a620659c549 15.9 landed
- 96f9b29a3e1e 14.14 landed
- ff65f695c0d3 13.17 landed
- 46d9be5efb1a 12.21 landed