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 1iv22a-0005Ii-G1 for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Jan 2020 16:42:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iv22Z-0006RG-3N for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Jan 2020 16:42:39 +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 1iv22Y-0006R9-QZ for pgsql-hackers@lists.postgresql.org; Fri, 24 Jan 2020 16:42:38 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iv22V-00078Z-8p for pgsql-hackers@lists.postgresql.org; Fri, 24 Jan 2020 16:42:37 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id E79B421B24; Fri, 24 Jan 2020 11:42:33 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Fri, 24 Jan 2020 11:42:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=UL+3PMNFkToPdFIQTFb7Y9s9s2ipEYtFhs+U+4kg3 F4=; b=JkWMFCtjgWFsNpTNZ2qaNngWosB3uJ60AkoeMdmNC/k8K28LifBAS1FGr Xuw/iJZ8IpMuXD1Gco6TGTUl+nVInnmiNS6h6MN7NZngRHiMWDCOdeJzayg0iqf5 +iMqgU11PJPdDgBvBqXd0qS8ImORzByvwhgpBLdLDTzunAB9YuK0JQ9UAxLql7su emLju6/FbgCxtiyy5ekJi/3CjOPFB0qYpVDriI3Rf7/9XhigOCJKPTmM/2wCxc0h h4M+LS67mni5QotGpCPCC4Q2Qsps/bGns2kRr+zsXIVlnvceKQOEmj9Ad8D+yFd9 fcF+DLhYPTOhmzvEBuqCpVAxQygLw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrvdeggdeltdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhfhokffffgggjggtgfesthekredttdefjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsedvnhguqh hurggurhgrnhhtrdgtohhmqeenucffohhmrghinhepvdhnughquhgrughrrghnthdrtgho mhenucfkphepleefrddvgedvrddvheehrdduuddvnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgruhhtsedv nhguqhhurggurhgrnhhtrdgtohhm X-ME-Proxy: Received: from april.pezone.net (p5df2ff70.dip0.t-ipconnect.de [93.242.255.112]) by mail.messagingengine.com (Postfix) with ESMTPA id 9CB933061248; Fri, 24 Jan 2020 11:42:32 -0500 (EST) Subject: Re: Allow to_date() and to_timestamp() to accept localized names To: Tom Lane , Alvaro Herrera References: <20200124161814.GA8989@alvherre.pgsql> <32487.1579882979@sss.pgh.pa.us> Cc: =?UTF-8?Q?Juan_Jos=c3=a9_Santamar=c3=ada_Flecha?= , Arthur Zakirov , Tomas Vondra , PostgreSQL Hackers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <2f83150e-a2c0-6318-3125-d9b86e421aa2@2ndquadrant.com> Date: Fri, 24 Jan 2020 17:42:31 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <32487.1579882979@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-01-24 17:22, Tom Lane wrote: > Alvaro Herrera writes: >> But that's a different POV. The input to this function could come from >> arbitrary user input from any application whatsoever. So the only >> reason we can get away with that is because the example regression case >> Juan José added (which uses non-normals) does not conform to the >> standard. > > I'm unsure about "conforming to standard", but I think it's reasonable > to put the onus of doing normalization when necessary on the user. > Otherwise, we need to move normalization logic into basically all > the string processing functions (even texteq), which seems like a > pretty huge cost that will benefit only a small minority of people. > (If it's not a small minority, then where's the bug reports complaining > that we don't do it today?) These reports do exist, and this behavior is known. However, the impact is mostly that results "look wrong" (looks the same but doesn't compare as equal) rather than causing inconsistency and corruption, so it's mostly shrugged off. The nondeterministic collation feature was introduced in part to be able to deal with this; the pending normalization patch is another. However, this behavior is baked deeply into Unicode, so no single feature or facility will simply make it go away. AFAICT, we haven't so far had any code that does a lookup of non-ASCII strings in a table, so that's why we haven't had this discussion yet. Now that I think about it, you could also make an argument that this should be handled through collation, so the function that looks up the string in the locale table should go through texteq. However, this would mostly satisfy the purists but create a bizarre user experience. Looking through the patch quickly, if you want to get Unicode-fancy, doing a case-insensitive comparison by running lower-case on both strings is also wrong in corner cases. All the Greek month names end in sigma, so I suspect that this patch might not work correctly in such cases. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services