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 1iwWgX-0001mp-CA for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jan 2020 19:38:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iwWgW-00080z-2O for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jan 2020 19:38:04 +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 1iwWgV-00080r-PY for pgsql-hackers@lists.postgresql.org; Tue, 28 Jan 2020 19:38:03 +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 1iwWgO-0006tf-RN for pgsql-hackers@lists.postgresql.org; Tue, 28 Jan 2020 19:38:03 +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 00SJbotg027211; Tue, 28 Jan 2020 14:37:50 -0500 From: Tom Lane To: Mark Dilger cc: Peter Eisentraut , =?utf-8?Q?Juan_Jos=C3=A9_Santamar=C3=ADa_Flecha?= , Alvaro Herrera , Arthur Zakirov , Tomas Vondra , PostgreSQL Hackers Subject: Re: Allow to_date() and to_timestamp() to accept localized names In-reply-to: <06220D86-5D3B-4EAA-860D-4328F926010F@enterprisedb.com> References: <20200124161814.GA8989@alvherre.pgsql> <32487.1579882979@sss.pgh.pa.us> <2f83150e-a2c0-6318-3125-d9b86e421aa2@2ndquadrant.com> <964.1579884408@sss.pgh.pa.us> <7212.1580177517@sss.pgh.pa.us> <2E3D8D71-3B55-4735-A047-1FECE1506CD1@enterprisedb.com> <6642.1580223087@sss.pgh.pa.us> <4144A0A0-4820-458D-A105-D5EC0E0D133B@enterprisedb.com> <15575.1580232642@sss.pgh.pa.us> <06220D86-5D3B-4EAA-860D-4328F926010F@enterprisedb.com> Comments: In-reply-to Mark Dilger message dated "Tue, 28 Jan 2020 11:05:09 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <27209.1580240270.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 28 Jan 2020 14:37:50 -0500 Message-ID: <27210.1580240270@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Mark Dilger writes: >> On Jan 28, 2020, at 9:30 AM, Tom Lane wrote: >> A brute-force answer, if there are few enough cases, is to recognize >> them regardless of the specific value of LC_TIME. Do we think >> anybody would notice or care if to_date('Sonnabend', 'TMDay') works >> even when in a non-German locale? > I think this only becomes a problem if there are weekday or month name c= ollisions between languages where they have different meanings. As an abs= urd hypothetical, if =E2=80=9CSunday=E2=80=9D in Tagalog means what =E2=80= =9CTuesday=E2=80=9D means in English, then you=E2=80=99ve got a problem. > This does happen for month abbreviations. =E2=80=9CMar=E2=80=9D is shor= t for =E2=80=9CMarch=E2=80=9D and variations in a number of languages, but= short for =E2=80=9CNovember=E2=80=9D in Finnish. > For day abbreviations, =E2=80=9CSu=E2=80=9D collides between fi_FI and h= r_HR, and =E2=80=9Ctor=E2=80=9D collides between sl_SL and no_NO. But none of those cases are alternative names, so we wouldn't have entries for them in this hypothetical list. They'd only be recognized when strftime() returns them. I suspect also that the abbreviated names have few if any alternatives, so we may only need this whole hack for full names. A possible way of tightening things up without explicitly decoding the locale name is to make the entries of the list be string pairs: "if strftime() returned this, then also consider that". That puts a bit of a premium on knowing which names strftime considers primary, but I think we'd have had to know that anyway. regards, tom lane