Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJLHT-00080y-N6 for pgsql-general@arkaria.postgresql.org; Thu, 26 Aug 2021 19:43:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mJLHS-00039N-GU for pgsql-general@arkaria.postgresql.org; Thu, 26 Aug 2021 19:43:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJLHS-00039F-7p for pgsql-general@lists.postgresql.org; Thu, 26 Aug 2021 19:43:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJLHN-0004NU-4N for pgsql-general@lists.postgresql.org; Thu, 26 Aug 2021 19:43:17 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 17QJhARL673097; Thu, 26 Aug 2021 15:43:10 -0400 From: Tom Lane To: Peter Eisentraut cc: "David G. Johnston" , Christophe Pettus , "pgsql-generallists.postgresql.org" Subject: Re: lower() and unaccent() not leakproof In-reply-to: <7eb0e72c-d638-a223-858c-24ce29f1f2e8@enterprisedb.com> References: <02BDFCCF-BDBB-4658-9717-4D95F9A91561@thebuild.com> <648381.1629986401@sss.pgh.pa.us> <7eb0e72c-d638-a223-858c-24ce29f1f2e8@enterprisedb.com> Comments: In-reply-to Peter Eisentraut message dated "Thu, 26 Aug 2021 17:06:23 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <673095.1630006990.1@sss.pgh.pa.us> Date: Thu, 26 Aug 2021 15:43:10 -0400 Message-ID: <673096.1630006990@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > I think the complexity of the implementation of upper() and lower() is > on the same order as bttextcmp() and similar, so it wouldn't be totally > out of scope. True. But you'll recall that the decision to mark bttextcmp() and cohorts as leakproof was not made without fear. IMV, that decision did not rest simply on code review but on two arguments about why we should take the risk: * The query-optimization usefulness of having those be leakproof is extremely high. * btree comparison functions should really not have any user-reachable failure modes (which comes close to being the definition of leakproof). If one did, that would mean there were legal values of the type that couldn't be put into a btree index. Maybe similar arguments can be made about upper/lower, but I think it's a far weaker case. As for unaccent, the fact that it relies on user-controllable definitions seems to me to make it almost certainly unsafe to be leakproof. regards, tom lane