Re: to_timestamp error between postgres version 8.3 and 9.2

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: to_timestamp error between postgres version 8.3 and 9.2
Дата
Msg-id 14883.1377928020@sss.pgh.pa.us
обсуждение исходный текст
Ответ на to_timestamp error between postgres version 8.3 and 9.2  (Technical Doubts <online.technicaldoubts@gmail.com>)
Список pgsql-admin
Technical Doubts <online.technicaldoubts@gmail.com> writes:
> insert into registers_info (regid,transid,regdate,canceldate) values
> ('reg1',1,to_timestamp('2013-07-24','yyyy-MM-dd
> hh24:mi:ss')::TIMESTAMP,to_timestamp('null','yyyy-MM-dd
> hh24:mi:ss')::TIMESTAMP);

> The above query works fine in Postgres 8.3 version.

> But the same query when executed in postgres 9.2 its throwing below error

> ERROR: invalid value "null" for "yyyy"
> Detail: Value must be an integer.

Yup.  It was never intended that 'null' would be valid input for
to_timestamp, and that's thrown an error since 8.4.  See thread here:
http://www.postgresql.org/message-id/37ed240d0808291839t21e19956mdfbdc80aeb1b3c19@mail.gmail.com

A quick test says that 8.3 and older did this:

regression=# select to_timestamp('null','yyyy-MM-dd hh24:mi:ss');
       to_timestamp
---------------------------
 0001-01-01 00:00:00-05 BC
(1 row)

which can hardly be considered a sane interpretation of 'null', even
if we wanted to accept that input.

            regards, tom lane


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

Предыдущее
От: Technical Doubts
Дата:
Сообщение: to_timestamp error between postgres version 8.3 and 9.2
Следующее
От: françois Figarola
Дата:
Сообщение: Re: to_timestamp error between postgres version 8.3 and 9.2