diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c new file mode 100644 index ce0d05d..40e5098 *** a/src/bin/psql/print.c --- b/src/bin/psql/print.c *************** print_aligned_text(const printTableConte *** 692,698 **** if (opt_border == 0) width_total = col_count; else if (opt_border == 1) ! width_total = col_count * 3 - 1; else width_total = col_count * 3 + 1; total_header_width = width_total; --- 692,698 ---- if (opt_border == 0) width_total = col_count; else if (opt_border == 1) ! width_total = col_count * 3 - ((col_count > 0) ? 1 : 0); else width_total = col_count * 3 + 1; total_header_width = width_total; *************** print_aligned_text(const printTableConte *** 928,934 **** fputs(!header_done[i] ? format->header_nl_right : " ", fout); ! if (opt_border != 0 && i < col_count - 1) fputs(dformat->midvrule, fout); } curr_nl_line++; --- 928,934 ---- fputs(!header_done[i] ? format->header_nl_right : " ", fout); ! if (opt_border != 0 && col_count > 0 && i < col_count - 1) fputs(dformat->midvrule, fout); } curr_nl_line++; *************** print_aligned_text(const printTableConte *** 983,989 **** struct lineptr *this_line = &col_lineptrs[j][curr_nl_line[j]]; int bytes_to_output; int chars_to_output = width_wrap[j]; ! bool finalspaces = (opt_border == 2 || j < col_count - 1); /* Print left-hand wrap or newline mark */ if (opt_border != 0) --- 983,990 ---- struct lineptr *this_line = &col_lineptrs[j][curr_nl_line[j]]; int bytes_to_output; int chars_to_output = width_wrap[j]; ! bool finalspaces = (opt_border == 2 || ! (col_count > 0 && j < col_count - 1)); /* Print left-hand wrap or newline mark */ if (opt_border != 0) *************** print_aligned_text(const printTableConte *** 1077,1087 **** fputs(format->wrap_right, fout); else if (wrap[j] == PRINT_LINE_WRAP_NEWLINE) fputs(format->nl_right, fout); ! else if (opt_border == 2 || j < col_count - 1) fputc(' ', fout); /* Print column divider, if not the last column */ ! if (opt_border != 0 && j < col_count - 1) { if (wrap[j + 1] == PRINT_LINE_WRAP_WRAP) fputs(format->midvrule_wrap, fout); --- 1078,1088 ---- fputs(format->wrap_right, fout); else if (wrap[j] == PRINT_LINE_WRAP_NEWLINE) fputs(format->nl_right, fout); ! else if (opt_border == 2 || (col_count > 0 && j < col_count - 1)) fputc(' ', fout); /* Print column divider, if not the last column */ ! if (opt_border != 0 && (col_count > 0 && j < col_count - 1)) { if (wrap[j + 1] == PRINT_LINE_WRAP_WRAP) fputs(format->midvrule_wrap, fout); *************** print_aligned_vertical(const printTableC *** 1236,1243 **** if (cont->cells[0] == NULL && cont->opt->start_table && cont->opt->stop_table) { ! if (!opt_tuples_only && cont->opt->default_footer) ! fprintf(fout, _("(No rows)\n")); return; } --- 1237,1254 ---- if (cont->cells[0] == NULL && cont->opt->start_table && cont->opt->stop_table) { ! printTableFooter *footers = footers_with_default(cont); ! ! if (!opt_tuples_only && !cancel_pressed && footers) ! { ! printTableFooter *f; ! ! for (f = footers; f; f = f->next) ! fprintf(fout, "%s\n", f->data); ! } ! ! fputc('\n', fout); ! return; }