diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2011-11-12 17:03:10 +0200 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2011-11-12 17:03:10 +0200 |
commit | 95d2af1646080474ad3e1f1303e68dd5799f9cad (patch) | |
tree | f6983d202744cbff88419f582f61c17c6e740bc3 /src/bin/psql/command.c | |
parent | aa3299f25601c1a27e52c1c49e92b7f11441e76b (diff) |
Add psql expanded auto mode
This adds the "auto" option to the \x command, which switches to the
expanded mode when the normal output would be wider than the screen.
reviewed by Noah Misch
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r-- | src/bin/psql/command.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 5970ab32c15..9cc73beabff 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1355,7 +1355,7 @@ exec_command(const char *cmd, free(fname); } - /* \x -- toggle expanded table representation */ + /* \x -- set or toggle expanded table representation */ else if (strcmp(cmd, "x") == 0) { char *opt = psql_scan_slash_option(scan_state, @@ -2189,14 +2189,21 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet) /* set expanded/vertical mode */ else if (strcmp(param, "x") == 0 || strcmp(param, "expanded") == 0 || strcmp(param, "vertical") == 0) { - if (value) + if (value && pg_strcasecmp(value, "auto") == 0) + popt->topt.expanded = 2; + else if (value) popt->topt.expanded = ParseVariableBool(value); else popt->topt.expanded = !popt->topt.expanded; if (!quiet) - printf(popt->topt.expanded - ? _("Expanded display is on.\n") - : _("Expanded display is off.\n")); + { + if (popt->topt.expanded == 1) + printf(_("Expanded display is on.\n")); + else if (popt->topt.expanded == 2) + printf(_("Expanded display is used automatically.\n")); + else + printf(_("Expanded display is off.\n")); + } } /* locale-aware numeric output */ @@ -2356,7 +2363,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet) popt->topt.columns = atoi(value); if (!quiet) - printf(_("Target width for \"wrapped\" format is %d.\n"), popt->topt.columns); + printf(_("Target width is %d.\n"), popt->topt.columns); } else |