DanStopka
DanStopka

Reputation: 565

PostgreSQL compare string setting

I have one query, which returns different results on different servers.

select ' s' > '.'

First server return true, second - false. What the are the settings that can cause this?

Upvotes: 1

Views: 57

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175676

Your DBs have different COLLATION:

The collation feature allows specifying the sort order and character classification behavior of data per-column, or even per-operation. This alleviates the restriction that the LC_COLLATE and LC_CTYPE settings of a database cannot be changed after its creation.

select name, setting
from pg_settings
where name in ('lc_collate', 'server_encoding', 'client_encoding');

-- explicit collation
select ' s' COLLATE "POSIX" > '.' COLLATE "POSIX"

SQLFiddle Demo

Upvotes: 1

Related Questions