Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between C and Posix locales on Postgres?

I know that database locales on Postgres are responsible for proper order of national characters, proper lower/upper-casing etc.

But why there are two language-neutral locales: posix and c? Is there any difference between them or is it just one neutral locale with two different names?

UPDATE As Magnus Hagander states in his answer, POSIX and C locales are the same locale with different names (no matter if Postgres is installed on POSIX or Windows System). I don't know how to confirm this information - where to look for proper section of documentation?

Magnus's explanation seems sensible, but it is strange at the same time that there are two names for the same locale to choose from. What is the purpose of this - only to make confusion?

like image 376
WildWezyr Avatar asked Mar 01 '10 10:03

WildWezyr


People also ask

What is C locale in Postgres?

Locale support refers to an application respecting cultural preferences regarding alphabets, sorting, number formatting, etc. PostgreSQL uses the standard ISO C and POSIX locale facilities provided by the server operating system. For additional information refer to the documentation of your system.

What is POSIX locale?

This locale refers to the ANSI C or POSIX-defined standard for the locale inherited by all processes at startup time. The C or POSIX locale assumes the 7-bit ASCII character set and defines information for the six previous categories.

How do I change collate and Ctype in PostgreSQL?

You cannot to change these values for already created databases. In this moment, when there are not other databases, the most easy solution is a) stop database, b) delete data directory, c) run manually initdb with options --encoding and --locale (run this command under postgres user).


2 Answers

Note that PostgreSQL just uses the operating system locale, and doesn't have it's own definition of locales. If your system is POSIX compliant, C and POSIX will be the exact same locale: http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html (see the first sentence under 7.2).

like image 176
Magnus Hagander Avatar answered Oct 10 '22 10:10

Magnus Hagander


According to The Single UNIX ® Specification POSIX and C locales are aliases:

The strings "C" and "POSIX" are reserved as identifiers for the POSIX locale

So they are guaranteed to be the same on POSIX systems. I don't know how far Windows Vista or 7 are POSIX compliant, but probably similar definition can be found in Microsoft documentation.

like image 30
user2622016 Avatar answered Oct 10 '22 11:10

user2622016