Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbBlH-0002IK-W4 for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Oct 2013 16:03:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VbBlH-00034I-6z for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Oct 2013 16:03:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbBlG-00034C-KZ for pgsql-bugs@postgresql.org; Tue, 29 Oct 2013 16:03:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbBlD-00051U-GE for pgsql-bugs@postgresql.org; Tue, 29 Oct 2013 16:03:18 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id r9TG3DLl002727; Tue, 29 Oct 2013 12:03:13 -0400 From: Tom Lane To: Robert Haas cc: Postgres-Bugs Subject: Re: surprising to_timestamp behavior In-reply-to: References: Comments: In-reply-to Robert Haas message dated "Tue, 29 Oct 2013 11:24:49 -0400" Date: Tue, 29 Oct 2013 12:03:13 -0400 Message-ID: <2726.1383062593@sss.pgh.pa.us> X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Robert Haas 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