Re: BUG #18568: BUG: Result wrong when do group by on partition table!
Aleksander Alekseev <aleksander@timescale.com>
From: Aleksander Alekseev <aleksander@timescale.com>
To: pgsql-bugs@lists.postgresql.org
Cc: Tender Wang <tndrwang@gmail.com>, 1105066510@qq.com
Date: 2024-08-06T09:09:30Z
Lists: pgsql-bugs
Hi, > [...] > I continue to find out why the collation id of partkey is 16384(e.g. case_insensitive). The partkey expr info is > set in set_baserel_partition_key_exprs(), which it uses partkey->parttypcoll[cnt] value not partkey->partcollation value. > > And partkey->parttypcoll[cnt] is assigned from pg_attribute , which is the column c meta data. > Should we use partkey->partcollation value? I try to fix that in the attached patch. I add your case in the test, and I don't find > failed regress. ``` +SELECT c collate case_insensitive, count(c) FROM +pagg_tab_col GROUP BY c collate case_insensitive; + c | count +---+------- + e | 600 + D | 600 + C | 600 + B | 600 + A | 600 +(5 rows) ``` Shouldn't we use UPPER(c) and ORDER BY in the test case to make the results deterministic? -- Best regards, Aleksander Alekseev
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
-
For partitionwise join, match on partcollation, not parttypcoll.
- 2af28e603319 11.0 cited