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 1icQxH-0004wI-Vh for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Dec 2019 09:28:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icQxF-0003Rb-An for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Dec 2019 09:28:17 +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 1icQxE-0003RT-TX for pgsql-bugs@lists.postgresql.org; Wed, 04 Dec 2019 09:28:17 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icQxB-0005YS-L6 for pgsql-bugs@lists.postgresql.org; Wed, 04 Dec 2019 09:28:16 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 36CF121C2527; Wed, 4 Dec 2019 12:28:12 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.200] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 0C2C921C24BA; Wed, 4 Dec 2019 12:28:12 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1575451692; bh=g+V6yDupbduHpaCc/sXa+CcTIdSvdm2TcV7sTrgWTRo=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=eJgLaoVUkC1gc/owXA/bJALn1e2QqvnMxn5E9LZRNDOChcsyrf930MMkxIBwGGl29 G0bA3uS8Yv+F7CHFVlQ6ZIXTmeFRBp27aJfaWZ4QJc9+isSD1qcjRecSKNiD44gYdh vdctRk9tKT5rDnPjKjCMkXvsEHJ5a0sYZlztIKXU= Subject: Re: Numeric is not leakproof To: Stephen Frost Cc: pgsql-bugs@lists.postgresql.org References: <13a01430-672d-c73c-7abe-0b70e9e8aa01@postgrespro.ru> <20191203204311.GU6962@tamriel.snowman.net> From: Konstantin Knizhnik Message-ID: Date: Wed, 4 Dec 2019 12:28:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20191203204311.GU6962@tamriel.snowman.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03.12.2019 23:43, Stephen Frost wrote: > Greetings, > > * Konstantin Knizhnik (k.knizhnik@postgrespro.ru) wrote: >> Numeric functions are not marked as leakproof in pg_proc.dat >> It cause unexpected behavior in case of using row-level security: > The behavior you're getting is *entirely* expected, just to be clear. > Perhaps unfortunate and not as performant as you were hoping, but > definitely not unexpected. > > As Tom noted downthread, you can't just mark things 'leakproof' because > you want them to be able to be used in an index- you need to actually > show that they're leakproof. > >> I have not checked all other builtin type. >> But it seems to me that it may be reasonable to mark ALL builtin functions >> (described in pg_proc.dat) as leekprof by default. > Absolutely not without careful verification of each and every one. > There's nothing that guarantees builtins are leakproof (and indeed, > there's no shortage of ones that are clearly *not* leakproof today). > > I'd love it for someone to go through and fix them all to actually be > leakproof (or at least all of the ones that might be used with an index) > but that clearly hasn't been done here. Ok, I understand that it is not possible just to mark all built-in functions as leak proof, but what about marking as leakproof just comparison functions for the numeric type as I proposed in the attached patch? I have checked that cmp_numerics can not report any errors and so it can be considered as leekprof as far as comparison functions for most of other builtin types which are already marked as leakproof. After applying this patch opr_sanity test is failed (just because list of leakproof functions is extended, so expected result for this test should also be updated). -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company