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 1hxeW0-0004fQ-5a for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2019 21:39:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxeVz-0000Qw-2D for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2019 21:39:35 +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 1hxeVy-0000Qo-Om for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2019 21:39:34 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxeVv-0001IP-JB for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2019 21:39:34 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 4B6305F79F; Tue, 13 Aug 2019 17:39:30 -0400 (EDT) Date: Tue, 13 Aug 2019 17:39:30 -0400 From: Stephen Frost To: Derek Hans Cc: Tom Lane , pgsql-general@lists.postgresql.org Subject: Re: GIST/GIN index not used with Row Level Security Message-ID: <20190813213930.GO16436@tamriel.snowman.net> References: <12552.1565723566@sss.pgh.pa.us> <14241.1565725716@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="c60Aklyj4jgaOXzU" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --c60Aklyj4jgaOXzU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Derek Hans (derek.hans@gmail.com) wrote: > Unfortunately only "alter function" supports "leakproof" - "alter operato= r" > does not. Is there a function-equivalent for marking operators as > leakproof? Is there any documentation for which operators/functions are > leakproof? Tom's query downthread provides the complete list. Note that the list is not completely static- it's entirely possible that additional functions can be made leak-proof, what's needed is a careful review of the function code to ensure that it can't leak information about the data (or, if it does today, a patch which removes that). If you have an interest in that then I'd encourage you to dig into the code and look for possible leaks (Tom's already hinted in the direction you'd want to go in) and then propose a patch to address those cases and to mark the function(s) as leakproof. > In my particular case, RLS is still useful even if operators are leaky as= I > control the application code and therefore can ensure leaky errors are > handled. If it's possible to disable all checking for "leakproof", that > would work for me. There isn't a way to disable the leakproof-checking system. Certainly in the general case that wouldn't be acceptable and I'm not entirely convinced by your argument that such an option should exist, though you could go through and set all of the functions to be leakproof if you really wish to. > > If that's not possible, it sounds like it > > > effectively blocks the use of GIN/GIST indexes when RLS is in use. > > > > There's a whole lot of daylight between "it doesn't pick an indexscan in > > this one example" and "it effectively blocks the use of GIN/GIST". >=20 > True indeed :). Would you have a working example of using a GIN/GIST index > with RLS? All the attempts I've made have ended in seq scans. In practice, > I'm looking to implement fuzzy search using trigrams, so % and %> operato= rs > are what matter to me. ~~ also happens to fail. Should I expect to be able > to use any of these with RLS, large amounts of data and reasonable > performance? Functions that aren't marked leakproof aren't going to be able to be pushed down. > Your description of leakproof (and the documentation I've found) makes it > sound like I'm not just hitting an isolated problem, but a general problem > with RLS that represents a substantial limitation and is likely worth > documenting. There's some documentation regarding leakproof functions here: https://www.postgresql.org/docs/current/ddl-rowsecurity.html and here: https://www.postgresql.org/docs/11/sql-createfunction.html Of course, patches are welcome to improve on our documentation. One thing that it sounds like you're not quite appreciating is that in the general case, verifying that a function is leakproof isn't optional. Without such a check, any user could create a function and then get PG to push that function down below the RLS checks and therefore gain access to the data that they aren't supposed to be able to see. All that said, there's quite a few functions that *are* marked as leakproof already and they're quite handy and work well with RLS already, as I expect you'll see when you go querying pg_proc. Thanks, Stephen --c60Aklyj4jgaOXzU Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJdUy4RAAoJEO1sijiDR2RVUcQP+wf2hgMn2Qp7WjTGSrr2dtqY I81ghcPqtWXH9oVGar8OM7K5qBSFc/KxTnt2arnhqg77jdYPpHs2NTxUg89drz71 3ejqK+h6rbgoB264CXRJCqHQ3RszqutTsifj2ZQaZ2Iuosb106Ub6ePyeBDV7nDq Vqz/1aWWyVhix7vpZ8+k+AjHk+CUaA5ZPSixQCEzDs9JOGi800aoSSGJKjl8O6AR +iccByprOLkY1WLoN1EZnPWjobqjdqUuACnpuvYBZbFhhUYKjezO2tJ2uBoH3Ncs uyIU/vqW3zhXjIAo4oR7Tnx3r6uULaqyhcqd9jdlNHW1FWc6D48K4BtEqv3zJLqU bOCmco45t/wJROy0qqXpJjRMDPbzSb9IBB4lWC6xCEuG/GFSIEIpQH/P2Hylc1hQ rlCW7/5Y8Lp4MpLrs8gH/MJsE1hYJAzU1hBFy2yytMQfymaDRp+uXp6X61MQi2Aw UZuucxcfaQRToij1xi/ndAJ/hL4CP0dngJzio9W54xUjf68fYlhRw0J5zW4CTvKl dks45o+deTwmnv8dgatC0MRu7uALrlD9cWLzXhdVGk4GGLaXo5WYG1wmBJKJ6l+z 4Sg2NCAwMVyjTFu1Co47L5QtAvsMF3lPV6JDcU9iGDhKJGJNg3rBBo2hSmG1z7Cq 3g7cZva2+nJnM2q0pitX =/mge -----END PGP SIGNATURE----- --c60Aklyj4jgaOXzU--