Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3CnD-0008QD-Ax for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Apr 2018 03:39:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3CnC-0007mg-17 for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Apr 2018 03:39:30 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3CnB-0007mR-OD for pgsql-bugs@lists.postgresql.org; Tue, 03 Apr 2018 03:39:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3Cn4-00030p-Va for pgsql-bugs@lists.postgresql.org; Tue, 03 Apr 2018 03:39:28 +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 w333dLOT008934; Mon, 2 Apr 2018 23:39:21 -0400 From: Tom Lane To: "David G. Johnston" cc: defanor@uberspace.net, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15141: Faulty ISO 8601 parsing In-reply-to: References: <152271186941.1442.12179299369295226185@wrigleys.postgresql.org> <32337.1522714669@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Mon, 02 Apr 2018 17:46:21 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <8932.1522726760.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Mon, 02 Apr 2018 23:39:20 -0400 Message-ID: <8933.1522726760@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" writes: > On Mon, Apr 2, 2018 at 5:17 PM, Tom Lane wrote: >> I think you meant that this fails: >> # select '2018-04-03T01:45:00,728456785+0000'::timestamp with time zone; >> ERROR: invalid input syntax for type timestamp with time zone: >> "2018-04-03T01:45:00,728456785+0000" >> which it does, but I don't think we should do anything about it. >> There is not and never has been any dependency on LC_TIME properties in >> PG's timestamp I/O. Considering that we also have DateStyle to cope with, >> as well as a lot more flexibility in the input parser than ISO 8601 >> contemplates, I think allowing a comma instead of decimal point here >> would probably create more confusion than benefit. > ​Ideally it would be as simple as: > - /* Leading decimal point? Then fractional seconds... */ > - else if (*cp == '.') > + /* Leading decimal point or comma? Then fractional seconds... */ > + else if (*cp == '.' || *cp == ',') Well, it's not. The core problem here is that the datetime input parser treats commas as ignorable punctuation, equivalent to whitespace. For instance, we accept # select 'sunday, april 1, 2018'::timestamp; timestamp --------------------- 2018-04-01 00:00:00 (1 row) but not # select 'sunday. april 1, 2018'::timestamp; ERROR: invalid input syntax for type timestamp: "sunday. april 1, 2018" But surely it would not be a good idea to consider "T01:45:00,728456785" the same as "T01:45:00 728456785". Changing this would entail all sorts of side-effects on non-ISO data formats. Considering that this code is about old enough to vote, and this is the first complaint on this specific issue that I can recall hearing, I don't even think it's worth the time to investigate just what the side-effects would be ... there's no way that any proposed change would get past the backwards-compatibility hurdles. regards, tom lane