diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-11-26 12:31:20 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-11-26 12:31:20 -0500 |
commit | a7eece4fc9a416129aa692271972be5a30daa68c (patch) | |
tree | 9dff7a0850b1665465f45d0117435c946920d5ed | |
parent | 36d442a25a1aed39d2c7c3fb24c22640a9a6545d (diff) | |
download | postgresql-a7eece4fc9a416129aa692271972be5a30daa68c.tar.gz postgresql-a7eece4fc9a416129aa692271972be5a30daa68c.zip |
Fix breakage of "\pset format latex".
Commit eaf746a5b unintentionally made psql's "latex" output format
inaccessible, since not only "latex" but all abbreviations of it
were considered ambiguous against "latex-longtable". Let's go
back to the longstanding behavior that all shortened versions
mean "latex", and you have to write at least "latex-" to get
"latex-longtable". This leaves the only difference from pre-v12
behavior being that "\pset format a" is considered ambiguous.
The fact that the regression tests didn't expose this is pretty bad,
but fixing it is material for a separate commit.
Discussion: https://postgr.es/m/cb7e1caf-3ea6-450d-af28-f524903a030c@manitou-mail.org
-rw-r--r-- | src/bin/psql/command.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index ee88e1ca5cf..13d4c5792f3 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3698,7 +3698,6 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet) {"asciidoc", PRINT_ASCIIDOC}, {"html", PRINT_HTML}, {"latex", PRINT_LATEX}, - {"latex-longtable", PRINT_LATEX_LONGTABLE}, {"troff-ms", PRINT_TROFF_MS}, {"unaligned", PRINT_UNALIGNED}, {"wrapped", PRINT_WRAPPED} @@ -3725,13 +3724,22 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet) } } } - if (match_pos < 0) + if (match_pos >= 0) + popt->topt.format = formats[match_pos].number; + else if (pg_strncasecmp("latex-longtable", value, vallen) == 0) + { + /* + * We must treat latex-longtable specially because latex is a + * prefix of it; if both were in the table above, we'd think + * "latex" is ambiguous. + */ + popt->topt.format = PRINT_LATEX_LONGTABLE; + } + else { psql_error("\\pset: allowed formats are aligned, asciidoc, html, latex, latex-longtable, troff-ms, unaligned, wrapped\n"); return false; } - else - popt->topt.format = formats[match_pos].number; } } |