Re: to_timestamp() too loose?

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: to_timestamp() too loose?
Дата
Msg-id CABUevEzf8A5f_4e15QRUA+g62M3gYN6iAMfoHShW2d8Ekf5pcw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: to_timestamp() too loose?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: to_timestamp() too loose?
Список pgsql-hackers
On Thu, Aug 23, 2012 at 3:42 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Magnus Hagander <magnus@hagander.net> writes:
>> postgres=# select to_timestamp('2012-08-01', 'yyyy-mm-dd');
>>       to_timestamp
>> ------------------------
>>  2012-08-01 00:00:00+02
>
>> postgres=# select to_timestamp('2012-08-00', 'yyyy-mm-dd');
>>       to_timestamp
>> ------------------------
>>  2012-08-01 00:00:00+02
>
>> postgres=# select to_timestamp('2012-00-00', 'yyyy-mm-dd');
>>       to_timestamp
>> ------------------------
>>  2012-01-01 00:00:00+01
>
>> Should we really convert 00 to 01?
>
> to_timestamp is intentionally pretty loose.  Personally, if I wanted
> sanity checking on a date string in any common format, I would just
> cast the string to timestamp(tz), and *not* use to_timestamp.

Shouldn't we put at least a note, and IMO even a *warning* in the docs
saying that it is like this? (or am I missing one we have) It's not
really consistent with how most of postgres works :)

-- Magnus HaganderMe: http://www.hagander.net/Work: http://www.redpill-linpro.com/



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: to_timestamp() too loose?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: to_timestamp() too loose?