Re: Improvements in psql hooks for variables
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Daniel Verite" <daniel@manitou-mail.org>
Cc: "Rahila Syed" <rahilasyed90@gmail.com>,
"Stephen Frost" <sfrost@snowman.net>,
"Ashutosh Bapat" <ashutosh.bapat@enterprisedb.com>,
"pgsql-hackers" <pgsql-hackers@postgresql.org>,
"Andrew Dunstan" <andrew@dunslane.net>
Date: 2017-01-31T18:07:22Z
Lists: pgsql-hackers
"Daniel Verite" <daniel@manitou-mail.org> 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
Commits
-
Clean up psql's behavior for a few more control variables.
- fd6cd698031d 10.0 landed
-
Make psql's \set display variables in alphabetical order.
- c3e3844a92fe 10.0 landed
-
Improve psql's behavior for \set and \unset of its control variables.
- 86322dc7e013 10.0 landed
-
Make psql reject attempts to set special variables to invalid values.
- 511ae628f31b 10.0 landed