Peter Eisentraut <peter_e@gmx.net> writes:
> Mihail Marinov writes:
>> My problem is that ORDER BY does not alphabetically order strings in
>> proper way. Worst - it does sometimes work right but I can't find out
>> exactly why. But after a while it stops until I rebuild and
>> reconfigure.
> You must have the same collation locale setting (LC_COLLATE, or LC_ALL as
> default) when running initdb and when running postmaster. Changing the
> setting in between will result in random and incorrect results and
> database corruption.
To enlarge a little more: the most common way to get burnt by this is
to have different LC_xxx environment variables when starting the
postmaster from a boot script as you do when running initdb or starting
the postmaster from an interactive shell. Best to explicitly set the
desired locale in the script that fires up the postmaster.
Postgres 7.1 solves this problem by locking down a database's locale at
initdb time. Subsequent postmaster runs will adopt the LC_COLLATE value
that was prevalent when initdb ran, no matter what their environment is.
regards, tom lane