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>
Date: 2017-01-30T18:17:42Z
Lists: pgsql-hackers
BTW, while testing this patch I noticed that the error reports are
a tad redundant:

regression=# \set AUTOCOMMIT foo
unrecognized value "foo" for "AUTOCOMMIT": boolean expected
\set: error while setting variable
regression=# 

The "error while setting variable" message seems entirely content-free.
I think we should drop that and instead establish a rule that SetVariable
should print a message for itself about any failure.  (There are a lot
of call sites that don't check for or print a message, but that's only
because they aren't expecting failure.  If one were to happen, printing
a message doesn't seem unreasonable.)  That would in turn propagate into
an API requirement that var hooks that return FALSE are responsible for
printing a message about the reason, which is why it would be appropriate
to make that change as part of this patch.

Barring objections PDQ, I'll make this change.

			regards, tom lane


Commits

  1. Clean up psql's behavior for a few more control variables.

  2. Make psql's \set display variables in alphabetical order.

  3. Improve psql's behavior for \set and \unset of its control variables.

  4. Make psql reject attempts to set special variables to invalid values.