From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas@vondra.me>
Cc: [3반]김민지_4904 <hzuiw33@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Sorting Discrepancy in PostgreSQL 14.13
Date: Thu, 14 Nov 2024 23:25:34 -0500
Message-ID: <2358737.1731644734@sss.pgh.pa.us> (raw)
In-Reply-To: <69c7ee62-f9de-4365-b325-7e493203a7ae@vondra.me>
References: <CAGU7ePPpK+3UUyfLbynZBbqf7kHRbUYasZ5=kN5p-ZJnWT=tHA@mail.gmail.com>
<69c7ee62-f9de-4365-b325-7e493203a7ae@vondra.me>
Tomas Vondra <tomas@vondra.me> writes:
> On 11/14/24 13:49, [3반]김민지_4904 wrote:
>> I'm doubtful this is a collation issue, as most collations basically
>> respect ASCII order.
> This is 99.999% due to the collation, so which collations are being used
> on these systems? Also, I don't get this "incorrect" behavior on 14.13,
> it behaves the same as 17 for me, producing the expected result.
It surely is a collation issue. Using a glibc-based system, I get
u8=# CREATE TABLE t0 (c0 TEXT);
CREATE TABLE
u8=# INSERT INTO t0 (c0) VALUES ('-10'), ('20'), ('-5'), ('15'), ('-25');
INSERT 0 5
u8=# select * from t0 order by c0 collate "C";
c0
-----
-10
-25
-5
15
20
(5 rows)
u8=# select * from t0 order by c0 collate "en_US";
c0
-----
-10
15
20
-25
-5
(5 rows)
(In point of fact, most glibc collations do NOT "respect ASCII order".
They tend to ignore punctuation until it's needed as a tiebreaker.)
So this is surely down to the PG 14.13 installation having a different
default collation than whatever it's compared to, which most likely
is caused by having run initdb with a different locale environment.
regards, tom lane
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: tgl@sss.pgh.pa.us, tomas@vondra.me, hzuiw33@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: Sorting Discrepancy in PostgreSQL 14.13
In-Reply-To: <2358737.1731644734@sss.pgh.pa.us>
* 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