Postgres won't upper or lowercase non-ascii chars even with UTF8 encoding and Collate/Ctype set to C

Viewed 32

I noticed some weird query results on my local machine, and when I looked into it, for some reason Postgres is not upper or lower casing letter like I would expect.

If I use the single codepoint accented "e", it doesn't uppercase or lowercase it:

SELECT upper('é');
 upper
-------
 é
(1 row)

If I use the 2 codepoint version ["e", "́"], then it does.

SELECT upper('é');
 upper
-------
 É
(1 row)

After digging around and finding the \l+ command, I seem to have what I need in there. all my tables look the same, with the following:

                 | Encoding | Collate | Ctype |
 | postgres      | UTF8     | C       | C     |      | 10 MB   | pg_default |

I'm a bit stuck about what could be wrong. I did try uninstalling and reinstalling postgres, but the issue remains. I'm running postgresql: stable 14.4 (bottled), HEAD on a macbook pro M1, macOS 12.4

1 Answers

It appears that C Ctype doesn't correctly(at least not as I would have expected) lower/upper case non-ascii characters. Changing the Ctype worked for me.

Related