From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Postgres-Bugs <pgsql-bugs@postgresql.org>
Subject: Re: surprising to_timestamp behavior
Date: Tue, 29 Oct 2013 12:03:13 -0400
Message-ID: <2726.1383062593@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmobO2Jc2meW0tWpcNcX0Q3AoddcfWwKvBD+tp3VNPef_7w@mail.gmail.com>
References: <CA+TgmobO2Jc2meW0tWpcNcX0Q3AoddcfWwKvBD+tp3VNPef_7w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com
Subject: Re: surprising to_timestamp behavior
In-Reply-To: <2726.1383062593@sss.pgh.pa.us>
References: <CA+TgmobO2Jc2meW0tWpcNcX0Q3AoddcfWwKvBD+tp3VNPef_7w@mail.gmail.com> <2726.1383062593@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox