pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Make psql reject attempts to set special variables to invalid va
Date: Mon, 30 Jan 2017 21:37:36 +0000
Message-ID: <E1cYJdo-0003nW-QY@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

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

Previously, if the user set a special variable such as ECHO to an
unrecognized value, psql would bleat but store the new value anyway, and
then fall back to a default setting for the behavior controlled by the
variable.  This was agreed to be a not particularly good idea.  With
this patch, invalid values result in an error message and no change in
state.

(But this applies only to variables that affect psql's behavior; purely
informational variables such as ENCODING can still be set to random
values.)

To do this, modify the API for psql's assign-hook functions so that they
can return an OK/not OK result, and give them the responsibility for
printing error messages when they reject a value.  Adjust the APIs for
ParseVariableBool and ParseVariableNum to support the new behavior
conveniently.

In passing, document the variable VERSION, which had somehow escaped that.
And improve the quite-inadequate commenting in psql/variables.c.

Daniel Vérité, reviewed by Rahila Syed, some further tweaking by me

Discussion: https://postgr.es/m/7356e741-fa59-4146-a8eb-cf95fd6b21fb@mm

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/511ae628f31b4e791cd5c7836e46cb84dcf145fd

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml     |  33 ++++--
src/bin/psql/command.c             |  82 +++++++------
src/bin/psql/common.c              |   1 -
src/bin/psql/input.c               |   2 +-
src/bin/psql/mainloop.c            |   2 +-
src/bin/psql/startup.c             | 121 ++++++++++++--------
src/bin/psql/variables.c           | 228 ++++++++++++++++++++++++++-----------
src/bin/psql/variables.h           |  50 +++++---
src/test/regress/expected/psql.out |  11 +-
src/test/regress/sql/psql.sql      |   8 ++
10 files changed, 356 insertions(+), 182 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1cYJdo-0003nW-QY@gemulon.postgresql.org>
Permalink:  ../E1cYJdo-0003nW-QY@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1cYJdo-0003nW-QY@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Make psql reject attempts to set special variables to invalid va
  In-Reply-To: <E1cYJdo-0003nW-QY@gemulon.postgresql.org>
  References: <E1cYJdo-0003nW-QY@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox