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.92) (envelope-from ) id 1j8rg4-0002uN-UT for pgsql-general@arkaria.postgresql.org; Mon, 02 Mar 2020 20:28:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j8rg3-0001D9-PZ for pgsql-general@arkaria.postgresql.org; Mon, 02 Mar 2020 20:28:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j8rg3-0001D2-D4 for pgsql-general@lists.postgresql.org; Mon, 02 Mar 2020 20:28:35 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j8rfz-0000IS-Pk for pgsql-general@lists.postgresql.org; Mon, 02 Mar 2020 20:28:33 +0000 Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mailbackend.panix.com (Postfix) with ESMTP id 48WWtk2Hgcz15Cg; Mon, 2 Mar 2020 15:28:30 -0500 (EST) Received: by panix5.panix.com (Postfix, from userid 17622) id 48WWtk0XyfzfYm; Mon, 2 Mar 2020 15:28:30 -0500 (EST) Date: Mon, 2 Mar 2020 15:28:29 -0500 From: stan To: Adrian Klaver Cc: pgsql-general@lists.postgresql.org Subject: Re: Detecting which columns a query will modify in a function called by a trigger Message-ID: <20200302202829.GA19161@panix.com> References: <20200302185904.GA6528@panix.com> <30c3c06e-61fa-3210-666d-1696af320a75@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <30c3c06e-61fa-3210-666d-1696af320a75@aklaver.com> X-Editor: gVim List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Mar 02, 2020 at 11:02:54AM -0800, Adrian Klaver wrote: > On 3/2/20 10:59 AM, stan wrote: > > I need to implement a fairly fine grained security model. Probably a bit > > finer that I can do with the standard ownership functionality. > > > > My thinking on this is to create a table that contains the users, and a > > "permission bit" for each function that they may want to do, vis a vi > > altering an existing row,or rows, or inserting new rows. > > > > Looks relatively straight forward, if fairly time consuming to do. But I > > would need to know which column(s) a given query would add..alter from the > > function to implement this via a trigger. looks like I see most of what I > > need t do this in the docs, but I can't quite figure out if I can get this > > down to what column(s) a given trigger will modify. Is this possible? > > Before you get too far into this I would look at RLS: > > https://www.postgresql.org/docs/12/ddl-rowsecurity.html > Thanks for pointing that out. Using that functionality was my original plan, but let me describe why I do not think it can do what I need. This may be an indication of my weakness in design though. Envision a table with a good many columns. This table represents the "life history" of a part on a project. Some of the columns need to be created/modified by the engineer. Some need to be created/modified by the purchasing agent, some of the columns need to be created by the receiving department, some of the columns need to be created/modified by the accounts payable department. Make sense? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin