Re: Different result when using '=' and 'like' in unicode

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Different result when using '=' and 'like' in unicode
Дата
Msg-id Pine.LNX.4.44.0211171451440.12428-100000@localhost.localdomain
обсуждение исходный текст
Ответ на Different result when using '=' and 'like' in unicode mode  (Jiang Sheng <jiangsheng@sis.sh.cn>)
Список pgsql-bugs
Jiang Sheng writes:

> the sql is
> select * from tbl_test where name = '石田';
>
> but the result contains other data, such as 石町, 柳町, 柳田
>
> and I changed the sql to
> select * from tbl_test where name like '石田';
> select * from tbl_test where name ilike '石田';
>
> the results both correct.

The LIKE operator uses a character-by-character comparison (which could
quite possibly behave oddly if your strings contain combining characters,
but that is a different issue).  The = operator uses the host operating
system's locale facilities to do a locale-aware comparison.  So in general
LIKE and = are not interchangeable.

If the result you get for = is wrong even under some locale, then you
probably don't have the right locale set on your server.  Recent glibc
systems require you to set your locale to xx_YY.utf8 (rather than just
xx_YY) if you want to use Unicode.

--
Peter Eisentraut   peter_e@gmx.net

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Jiang Sheng
Дата:
Сообщение: Different result when using '=' and 'like' in unicode mode
Следующее
От: Jiang Sheng
Дата:
Сообщение: Re: Different result when using '=' and 'like' in unicode mode