Re: surprising to_timestamp behavior

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: surprising to_timestamp behavior
Дата
Msg-id 2726.1383062593@sss.pgh.pa.us
обсуждение исходный текст
Ответ на surprising to_timestamp behavior  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: surprising to_timestamp behavior  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-bugs
Robert Haas <robertmhaas@gmail.com> writes:
> It turns out that when you use the to_timestamp function, a space in
> the format mask can result in skipping any character at all, even a
> digit, in the input string.  Consider this example, where 10 hours are
> lost:

> rhaas=# select to_timestamp('2013-10-29 10:47:18', 'YYYY-MM-DD  HH24:MI:SS');
>       to_timestamp
> ------------------------
>  2013-10-29 00:47:18-04
> (1 row)

And that's a bug why?  The format says to ignore two characters before the
hours field.  I think you're proposing to remove important functionality.

To refine the point a bit, it's absolutely stupid to be using to_timestamp
at all for sane input data like this example.  Just cast the string to
timestamp(tz), and the standard datatype input function will do a better
job than to_timestamp ever would.  The point of to_timestamp, IMNSHO,
is to extract data successfully from weirdly formatted input; which might
well include cases where there are stray digits you don't want taken as
data.  So I'm not on board with proposals to "fix" cases like this by
making the format string's meaning squishier.

            regards, tom lane

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

Предыдущее
От: ingsis.johnparra@gmail.com
Дата:
Сообщение: BUG #8567: sql "with" for delete and update not work correctly
Следующее
От: Robert Haas
Дата:
Сообщение: Re: surprising to_timestamp behavior