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: "Ashutosh Sharma" <ashu.coek88@gmail.com>,
"Rahila Syed" <rahilasyed90@gmail.com>,
"Stephen Frost" <sfrost@snowman.net>,
"Ashutosh Bapat" <ashutosh.bapat@enterprisedb.com>,
"pgsql-hackers" <pgsql-hackers@postgresql.org>
Date: 2017-01-20T14:02:10Z
Lists: pgsql-hackers
"Daniel Verite" <daniel@manitou-mail.org> writes: > Setting ENCODING has no effect, like DBNAME, USER, HOST and PORT. > In a way, it's a read-only variable that's here to inform the user, > not as a means to change the encoding (\encoding does that and > has proper support for tab completion) Right. > What we could do as of this patch is emit an error when we try > to change ENCODING, with a hook returning false and > a proper error message hinting to \encoding. I think that the current behavior is intentional: it avoids making those variables reserved. That is, if you're unaware that psql sets them and try to use them for your own purposes, it will work. However, it only really works if psql never overwrites the values after startup, whereas I believe all of these are overwritten by a \c command. So maybe it's more user-friendly to make these variables fully reserved, even at the risk of breaking existing scripts. But I don't think it's exactly an open-and-shut question. 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