Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgYwW-0006RD-UR for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Sep 2016 15:02:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bgYwV-0007R8-RC for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Sep 2016 15:02:43 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bgYv8-0005sd-Ae for pgsql-hackers@postgresql.org; Sun, 04 Sep 2016 15:01:18 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgYv4-0000Iu-LJ for pgsql-hackers@postgresql.org; Sun, 04 Sep 2016 15:01:17 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 77CB05F794; Sun, 4 Sep 2016 11:01:13 -0400 (EDT) Date: Sun, 4 Sep 2016 11:01:13 -0400 From: Stephen Frost To: Robert Haas , Thom Brown Cc: "pgsql-hackers@postgresql.org" Subject: Re: Add support for restrictive RLS policies Message-ID: <20160904150113.GM4028@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="RJnWrOMAazItjkl+" Content-Disposition: inline In-Reply-To: X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-91-generic (x86_64) X-Uptime: 10:22:37 up 57 days, 15:46, 9 users, load average: 0.01, 0.07, 0.07 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.1 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --RJnWrOMAazItjkl+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Robert Haas (robertmhaas@gmail.com) wrote: > On Thu, Sep 1, 2016 at 12:04 PM, Stephen Frost wrote: > > As outlined in the commit message, this adds support for restrictive RLS > > policies. We've had this in the backend since 9.5, but they were only > > available via hooks and therefore extensions. This adds support for > > them to be configured through regular DDL commands. These policies are, > > essentially "AND"d instead of "OR"d. > > > > Includes updates to the catalog, grammer, psql, pg_dump, and regression > > tests. Documentation will be added soon, but until then, would be great > > to get feedback on the grammer, catalog and code changes. >=20 > I don't like CREATE RESTRICT POLICY much. It's not very good grammar, > for one thing. I think putting the word RESTRICT, or maybe AS > RESTRICT, somewhere later in the command would be better. I had been notionally thinking RESTRICTIVE, but ended up just using RESTRICT since it was already an unreserved keyword. Of course, that's not a good reason. > I also think that it is very strange to have the grammar keyword be > "restrict" but the internal flag be called "permissive". It would be > better to have the sense of those flags match. Permissive is the default and should just be added to the grammar, so users can be explicit, if they wish to. * Thom Brown (thom@linux.com) wrote: > On 1 September 2016 at 10:02, Robert Haas wrote: > > I don't like CREATE RESTRICT POLICY much. It's not very good grammar, > > for one thing. I think putting the word RESTRICT, or maybe AS > > RESTRICT, somewhere later in the command would be better. > > > > I also think that it is very strange to have the grammar keyword be > > "restrict" but the internal flag be called "permissive". It would be > > better to have the sense of those flags match. > > > > (This is not intended as a full review, just a quick comment.) >=20 > I had proposed this sort of functionality a couple years back: > https://www.depesz.com/2014/10/02/waiting-for-9-5-row-level-security-poli= cies-rls/#comment-187800 >=20 > And I suggested CREATE RESTRICTIVE POLICY, but looking back at that, > perhaps you're right, and it would be better to add it later in the > command. Ah, I had recalled seeing something along those lines somewhere, but didn't know where, thanks. Based on Robert's suggestion and using Thom's verbiage, I've tested this out: CREATE POLICY pol ON tab AS [PERMISSIVE|RESTRICTIVE] ... and it appears to work fine with the grammar, etc. Unless there's other thoughts on this, I'll update the patch to reflect this grammar in a couple days. Thanks! Stephen --RJnWrOMAazItjkl+ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJXzDc5AAoJEO1sijiDR2RVGscP/1jIXjHGcjp+JFZbOyaGOrtr Nccl6Hzzauf77uXef3odqDXHDCdA0nXkohKTNchGq49fAaBeVOYCVOPfOsk0y6Px LhwNVU5Azmxafe7QRPTudsr3dlQDXMAl/E+cy3rt2SxN2J+ytNR23AR2Bk21Xsin dLQKqX1YN0Tt1xZi52+7eyvT0WcXLSpN6yU0fmC3nKk7maZhx9PnAeAhVMYT5Ixo 5cNvVCUx3g58Ep97Ps/PkXh1Ub/j2zOlusvBaHMW4aV5c/EfhPshr2yBtW0I84Kp ZWabfigxUejNBqyjC9FDUB9K+dbsELOBIHHGXKhXSKnnRofBw6PpcAA4e3LGixyp JVwXUyQleJ9+QMXPC7bTUIkTqCZUS2zTmmEnMGXCUlJutQrlqbxKPHwtaDweR/zz uJiVsj5zui//doEt+zEQKwnssV0N0pn4klbnU2utBB38HRJxqtLeFghbRmFkofrT 0fp10t8O/kgfxf3cszCxMODSm1HZWUTBELmS21CANuZ+RgsOnlvMJPDp4aeVzcG8 wXjaUGRIufuiLUyXfH+seSmjvAKpAdSivXlUMvN7s3QH7m1x9+bbzcNCFBcyIrq+ FSHNeBoBSN20Sx8/ZJjl/LFxC9kfdhUfi1RxdmPxBvwN6Z/X7y6fANS/g7/ONZN/ KWy4Vr5LnskiFxmiOD1F =aEzx -----END PGP SIGNATURE----- --RJnWrOMAazItjkl+--