Re: Precedence of NOT LIKE, NOT BETWEEN, etc

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Precedence of NOT LIKE, NOT BETWEEN, etc
Дата
Msg-id 10160.1424722099@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Precedence of NOT LIKE, NOT BETWEEN, etc  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Precedence of NOT LIKE, NOT BETWEEN, etc
Список pgsql-hackers
I wrote:
> I'm not seeing any terribly pleasing ways to fix this.  Aside from
> the option of doing nothing, it seems like these are the choices:

> 1. We could hack base_yylex() to reduce NOT LIKE to a single token
> which could be given the same precedence as LIKE.  Ditto for the other
> four cases.  This would result in nice behavior for these cases, but as
> Robert has correctly pointed out, hacks in base_yylex() risk creating
> other poorly-understood behaviors.

> 2. We could change the precedence levels so that LIKE/ILIKE/SIMILAR,
> BETWEEN, and IN all have precedence just above NOT, which would pretty
> much mask the problem since there would be no other tokens with in-between
> precedence levels.  In the context of the operator precedence changes
> I proposed earlier, this would mean inserting the IS tests and comparison
> operators between IN_P and POSTFIXOP rather than where the
> single-character comparison ops live now.  We would likely also have to
> flatten LIKE/BETWEEN/IN into a single %nonassoc precedence level to avoid
> having weird interactions among them.  This isn't terribly attractive
> because it would risk larger behavioral changes than the previous
> proposal.

I thought of another possibility:

3. Leave everything as-is but mark the NOT-operator productions as having
the precedence of NOT rather than of LIKE etc.  This would change the
behavior only for the NOT-LIKE-followed-by-< example, and would make the
two cases for NOT LIKE consistent though they'd remain inconsistent with
LIKE.  This behavior seems at least somewhat explainable/documentable
("NOT-foo operators have the precedence of NOT"), whereas what we have
seems about impossible to justify.
        regards, tom lane



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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Reduce pinning in btree indexes
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: Abbreviated keys for text cost model fix