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 1j9BZG-0003d3-Uq for pgsql-general@arkaria.postgresql.org; Tue, 03 Mar 2020 17:42:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9BZF-0003tk-PU for pgsql-general@arkaria.postgresql.org; Tue, 03 Mar 2020 17:42:53 +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 1j9BZF-0003td-CC for pgsql-general@lists.postgresql.org; Tue, 03 Mar 2020 17:42:53 +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 1j9BZD-00025D-0G for pgsql-general@lists.postgresql.org; Tue, 03 Mar 2020 17:42:52 +0000 Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mailbackend.panix.com (Postfix) with ESMTP id 48X4952nzQz1W8p; Tue, 3 Mar 2020 12:42:48 -0500 (EST) Received: by panix5.panix.com (Postfix, from userid 17622) id 48X4945m8gzfYm; Tue, 3 Mar 2020 12:42:48 -0500 (EST) Date: Tue, 3 Mar 2020 12:42:48 -0500 From: stan To: "David G. Johnston" Cc: pgsql-general@lists.postgresql.org Subject: Re: Detecting which columns a query will modify in a function called by a trigger Message-ID: <20200303174248.GB5019@panix.com> References: <20200302185904.GA6528@panix.com> <30c3c06e-61fa-3210-666d-1696af320a75@aklaver.com> <20200302202829.GA19161@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Editor: gVim List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Mar 02, 2020 at 01:44:52PM -0700, David G. Johnston wrote: > On Mon, Mar 2, 2020 at 1:28 PM stan wrote: > > > 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? > > > > On a theory level this design is insufficiently normalized. The fact that > you are having issues and challenges working with it suggests you should > seriously consider a different design, one that exhibits better > normalization properties. > > Alternatively you might consider just removing direct access to the table > and provide views and/or functions that can use normal permission grants. > Add some check constraints to the table to describe and enforce the > inter-field relationships that are present. > Thanks for the input. I have, indeed created views that restrict the subset of columns that a particular job function needs access to to the appropriate ones, but unfortunately to the best of my knowledge, I cannot INSERT/UPDATE a table through a view. Am I suffering from a lack of knowledge here? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin