Re: Unexpected parse behaviour for date to timestamp

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Unexpected parse behaviour for date to timestamp
Дата
Msg-id 3712.1047098930@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Unexpected parse behaviour for date to timestamp  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
Список pgsql-general
Jean-Christian Imbeault <jc@mega-bucks.co.jp> writes:
> As an aside, and for my own edificaton, what is the "correct" was to
> pass a date in as an SQL argument? Using '2003-01-01' works but it seems
> the parser is actually viewing this as text and not a date?

No.  That is actually the preferred way to do it.  A literal encased in
single quotes is not text to Postgres --- it is an untyped literal that
will be cast automatically to the datatype needed by its context.  In
particular, given an expression like
        columnref operator 'literal'
the untyped literal will preferentially be cast to the same datatype as
the column reference.  (I believe the parser will explore other possible
interpretations if that one doesn't match any available operator, but
that will definitely be what's chosen if there's a matching operator.)

            regards, tom lane

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

Предыдущее
От: Jean-Christian Imbeault
Дата:
Сообщение: Re: Unexpected parse behaviour for date to timestamp
Следующее
От: Joshua Moore-Oliva
Дата:
Сообщение: Define maximum time increment.