Just a little conundrum I have faced with.
I have a table player with login column(varchar(255)).
The rows are inserted by Java code.
I've a record with id = 173 login = PLN2test:
When I search for this record by the following query,
SELECT login FROM player WHERE login = 'PLN2test'
or even:
SELECT login FROM player WHERE login = (SELECT login FROM player WHERE id = 173)
I get zero results!
However when I try:
SELECT login FROM player WHERE login LIKE '%PLN2test'
or
SELECT login FROM player WHERE login LIKE 'PLN2test%'
I get my record.
Please can you tell me why this is happening?
Is there known bug on the postgres side?
How I can debug query execution and understand why it returns unexpected result?
P.S. SELECT length(login) FROM player WHERE id = 173 gives me 8
show lc_collate;
lc_collate
------------
en_US.utf8
(1 row)
show client_encoding ;
client_encoding
-----------------
UTF8
(1 row)
OS version: Ubuntu 20.04
It looks like colleague of mine just recently changed a collate type from C.UTF-8 to en_US.utf8). Can this lead to such a behavior? And how to migrate data to new type now?
CodePudding user response:
What you have found is that you should not go around changing system catalogs(pg_database) manually. Per Locale: "Some locale categories must have their values fixed when the database is created. You can use different settings for different databases, but once a database is created, you cannot change them for that database anymore. LC_COLLATE and LC_CTYPE are these categories."
