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 1hxFmF-0006D8-Nd for pgsql-general@arkaria.postgresql.org; Mon, 12 Aug 2019 19:14:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxFmE-0007iH-DI for pgsql-general@arkaria.postgresql.org; Mon, 12 Aug 2019 19:14:42 +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 1hxFmC-0007gT-J7 for pgsql-general@lists.postgresql.org; Mon, 12 Aug 2019 19:14:42 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxFm3-0004hh-Rj for pgsql-general@lists.postgresql.org; Mon, 12 Aug 2019 19:14:40 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id C6D5A47C; Mon, 12 Aug 2019 15:14:27 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 12 Aug 2019 15:14:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=l e2vLvXsA81tUnRvwGPx0H6B6eW4sGlVjKnz+LTvT8I=; b=OqcwBYNScYxgTQtY2 GsYm+BrLkZyofQ+ZtvOfeyfXGNTMBIX1o0a5vLrCbm4GTp0l0yOSIpEUreNS8YZ8 5uI8Wjw0jcCGTlTEVZ+piLZK0XFvElF1X0axRGXq5hajG8QFH7zpKYEKjnZfDNVI ogJ+dyGfpqQU3YNwxLuyRzxj4fajiYE4g6nTN+K5g9JK7cwVfYkdaQGTLr2whY6F 4XtEWhfuRcLF0cyZYSw2hy82lJrCxiC/y+MXgxtrUhqMTdNwD19mgZNTpdmZHQae 2mG3qZ1uTm3CAqwKHL6C/7NlPuawQOcTnCbX0ryw2HmNsAyUCRJvNg7lNcv6oePq KDKIA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=le2vLvXsA81tUnRvwGPx0H6B6eW4sGlVjKnz+LTvT 8I=; b=lo3DfpGDiFI+Om/HMRhWvF/8k1M3BvyAS1knmxLl7rMN3mwIuSN4feixY mJTwhpFZqGF9ZkqBms9hEijBfVgEqyFnYmZP8MyubT8r+yBdJ5lCDth6VsqZ+/Vb AxjOua/GzuvGG5AGRUZgjUMfoPWH41K9fkabwBVLRx1SO0EvLF/bqjQERGA2AWX0 kUUKTZWOLlKZRItoazwh+niiS5ZGs7b72q9J8ZNUn0y9eiz3YMz25h/+zJoDQM8G MJvgu0LboR8JCHnOl9HgHTQ+tfTb1+RgbDSlp3p7ndCSn9nEahdiRIIokh7A4pbb d5JDyF6eCV3jj3p49wK9Yh6F8a0zg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddruddvgedgudefhecutefuodetggdotefrod 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 4EC7080064; Mon, 12 Aug 2019 15:14:26 -0400 (EDT) Subject: Re: "Locking rows" To: stan , pgsql-general@lists.postgresql.org References: <20190812175133.GC681@panix.com> From: Adrian Klaver Message-ID: Date: Mon, 12 Aug 2019 12:14:25 -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: <20190812175133.GC681@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 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? -- Adrian Klaver adrian.klaver@aklaver.com