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 1j8sLa-0004CH-LQ for pgsql-general@arkaria.postgresql.org; Mon, 02 Mar 2020 21:11:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j8sLY-0002bd-AH for pgsql-general@arkaria.postgresql.org; Mon, 02 Mar 2020 21:11:28 +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 1j8sLW-0002at-4n for pgsql-general@lists.postgresql.org; Mon, 02 Mar 2020 21:11:28 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j8sLS-0000iQ-Tc for pgsql-general@lists.postgresql.org; Mon, 02 Mar 2020 21:11:24 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C4130218BB; Mon, 2 Mar 2020 16:11:21 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 02 Mar 2020 16:11:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=I zgUXGsHAKPXLZxbOkF68itln99W8U4qMOXzK3LCmw8=; b=cLm8kB8WuU1S09VQl sxOyAsLw9yd27ChcYbhfDJmkt2dWavkHeO55lH+Om9bqju2OmRQgoPlmctD7ft9C M7UJqZfG/NWyvN1/B3az15oMq1KlggKMf2umC1G2vfgdYRe8KXjRlGbbuwFcXQ/C /6cJZShCvcvA70Hn8LcwIp1Vj9XshwC7f4SSq7R52k7/3veveZlHIFzgoJOcQuPe 2yDnGa7QFM6KvhStwWL0fapeIpuQyj8T5l7wm+XylkQzrCZbjQe3OtzLlHkmp5Au SuvSSqiYcN0VCFC8mx5PzVGdhEae3tb00aToWLDQi9f/noAymbiGVzUBjkRrk3t3 MsNeg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=IzgUXGsHAKPXLZxbOkF68itln99W8U4qMOXzK3LCm w8=; b=Mq91GE/8uc1ltV968fFvkeSkFde7syLI/iCdEy42OzwJV0kFBKn19fPKj nPfjxHGfemSp1hF16/2o54t3UEmcnVwgGwZyr16tUAbqq3isOBE3cmFmI+IeW4FR jVeNcU6tRlVnkTRzX3akSdkNie5qJ/8YWHTmC3ZSmIBoO+psZ6d2AeTVrHp4j0zf QUh10UPqCLq3ZBkbGTQ3mam9WpviDNFOK5sxpxaQ61v4JRurKcnWHkSXVz29xQx1 CuyQLJQQkx6Pnx639XJ2+8341qGqoQALUn14AglXES2fm4Y3Zy5/4Af4SjJlxnTM dqCpbdLwRzVkdhwra0wXHVrBk1BTw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddtgedgudegjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesth ejredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdr khhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepphhoshhtghhrvg hsqhhlrdhorhhgnecukfhppeejuddrvdduvddruddvledrudelfeenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvg hrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id EFC7C328005A; Mon, 2 Mar 2020 16:11:20 -0500 (EST) Subject: Re: Detecting which columns a query will modify in a function called by a trigger To: stan Cc: pgsql-general@lists.postgresql.org References: <20200302185904.GA6528@panix.com> <30c3c06e-61fa-3210-666d-1696af320a75@aklaver.com> <20200302202829.GA19161@panix.com> From: Adrian Klaver Message-ID: Date: Mon, 2 Mar 2020 13:11:19 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200302202829.GA19161@panix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/2/20 12:28 PM, stan wrote: > 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. Yeah, I'm going to go with the other commenters and say this design needs work. My feeling is that if there is a division of labor it should be reflected in the tables. To me it seems easier to build a overall look from smaller units, then trying to decompose a larger unit into smaller units of work. > > 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? > -- Adrian Klaver adrian.klaver@aklaver.com