Re: BUG #18523: String compare not consistent

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: patrick(dot)van(dot)dijk(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18523: String compare not consistent
Date: 2024-06-26 16:04:04
Message-ID: 1515722.1719417844@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> When I try the following on a Azure/Linux version of PostgreSQL i see some
> strange results that are not correct.
> On Windows the behavior is correct.

"Correct" is in the eye of the beholder, and non-C collations
tend to act in ways far more complicated than you seem to expect.
Check the locale settings on the two machines; unless they are
both "C", there's not really any guarantee of consistency
between Windows and anybody else.

As a demonstration that this isn't some Postgres-specific
weirdness, you can try asking sort(1) what it thinks.
On a RHEL8 machine I get

$ echo -e '|\n0' | LANG=C sort
0
|
$ echo -e '|1\n01' | LANG=C sort
01
|1
$ echo -e '|\n0' | LANG=en_US.utf8 sort
|
0
$ echo -e '|1\n01' | LANG=en_US.utf8 sort
01
|1

and I'd expect the same from any Linux machine with a similar
vintage of glibc.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2024-06-26 18:30:56 Re: BUG #18523: String compare not consistent
Previous Message Laurenz Albe 2024-06-26 15:59:24 Re: BUG #18523: String compare not consistent