Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYcrT-0003rL-2z for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Jan 2017 18:08:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cYcrS-00088p-MR for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Jan 2017 18:08:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cYcq1-0005bA-VR for pgsql-hackers@postgresql.org; Tue, 31 Jan 2017 18:07:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cYcpz-00072B-I6 for pgsql-hackers@postgresql.org; Tue, 31 Jan 2017 18:07:28 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v0VI7MmQ000780; Tue, 31 Jan 2017 13:07:22 -0500 From: Tom Lane To: "Daniel Verite" cc: "Rahila Syed" , "Stephen Frost" , "Ashutosh Bapat" , "pgsql-hackers" , "Andrew Dunstan" Subject: Re: Improvements in psql hooks for variables In-reply-to: References: Comments: In-reply-to "Daniel Verite" message dated "Tue, 31 Jan 2017 18:12:03 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <778.1485886042.1@sss.pgh.pa.us> Date: Tue, 31 Jan 2017 13:07:22 -0500 Message-ID: <779.1485886042@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org "Daniel Verite" writes: > I notice that in the commited patch, you added the ability > for DeleteVariable() to reject the deletion if the hook > disagrees. Right. > But this can't happen in practice because as mentioned just upthread > the hook called with NULL doesn't know if the variable is getting unset > or initialized, so rejecting on NULL is not an option. It would have required the caller to set a value before installing the hook, which would require some reshuffling of responsibility. In the draft patch I sent a little bit ago, this is handled by installing a "substitution hook" first, and that hook transmogrifies NULL into an allowed setting. That gets to the same place in a slightly different way, but it also covers allowing "\unset FOO", which inserting initial values wouldn't. > Attached is a proposed patch to add initial values to > SetVariableAssignHook() to solve this problem, and an example for > \unset AUTOCOMMIT being denied by the hook. I think disallowing \unset is a nonstarter on compatibility grounds. We should allow \unset but treat it like setting to "off" (or whatever the default value is). regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers