Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iuf8k-0003oO-OE for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2020 16:15:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iuf8j-0007bb-4F for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2020 16:15:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iuf8i-0007bU-Ru for pgsql-hackers@lists.postgresql.org; Thu, 23 Jan 2020 16:15:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iuf8g-0003g1-MR for pgsql-hackers@lists.postgresql.org; Thu, 23 Jan 2020 16:15: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 00NGFNag011267; Thu, 23 Jan 2020 11:15:23 -0500 From: Tom Lane To: Alvaro Herrera cc: Arthur Zakirov , Juan =?iso-8859-1?Q?Jos=E9_Santamar=EDa?= Flecha , Tomas Vondra , PostgreSQL Hackers Subject: Re: Allow to_date() and to_timestamp() to accept localized names In-reply-to: <20200123155552.GA20980@alvherre.pgsql> References: <20200123155552.GA20980@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Thu, 23 Jan 2020 12:55:52 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11265.1579796123.1@sss.pgh.pa.us> Date: Thu, 23 Jan 2020 11:15:23 -0500 Message-ID: <11266.1579796123@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2020-Jan-22, Tom Lane wrote: >> Arthur Zakirov writes: >>> Shouldn't we just show all remaining string instead of truncating it? >> That would avoid a bunch of arbitrary decisions, for sure. >> Anybody have an objection? > I think it would be clearer to search for whitespace starting at the > start of the bogus token and stop there. It might not be perfect, > particularly if any language has whitespace in a month etc name (I don't > know any example but I guess it's not impossible for it to exist; > Portuguese weekday names maybe?), but it seems better than either of the > behaviors shown above. I'm okay with that. It won't work so well for cases like "1-Januzry-1999", but it's still better than what happens now: regression=# select to_date('1-Januzry-1999', 'DD MONTH YYYY'); ERROR: invalid value "Januzry-1" for "MONTH" That particular case could be improved by stopping at a dash ... but since this code is also used to match strings like "A.M.", we can't just exclude punctuation in general. Breaking at whitespace seems like a reasonable compromise. regards, tom lane