[COMMITTERS] pgsql: Improve psql's behavior for \set and \unset of its controlvaria

Поиск
Список
Период
Сортировка
От Tom Lane
Тема [COMMITTERS] pgsql: Improve psql's behavior for \set and \unset of its controlvaria
Дата
Msg-id E1cYxMs-0006P6-A4@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Improve psql's behavior for \set and \unset of its control variables.

This commit improves on the results of commit 511ae628f in two ways:

1. It restores the historical behavior that "\set FOO" is interpreted
as setting FOO to "on", if FOO is a boolean control variable.  We
already found one test script that was expecting that behavior, and
the psql documentation certainly does nothing to discourage people
from assuming that would work, since it often says just "if FOO is set"
when describing the effects of a boolean variable.  However, now this
case will result in actually setting FOO to "on", not an empty string.

2. It arranges for an "\unset" of a control variable to set the value
back to its default value, rather than becoming apparently undefined.
The control variables are also initialized that way at psql startup.

In combination, these things guarantee that a control variable always
has a displayable value that reflects what psql is actually doing.
That is a pretty substantial usability improvement.

The implementation involves adding a second type of variable hook function
that is able to replace a proposed new value (including NULL) with another
one.  We could alternatively have complicated the API of the assign hook,
but this way seems better since many variables can share the same
substitution hook function.

Also document the actual behavior of these variables more fully,
including covering assorted behaviors that were there before but
never documented.

This patch also includes some minor cleanup that should have been in
511ae628f but was missed.

Patch by me, but it owes a lot to discussions with Daniel Vérité.

Discussion: https://postgr.es/m/9572.1485821620@sss.pgh.pa.us

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/86322dc7e013b4062393dcbb74043db003e23ec5

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml     |  90 ++++++++++++++------
src/bin/psql/startup.c             | 170 +++++++++++++++++++++++++++----------
src/bin/psql/variables.c           | 144 +++++++++++++++----------------
src/bin/psql/variables.h           |  35 +++++++-
src/test/regress/expected/psql.out |  17 ++++
src/test/regress/sql/psql.sql      |  10 +++
6 files changed, 319 insertions(+), 147 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: [COMMITTERS] pgsql: Replace isMD5() with a more future-proof way to check if pw ise
Следующее
От: Tom Lane
Дата:
Сообщение: [COMMITTERS] pgsql: Make psql's \set display variables in alphabetical order.