Re: BUG #18857: Abnormal string comparison results

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: 2322370369@qq.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2025-03-20T14:46:15Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> As shown in the example below, on the ASCII table ‘?’ is larger than ‘&’. I
> don't think ‘t’ should be returned here. In the MySQL database it does
> return 0.
> Is there some special consideration here?

Read about collations at

https://www.postgresql.org/docs/current/collation.html

You are probably using a non-C collation.  You could say

postgres=# SELECT ('?' <= '&*CcCV5' collate "C");
 ?column? 
----------
 f
(1 row)

but more likely you want to switch it at the database level.

			regards, tom lane