Re: BUG #2391: "Similar to" pattern matching does not operate as documented

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #2391: "Similar to" pattern matching does not operate as documented
Дата
Msg-id 21132.1144947341@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #2391: "Similar to" pattern matching does not operate as documented  ("Eric Noriega" <noriega@gwu.edu>)
Список pgsql-bugs
"Eric Noriega" <noriega@gwu.edu> writes:
> db=# select 'tab' similar to 'a|b';
>  ?column?
> ----------
>  t

Yeah, this is a bug ... the cause can be seen by looking at the
underlying similar_escape() function, which converts a SIMILAR TO
pattern into a POSIX regex pattern:

regression=# select similar_escape('(a|b)', null);
 similar_escape
----------------
 ^(a|b)$
(1 row)

regression=# select similar_escape('a|b', null);
 similar_escape
----------------
 ^a|b$
(1 row)

regression=#

I believe that in the second case, ^ and $ bind more tightly than |
per POSIX rules.  So we need to put parens around the pattern to
prevent that.

Thanks for the report!

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #2389: function within function return value
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: BUG #2390: check constraint