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.89) (envelope-from ) id 1hxGje-00088b-RN for pgsql-general@arkaria.postgresql.org; Mon, 12 Aug 2019 20:16:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxGjd-0005tn-DE for pgsql-general@arkaria.postgresql.org; Mon, 12 Aug 2019 20:16:05 +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 1hxGjb-0005qC-BK for pgsql-general@lists.postgresql.org; Mon, 12 Aug 2019 20:16:05 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hxGjT-0005an-Rx for pgsql-general@lists.postgresql.org; Mon, 12 Aug 2019 20:16:02 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 13E553F0; Mon, 12 Aug 2019 16:15:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 12 Aug 2019 16:15:54 -0400 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=fm3; bh=P Rzn906jnzfE7LaXXUC6X2pwhJ67hslwoTvSFbGj/t4=; b=Y383at9fLCPJSA5Cw v6tlyY8WaAbocBdq/Ah1JZ0IJhBU+bYc7yl0wtW7uDysdErJLJFN6tKbCjHTwvGI y5McWE0aoTNeSszguZVZZAs7BDJ5YY7hXz5kzIjTZr6bzCLgN5RINu67cJqNLtd5 0wbnQPeb3D5BFwZ5QQE6DGeclXboEp2D9RMLCjW6uoDFvoZET/JFYoIXItki2zWk Y8FATO+tKVtY7AAnJzi1GF3V4WJip7ZRAJ2k2NrooEcttfhN2A6Sqz6+NrXNPGgd OYtVdWqex/abtfRiEENZoadtWYBJPqJL5cuz+H3/TbYEYzDWAlLEdkBQxiE/3Xpq Z4bfg== 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=fm3; bh=PRzn906jnzfE7LaXXUC6X2pwhJ67hslwoTvSFbGj/ t4=; b=iEH6dbJ0pw5W9ccAA1VVuclVzsfZf7XZfNP2Z20IVy6Q3odWipVrdKEiM jtkIa7ze8vHYA1NbLAxxvSguLTEgFYhooGBkKS032idjXiK+utfiSTK4XXOWv6yu zvo8f/OFIcFtgZB7491twcPC+uEXlKUKyNqY9QrvZxK+fQRVwNN4JNrLzq9IBqHO elX85nFtcnubQ4TQxueJcBl1n49Uh+LXUApTgzqWEQma7bdmy2z5Iybh2szwoT0E XOXTmCxcvFxxKFX2vBGDMegPQGodJvpX2WIsGVyBmsk5kLPCJfV5QJImNOPjiEfM Ki/WiTpUgrgRucRavDHrN0A8LTeMA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddruddvgedgudegjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesth ejredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdr khhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepphhoshhtghhrvg hsqhhlrdhorhhgnecukfhppeejuddrvdduvddrudehtddrvddtvdenucfrrghrrghmpehm rghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenuc evlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id CD8AB80062; Mon, 12 Aug 2019 16:15:52 -0400 (EDT) Subject: Re: "Locking rows" To: stan Cc: pgsql-general@lists.postgresql.org References: <20190812175133.GC681@panix.com> <20190812200730.GA19994@panix.com> From: Adrian Klaver Message-ID: <28137052-82f2-48c7-d4d4-6ff7ae70dcf0@aklaver.com> Date: Mon, 12 Aug 2019 13:15:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190812200730.GA19994@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 8/12/19 1:07 PM, stan wrote: > On Mon, Aug 12, 2019 at 12:14:25PM -0700, Adrian Klaver wrote: >> On 8/12/19 10:51 AM, stan wrote: >>> I have a customer requirement/desire. The system is (among other things) >>> essentially a employee time sheet. The manager wants for an employee to not >>> be able to modify a given row in the table they enter time into once it is >>> committed. I personally see issues with this, but I am willing to try to give >>> him what he wants. If it creates issues we can sort them out, once he sees >>> the issues. >>> >>> The only way I see to do this is to add a column (call it lock). I will >>> then set this up as a default entry with a value of TRUE. The form the >>> employee uses to enter this will, of course, not display this column. The >>> I will create a function that on UPDATE, checks for the presence of the 1 in >>> this row, and rejects the update. Then I will give the manager a form where >>> he can set this flag to FALSE. >>> >>> Looks ugly, and convulsed to me. >>> >>> Is here a more "database native" way to handle this? >> >> Depends on who is doing the database record changes. >> >> In other words are there defined roles: >> >> https://www.postgresql.org/docs/11/sql-createrole.html >> >> for the object(table) and the entity working with the table? >> > OK, maybe I could set up the "user" role, such that it does not have the > UPDATE permission on this table, just the INSERT one? Of course the "admin" > role would have the UPDATE attribute for this table. 'user' should also have SELECT if you want them to see their records. > > Make sense? Yes. > -- Adrian Klaver adrian.klaver@aklaver.com