pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: 狂奔的蜗牛 <1105066510@qq.com>
To: Aleksander Alekseev <aleksander@timescale.com>
To: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Cc: Tender Wang <tndrwang@gmail.com>
Subject: 回复: BUG #18568: BUG: Result wrong when do group by on partition table!
Date: Tue, 6 Aug 2024 19:45:59 +0800
Message-ID: <tencent_6767E6371361847E7540172904F06C1A1908@qq.com> (raw)
In-Reply-To: <CAJ7c6TPD+KMeT19jaoXjPf8_4mdQWOYXzOEyCuFDGanv=_k8UQ@mail.gmail.com>
References: <18568-2a9afb6b9f7e6ed3@postgresql.org>
	<CAHewXNnKLrZYG4iqaYw=uB3XWRrYRZHo7VtcMsbUEbdbajQg2Q@mail.gmail.com>
	<CAJ7c6TPD+KMeT19jaoXjPf8_4mdQWOYXzOEyCuFDGanv=_k8UQ@mail.gmail.com>

Hi,
I am working to compatible with Oracle in PG,
in oracle, the result used case-insensitive collation is not&nbsp;unique.
There are two oracle's test case:


first case:
```sql
&nbsp; &nbsp; CREATE TABLE group_by_ci_test_1 (c varchar2(20));
&nbsp; &nbsp; INSERT INTO group_by_ci_test_1 VALUES ('a');
&nbsp; &nbsp; INSERT INTO group_by_ci_test_1 VALUES ('a');
&nbsp; &nbsp; INSERT INTO group_by_ci_test_1 VALUES ('A');
&nbsp; &nbsp; SELECT c collate binary_ci, count(c) FROM group_by_ci_test_1 GROUP BY c collate binary_ci;
```
first result
```shell
&nbsp; &nbsp; CCOLLATEBINARY_CI&nbsp; &nbsp; &nbsp; COUNT(C)
&nbsp; &nbsp; -------------------- ----------
&nbsp; &nbsp; a&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3

```


second case:
```sql
&nbsp; &nbsp; CREATE TABLE group_by_ci_test_2 (c varchar2(20));
&nbsp; &nbsp; INSERT INTO group_by_ci_test_2 VALUES ('A');
&nbsp; &nbsp; INSERT INTO group_by_ci_test_2 VALUES ('a');
&nbsp; &nbsp; INSERT INTO group_by_ci_test_2 VALUES ('a');
&nbsp; &nbsp; SELECT c collate binary_ci, count(c) FROM group_by_ci_test_2 GROUP BY c collate binary_ci;

```
second result:
```shell
&nbsp; &nbsp; CCOLLATEBINARY_CI&nbsp; &nbsp; &nbsp; COUNT(C)
&nbsp; &nbsp; -------------------- ----------
&nbsp; &nbsp; A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;6

```






狂奔的蜗牛
1105066510@qq.com



&nbsp;




------------------&nbsp;原始邮件&nbsp;------------------
发件人:                                                                                                                        "Aleksander Alekseev"                                                                                    <aleksander@timescale.com&gt;;
发送时间:&nbsp;2024年8月6日(星期二) 下午5:09
收件人:&nbsp;"pgsql-bugs"<pgsql-bugs@lists.postgresql.org&gt;;
抄送:&nbsp;"Tender Wang"<tndrwang@gmail.com&gt;;"狂奔的蜗牛"<1105066510@qq.com&gt;;
主题:&nbsp;Re: BUG #18568: BUG: Result wrong when do group by on partition table!



Hi,

&gt; [...]
&gt; I continue to find out why the collation id of partkey is 16384(e.g. case_insensitive). The partkey expr info is
&gt; set in set_baserel_partition_key_exprs(), which it uses partkey-&gt;parttypcoll[cnt] value not&nbsp; partkey-&gt;partcollation value.
&gt;
&gt; And partkey-&gt;parttypcoll[cnt] is assigned from pg_attribute , which is the column c meta data.
&gt; Should we use partkey-&gt;partcollation value?&nbsp; I try to fix that in the attached patch. I add your case in the test, and I don't find
&gt; failed regress.

```
+SELECT c collate case_insensitive, count(c) FROM
+pagg_tab_col GROUP BY c collate case_insensitive;
+ c | count
+---+-------
+ e |&nbsp;&nbsp; 600
+ D |&nbsp;&nbsp; 600
+ C |&nbsp;&nbsp; 600
+ B |&nbsp;&nbsp; 600
+ A |&nbsp;&nbsp; 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

view thread (7+ messages)  latest in thread

Message-ID: <tencent_6767E6371361847E7540172904F06C1A1908@qq.com>
Permalink:  ../tencent_6767E6371361847E7540172904F06C1A1908@qq.com/
Also on:    postgresql.org/message-id/tencent_6767E6371361847E7540172904F06C1A1908@qq.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: 1105066510@qq.com, aleksander@timescale.com, pgsql-bugs@lists.postgresql.org, tndrwang@gmail.com
  Subject: Re: =?gb18030?B?u9i4tKO6IEJVRyAjMTg1Njg6IEJVRzogUmVzdWx0?= =?gb18030?B?IHdyb25nIHdoZW4gZG8gZ3JvdXAgYnkgb24gcGFy?= =?gb18030?B?dGl0aW9uIHRhYmxlIQ==?=
  In-Reply-To: <tencent_6767E6371361847E7540172904F06C1A1908@qq.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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