I have encountered two unrelated flaws in the psql table output. First, when using unaligned vertical mode (\a \x on), there is always an empty line after the last record. This also means that an empty result set prints an empty line, instead of nothing.
Second, when using aligned vertical mode (\x on), an empty result set prints "(No rows)". That's fine, but there is no way to turn this off. I intuitively attempted to use \t (tuples only), but that had no effect. \t doesn't really have a meaning in vertical mode, because the field names are always printed, but I think it could/should have the effect of shutting off footer lines. Patch for both issues attached.
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 2a34fb3..0722c98 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -439,10 +439,13 @@ static void IsPagerNeeded(const printTableContent *cont, const int extra_lines, } /* see above in print_unaligned_text() */ - if (cont->opt->recordSep.separator_zero) - print_separator(cont->opt->recordSep, fout); - else - fputc('\n', fout); + if (need_recordsep) + { + if (cont->opt->recordSep.separator_zero) + print_separator(cont->opt->recordSep, fout); + else + fputc('\n', fout); + } } } @@ -1169,7 +1172,8 @@ static void IsPagerNeeded(const printTableContent *cont, const int extra_lines, if (cont->cells[0] == NULL && cont->opt->start_table && cont->opt->stop_table) { - fprintf(fout, _("(No rows)\n")); + if (!opt_tuples_only) + fprintf(fout, _("(No rows)\n")); return; }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers