Incorrect Query Result I have a table with the following data:

    unit_codes
    kind    | code
-------------------------
    UNIT    | PS3b
    UNIT    | PS3B
    UNIT    | PS3C


If I run this select I get the correct result.

select * from unit_codes where kind = 'UNIT';


Result:

UNIT    PS3b
UNIT    PS3B 
UNIT    PS3C


If I filter on the code column I get no rows.

select * from unit_codes where code = 'PS3C';


No rows are retuned.

I suspect there is a non visible character on the code column for some rows. The problem started after some OS patches were installed.

We are running PostgreSQL 9.2.4 on sparc-sun-solaris2.10, compiled by cc: Sun C 5.9 SunOS_sparc 2007/05/03, 32-bit.
Aside from invisible characters, the possibility of an OS patch changing the results of such an query exists through a change in locales.

An index involving text types is only valid if the underlying collation never changes. Postgres relies on the OS for comparing strings, through the libc, so a change in an OS collation may have the effect of an index becoming unusable, as if it was corrupted.

If there is an index on the column, you can test this hypothesis by issuing SET enable_indexscan TO off; before the offending query and see if it gives the same results. This check may also reveal an index corruption independantly of any problem with the collation.