Re: Interval constant syntax, was Re: Interval & check clause

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Interval constant syntax, was Re: Interval & check clause
Дата
Msg-id 27508.1080625348@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Interval constant syntax, was Re: Interval & check clause  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
Bruno Wolff III <bruno@wolff.to> writes:
> This is different in that you are using - instead of >= . Date - Date
> will get picked because that is the only - operator with a left operand
> of type date.

Even if it weren't the only one, there is a preferential case involved:
given "known_type operator unknown_literal", the parser will
preferentially assume that the unknown_literal is the same type as the
other operand, if there is an available operator that takes that type
on both sides.  For details see
    http://www.postgresql.org/docs/7.4/static/typeconv-oper.html
(rule 2a is my point here).

Note that in *no* case will the contents of the string literal have any
a-priori effect on the parser's decision about what the literal's type
is.  I believe this is a good policy in general --- doing otherwise
would render the behavior way too unpredictable, since often the
contents of the literal are not under the control of the SQL query
author.  But this does mean that just writing '2 days' is not going
to be enough to make the system think it is an interval constant.
There must be some cue to the type outside the quotes, whether an
explicit cast or an implicit match to another operand.

            regards, tom lane

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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Interval constant syntax, was Re: Interval & check clause
Следующее
От: Shanmugasundaram Doraisamy
Дата:
Сообщение: Can we have time based triggers in Postgresql??