Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The lower() function on international characters in postgresql

Tags:

postgresql

I have a standard postgresql server from a new and an old ubuntu repository.

The first is postgresql server 8.3.12. Here the lower() function works correctly on the Danish letter 'Æ'

go=#  select lower('Æ');
 lower
-------
 æ
(1 row)

Now on postgres 9.1.9 the function doesn't work (it returns the same uppercase letter)

go=# select lower('Æ');
 lower
-------
Æ
(1 row)

Does anyone have an idea how to change this behavior?

(my real problem is that ilike doesn't work on Danish characters either, but I thought the above example would make the problem more clear)

like image 856
user2728690 Avatar asked Feb 02 '26 09:02

user2728690


1 Answers

Your database was probably created with a different locale.

Check \l+ in psql on the old and new versions. They'll have different locale settings.

Other possibilities are different operating systems/versions. PostgreSQL uses libc's locale rules, and some platforms (notably Mac OS X) have a bit of a ... special ... libc.

On 9.1.9 with an en_AU.UTF-8 database running on Fedora 19 I get:

regress=> select lower('Æ');
 lower 
-------
 æ
(1 row)
like image 197
Craig Ringer Avatar answered Feb 05 '26 00:02

Craig Ringer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!