retval = false;
+ myopt.default_footer = false;
/* This output looks confusing in expanded mode. */
myopt.expanded = false;
const char align = 'l';
char **attr;
+ myopt.default_footer = false;
+
initPQExpBuffer(&buf);
if (pset.sversion >= 80100)
sprintf(title, _("Text search parser \"%s\""), prsname);
myopt.title = title;
myopt.footers = NULL;
- myopt.default_footer = false;
+ myopt.topt.default_footer = false;
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
sprintf(title, _("Token types for parser \"%s\""), prsname);
myopt.title = title;
myopt.footers = NULL;
- myopt.default_footer = true;
+ myopt.topt.default_footer = true;
myopt.translate_header = true;
myopt.translate_columns = NULL;
myopt.nullPrint = NULL;
myopt.title = title.data;
myopt.footers = NULL;
- myopt.default_footer = false;
+ myopt.topt.default_footer = false;
myopt.translate_header = true;
printQuery(res, &myopt, pset.queryFout, pset.logfile);
static char *grouping;
static char *thousands_sep;
+static char default_footer[100];
+static printTableFooter default_footer_cell = { default_footer, NULL };
+
/* Line style control structures */
const printTextFormat pg_asciiformat =
{
}
+/*
+ * Return the list of explicitly-requested footers or, when applicable, the
+ * default "(xx rows)" footer. Always omit the default footer when given
+ * non-default footers, "\pset footer off", or a specific instruction to that
+ * effect from a calling backslash command. Vertical formats number each row,
+ * making the default footer redundant; they do not call this function.
+ *
+ * The return value may point to static storage; do not keep it across calls.
+ */
+static printTableFooter *
+footers_with_default(const printTableContent *cont)
+{
+ if (cont->footers == NULL && cont->opt->default_footer)
+ {
+ unsigned long total_records;
+
+ total_records = cont->opt->prior_records + cont->nrows;
+ snprintf(default_footer, sizeof(default_footer),
+ ngettext("(%lu row)", "(%lu rows)", total_records),
+ total_records);
+
+ return &default_footer_cell;
+ }
+ else
+ return cont->footers;
+}
+
+
/*************************/
/* Unaligned text */
/*************************/
/* print footers */
if (cont->opt->stop_table)
{
- if (!opt_tuples_only && cont->footers != NULL && !cancel_pressed)
+ printTableFooter *footers = footers_with_default(cont);
+
+ if (!opt_tuples_only && footers != NULL && !cancel_pressed)
{
printTableFooter *f;
- for (f = cont->footers; f; f = f->next)
+ for (f = footers; f; f = f->next)
{
if (need_recordsep)
{
if (cont->opt->stop_table)
{
+ printTableFooter *footers = footers_with_default(cont);
+
if (opt_border == 2 && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_BOTTOM, format, fout);
/* print footers */
- if (cont->footers && !opt_tuples_only && !cancel_pressed)
+ if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
- for (f = cont->footers; f; f = f->next)
+ for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
}
if (cont->opt->stop_table)
{
+ printTableFooter *footers = footers_with_default(cont);
+
fputs("</table>\n", fout);
/* print footers */
- if (!opt_tuples_only && cont->footers != NULL && !cancel_pressed)
+ if (!opt_tuples_only && footers != NULL && !cancel_pressed)
{
printTableFooter *f;
fputs("<p>", fout);
- for (f = cont->footers; f; f = f->next)
+ for (f = footers; f; f = f->next)
{
html_escaped_print(f->data, fout);
fputs("<br />\n", fout);
if (cont->opt->stop_table)
{
+ printTableFooter *footers = footers_with_default(cont);
+
if (opt_border == 2)
fputs("\\hline\n", fout);
fputs("\\end{tabular}\n\n\\noindent ", fout);
/* print footers */
- if (cont->footers && !opt_tuples_only && !cancel_pressed)
+ if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
- for (f = cont->footers; f; f = f->next)
+ for (f = footers; f; f = f->next)
{
latex_escaped_print(f->data, fout);
fputs(" \\\\\n", fout);
if (cont->opt->stop_table)
{
+ printTableFooter *footers = footers_with_default(cont);
+
fputs(".TE\n.DS L\n", fout);
/* print footers */
- if (cont->footers && !opt_tuples_only && !cancel_pressed)
+ if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
- for (f = cont->footers; f; f = f->next)
+ for (f = footers; f; f = f->next)
{
troff_ms_escaped_print(f->data, fout);
fputc('\n', fout);
for (footer = opt->footers; *footer; footer++)
printTableAddFooter(&cont, *footer);
}
- else if (!opt->topt.expanded && opt->default_footer)
- {
- unsigned long total_records;
- char default_footer[100];
-
- total_records = opt->topt.prior_records + cont.nrows;
- snprintf(default_footer, sizeof(default_footer),
- ngettext("(%lu row)", "(%lu rows)", total_records),
- total_records);
-
- printTableAddFooter(&cont, default_footer);
- }
printTable(&cont, fout, flog);
printTableCleanup(&cont);