Thread: Strange problem with string and select

Strange problem with string and select

From
Condor
Date:
Hello,
can I ask is exist some kind of automatic escape string in postgresql ?
I use pgsql 9.1.5 and I have very interest problem, I have field with
text string that I cant find normally.
Variable encoding from variables:

  server_encoding                 | WIN1251
  lc_collate                      | bg_BG.CP1251
  lc_ctype                        | bg_BG.CP1251
  lc_messages                     | bg_BG.CP1251
  lc_monetary                     | bg_BG.CP1251
  lc_numeric                      | bg_BG.CP1251
  lc_time                         | bg_BG.CP1251
  client_encoding                 | WIN1251

Here is examples (I replace in example Cyrillic encoding because most
of the ppl don't have cp1251 encoding)

select * from postcodes where namejr LIKE 'LULIN V%';
id | namejr
21 | LULIN VIII
22 | LULIN VII
23 | LULIN VIII
24 | LULIN VI
25 | LULIN VII
26 | LULIN V

buf if I do:
select * from postcodes where namejr LIKE 'LULIN VII%';
result is:
22 | LULIN VII
25 | LULIN VII


as I can see ids 21 and 23 missing that should be: LULIN VIII
I dump follow records to text file and make hex compare,
both ids 21 and 23 is the same (equal).

Any one can give me a little help?


Hristo C.





Re: Strange problem with string and select

From
Alban Hertroys
Date:
On 30 August 2012 10:12, Condor <condor@stz-bg.com> wrote:
> Hello,
> can I ask is exist some kind of automatic escape string in postgresql ?
> I use pgsql 9.1.5 and I have very interest problem, I have field with text
> string that I cant find normally.

> Here is examples (I replace in example Cyrillic encoding because most of the
> ppl don't have cp1251 encoding)
>
> select * from postcodes where namejr LIKE 'LULIN V%';
> id | namejr
> 21 | LULIN VIII
> 22 | LULIN VII
> 23 | LULIN VIII
> 24 | LULIN VI
> 25 | LULIN VII
> 26 | LULIN V
>
> buf if I do:
> select * from postcodes where namejr LIKE 'LULIN VII%';
> result is:
> 22 | LULIN VII
> 25 | LULIN VII
>
>
> as I can see ids 21 and 23 missing that should be: LULIN VIII
> I dump follow records to text file and make hex compare,
> both ids 21 and 23 is the same (equal).
>
> Any one can give me a little help?

Perhaps the records with ids 21 and 23 have a lower-case 'l' ('L')
instead of an upper-case 'I' ('i'), or something similar? Are the
hex-codes for ids 21, 22, 23 and 25 the same for the substring reading
'VII'?

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.


Re: Strange problem with string and select

From
Condor
Date:
On , Alban Hertroys wrote:
> On 30 August 2012 10:12, Condor <condor@stz-bg.com> wrote:
>> Hello,
>> can I ask is exist some kind of automatic escape string in
>> postgresql ?
>> I use pgsql 9.1.5 and I have very interest problem, I have field
>> with text
>> string that I cant find normally.
>
>> Here is examples (I replace in example Cyrillic encoding because
>> most of the
>> ppl don't have cp1251 encoding)
>>
>> select * from postcodes where namejr LIKE 'LULIN V%';
>> id | namejr
>> 21 | LULIN VIII
>> 22 | LULIN VII
>> 23 | LULIN VIII
>> 24 | LULIN VI
>> 25 | LULIN VII
>> 26 | LULIN V
>>
>> buf if I do:
>> select * from postcodes where namejr LIKE 'LULIN VII%';
>> result is:
>> 22 | LULIN VII
>> 25 | LULIN VII
>>
>>
>> as I can see ids 21 and 23 missing that should be: LULIN VIII
>> I dump follow records to text file and make hex compare,
>> both ids 21 and 23 is the same (equal).
>>
>> Any one can give me a little help?
>
> Perhaps the records with ids 21 and 23 have a lower-case 'l' ('L')
> instead of an upper-case 'I' ('i'), or something similar? Are the
> hex-codes for ids 21, 22, 23 and 25 the same for the substring
> reading
> 'VII'?


Ah, you are absolute right, after an exhausting search I forgot to
compare hex value of other strings.
in LULIN VIII last three hex strings is 0xb2 0xb2 0xb2
and in  LULIN VII last two hex strings is 0x49 0x49.

Thank you for the idea.


Hristo C.