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?
show lc_collate ;andshow client_encoding ;inpsqlreturn? What encoding is the Java code using? Add answers as update to your question. Also what OS and version and have there been any OS updates lately? Again add to your question.