1

In one of my PostgreSQL databases, the following statement returns true! The other works fine.

select 'A'>'a'

LC_COLLATE and LC_TYPE in all of my databases is en_US.UTF-8. client_encoding is UTF8

My database version is 13.2. OS is Linux.

In Unicode order, 'A' shall be smaller than 'a', but it isn't. Any configuration I shall look at?

Is it OS dependent? The other database that works correctly is running on MacOS.

--

select key from json_each('{"A":1, "a":2}') order by key => a and then A!

More weird: select key from json_each('{"A":1, "a":2, ":": 3, ":a": 4}') order by key => :, a, :a and then A

--

SQL Fiddle the same weird behavior, but DB Fiddle is correct (but its collation is C).

Tom Yeh
  • 1,987
  • 2
  • 15
  • 23

1 Answers1

1

The character type, defined by LC_CTYPE is probably en_US.utf8, which is not the same as UTF-8.

Its a non-IANA character type that supports lowercase letters being before uppercase.

Oddly, SQLFiddle is also afflicted, likewise returning true for 'A' > 'a'

Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • `en_US.utf8` is the same as `en_US.UTF-8`, right? I verified with another test server running on Linux. It returns `true` too! – Tom Yeh Jan 08 '22 at 16:02
  • 4
    No, utf8 and UTF-8 are different. See https://serverfault.com/questions/616744 – Bohemian Jan 08 '22 at 16:05