Обсуждение: Locale / Encoding mismatch
I have just attempted to upgrade to 8.3.1 and I now get this error when trying to create a UTF8 DB: postgres@mrnaz:~$ createdb twerl -E utf8 createdb: database creation failed: ERROR: encoding UTF8 does not match server's locale en_AU DETAIL: The server's LC_CTYPE setting requires encoding LATIN1. I have never bothered with the server's locale, all the locale handling in the app gets handled within the DB itself. I guess I now have to dig into the murky world of system locales and how they affect my app ecosystem. I don't suppose there is an easy solution to this and a short explanation of why it now occurs is there?
On Mon, Mar 31, 2008 at 04:32:16AM +1100, Naz Gassiep wrote: > I have never bothered with the server's locale, all the locale handling > in the app gets handled within the DB itself. I guess I now have to dig > into the murky world of system locales and how they affect my app > ecosystem. I don't suppose there is an easy solution to this and a short > explanation of why it now occurs is there? Basically, your locale defines your sort order and the encoding and the locale you've chosen in incompatable with the encoding you want to use in the backend. Having differing ideas of the encoding causing sorting to fail in odd ways and in extreme cases, crashes. Short answer is: use en_AU.UTF-8 for your locale. If it doesn't exist you can create it using /etc/locale.gen (assuming you're running some kind of linux) Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Please line up in a tree and maintain the heap invariant while > boarding. Thank you for flying nlogn airlines.
Вложения
PG 8.3 has strict rule what CTYPE and LOCALLE is allowed. It is protection before possible problems with data processing. You probably need set en_AU.uft8 locale when you initialize server. Zdenek Naz Gassiep napsal(a): > I have just attempted to upgrade to 8.3.1 and I now get this error when > trying to create a UTF8 DB: > > postgres@mrnaz:~$ createdb twerl -E utf8 > createdb: database creation failed: ERROR: encoding UTF8 does not match > server's locale en_AU > DETAIL: The server's LC_CTYPE setting requires encoding LATIN1. > > I have never bothered with the server's locale, all the locale handling > in the app gets handled within the DB itself. I guess I now have to dig > into the murky world of system locales and how they affect my app > ecosystem. I don't suppose there is an easy solution to this and a short > explanation of why it now occurs is there? >
> Short answer is: use en_AU.UTF-8 for your locale. If it doesn't exist > you can create it using /etc/locale.gen (assuming you're running some > kind of linux) > I've just installed that locale on my system (Debian Sarge). However I'm still getting the error. I only set the locale for that user, could it be that the locale needs to be set to UTF8 system wide? Here's the output: postgres@mrnaz:~$ locale LANG=en_AU.UTF8 LANGUAGE=en_AU.UTF8:en_US.UTF8:en_GB.UTF8:en.UTF8 LC_CTYPE=en_AU.UTF8 LC_NUMERIC=en_AU.UTF8 LC_TIME=en_AU.UTF8 LC_COLLATE=en_AU.UTF8 LC_MONETARY=en_AU.UTF8 LC_MESSAGES=en_AU.UTF8 LC_PAPER=en_AU.UTF8 LC_NAME=en_AU.UTF8 LC_ADDRESS=en_AU.UTF8 LC_TELEPHONE=en_AU.UTF8 LC_MEASUREMENT=en_AU.UTF8 LC_IDENTIFICATION=en_AU.UTF8 LC_ALL= postgres@mrnaz:~$ createdb twerl -E utf8 createdb: database creation failed: ERROR: encoding UTF8 does not match server's locale en_AU DETAIL: The server's LC_CTYPE setting requires encoding LATIN1.
On Mon, Mar 31, 2008 at 05:37:26AM +1100, Naz Gassiep wrote: > I've just installed that locale on my system (Debian Sarge). However I'm > still getting the error. I only set the locale for that user, could it > be that the locale needs to be set to UTF8 system wide? Here's the output: The locale is database-wide and was set at initdb time... You'll need to re-initdb. Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Please line up in a tree and maintain the heap invariant while > boarding. Thank you for flying nlogn airlines.