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 1j8s1V-0003Yu-3f for pgsql-general@arkaria.postgresql.org; Mon, 02 Mar 2020 20:50:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j8s1T-0004R3-Q3 for pgsql-general@arkaria.postgresql.org; Mon, 02 Mar 2020 20:50: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_SHA1:256) (Exim 4.89) (envelope-from ) id 1j8s1T-0004Qw-EH for pgsql-general@lists.postgresql.org; Mon, 02 Mar 2020 20:50:43 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j8s1Q-000256-9u for pgsql-general@lists.postgresql.org; Mon, 02 Mar 2020 20:50:43 +0000 Received: by mail-pg1-x541.google.com with SMTP id a14so385035pgb.11 for ; Mon, 02 Mar 2020 12:50:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:in-reply-to:message-id:date :mime-version; bh=QhDgyC6QAPZwOBBBsthqbMqGlJXPw6PQRVTrY9dudM4=; b=rvQuhKeTja5WLFdrjNlvOSDg6s7/SqfNeQbn9I/QCgr6VCRUNkjsef+q3Z/nK696sV 1nC8QdohiYxCtcM9F2QNwVypC2m3aIGWIAzedrvcD1QkR6ITVxE6pEWtOrxLX2iBE4Rk zM6vIH6rWxiERfbxXohQWeadxDlgsHb/IKTErdd37v7MQbsG5vXAh++mw209rLbMNw9V /LHyhnINCj9N0fd5OY6VZ/8XDWmKRfkeZY3XmyQBKyO2QXQHGHNbRnm/Dw58JnPiIqH8 cUCeASZcpGrEHSlu/roN8l4ez8/JkygQnZr6UqFDwo/crU6Isy8cjv76uBAC7Te9hZWk 6Jsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject :in-reply-to:message-id:date:mime-version; bh=QhDgyC6QAPZwOBBBsthqbMqGlJXPw6PQRVTrY9dudM4=; b=q+syTylmCej6qtKoc18sogl2/Qm0nyo7HMV/QDIw3uYT6L/1z4qw05q+bohyuRptnK M8u95NJiY7aekLRYWWhdmRd3GK6bUdfzRsedDzgh+BG9T+Eqj0XWo+WHrxCNjiYNouy+ 7A7I5hofx42iMIfm9t0zGZyuD557FqcL3+JYy+/de/I3F+La+jxCRuLNWAP49hCqo07P XH1UKaEV9hJ2j6ADbvMillgImVsfSGgQLfQ+39R8aasP7466GH13halQhPuzHyr4RU0E q8lECT8/6BmZUGi75yiPcbFXMWUFN0hM3Iv6moU43awJ/h0ScuiRwZJ47l66ionvcSU9 ck2Q== X-Gm-Message-State: ANhLgQ1ZxomvnH/4gGRpI3MijHhhgPRyGn57SBAstSZSKyraks+BLzE6 SuoAQ5rEGNvGbqKYiRtOy9g1vu/d X-Google-Smtp-Source: ADFU+vvWIZktxM1iAAEfonCyU4oKTq+pJuYwpc62GVNvWiugPxL1Cc8zmB++Wk6h/fZ9sXM6G3bD4Q== X-Received: by 2002:a62:f842:: with SMTP id c2mr813292pfm.104.1583182238137; Mon, 02 Mar 2020 12:50:38 -0800 (PST) Received: from tim-desktop (203-173-31-248.dyn.iinet.net.au. [203.173.31.248]) by smtp.gmail.com with ESMTPSA id q66sm20161415pgq.50.2020.03.02.12.50.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 12:50:37 -0800 (PST) References: <20200302185904.GA6528@panix.com> <30c3c06e-61fa-3210-666d-1696af320a75@aklaver.com> <20200302202829.GA19161@panix.com> User-agent: mu4e 1.3.9; emacs 27.0.90 From: Tim Cross To: pgsql-general@lists.postgresql.org Subject: Re: Detecting which columns a query will modify in a function called by a trigger In-reply-to: <20200302202829.GA19161@panix.com> Message-ID: <871rqatrae.fsf@gmail.com> Date: Tue, 03 Mar 2020 07:50:33 +1100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk stan writes: > 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? When you speak of columns needing to be created/modified, do you really mean columns or rows? It would be a very unusual approach to allow multiple different 'agencies' to create/modify underlying table design. If this is the case, then you are in an impossible position and have no hope of implementing anything that will be maintainable and you will never be able to manage security. I'm hoping you mean different agencies which need to add/modify rows wihtin the tables? -- Tim Cross