On Thu, Apr 26, 2012 at 09:25:25PM +0300, Peter Eisentraut wrote:
On m??n, 2012-04-23 at 12:30 -0400, Noah Misch wrote:
I've been enjoying \x auto in .psqlrc, but I noticed the row count footer
missing when it chooses ordinary output:
Looks like the logic in printQuery() needs further treatment.
Hmm, this looks a bit tricky, because at the time we add the footer we
don't yet know which output format will be used. I don't have a good
idea how to fix that at the moment.
I fiddled with this and settled on moving the default_footer boolean setting
and the interpretation thereof down from the printQuery() level to the
printTable() level. That permits delaying the decision until we determine
whether the final output format is indeed vertical.
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***
*** 2407,2418 do_pset(const char *param, const char *value, printQueryOpt
*popt, bool quiet)
else if (strcmp(param, footer) == 0)
{
if (value)
! popt-default_footer = ParseVariableBool(value);
else
! popt-default_footer = !popt-default_footer;
if (!quiet)
{
! if (popt-default_footer)
puts(_(Default footer is on.));
else
puts(_(Default footer is off.));
--- 2407,2418
else if (strcmp(param, footer) == 0)
{
if (value)
! popt-topt.default_footer = ParseVariableBool(value);
else
! popt-topt.default_footer = !popt-topt.default_footer;
if (!quiet)
{
! if (popt-topt.default_footer)
puts(_(Default footer is on.));
else
puts(_(Default footer is off.));
*** a/src/bin/psql/describe.c
--- b/src/bin/psql/describe.c
***
*** 1130,1135 describeOneTableDetails(const char *schemaname,
--- 1130,1136
retval = false;
+ myopt.default_footer = false;
/* This output looks confusing in expanded mode. */
myopt.expanded = false;
***
*** 2363,2368 describeRoles(const char *pattern, bool verbose)
--- 2364,2371
const char align = 'l';
char **attr;
+ myopt.default_footer = false;
+
initPQExpBuffer(buf);
if (pset.sversion = 80100)
***
*** 3362,3368 describeOneTSParser(const char *oid, const char *nspname,
const char *prsname)
sprintf(title, _(Text search parser \%s\), prsname);
myopt.title = title;
myopt.footers = NULL;
! myopt.default_footer = false;
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
--- 3365,3371
sprintf(title, _(Text search parser \%s\), prsname);
myopt.title = title;
myopt.footers = NULL;
! myopt.topt.default_footer = false;
myopt.translate_header = true;
myopt.translate_columns = translate_columns;
***
*** 3393,3399 describeOneTSParser(const char *oid, const char *nspname,
const char *prsname)
sprintf(title, _(Token types for parser \%s\), prsname);
myopt.title = title;
myopt.footers = NULL;
! myopt.default_footer = true;
myopt.translate_header = true;
myopt.translate_columns = NULL;
--- 3396,3402
sprintf(title, _(Token types for parser \%s\), prsname);
myopt.title = title;
myopt.footers = NULL;
! myopt.topt.default_footer = true;
myopt.translate_header = true;
myopt.translate_columns = NULL;
***
*** 3725,3731 describeOneTSConfig(const char *oid, const char *nspname,
const char *cfgname,
myopt.nullPrint = NULL;
myopt.title = title.data;
myopt.footers = NULL;
! myopt.default_footer = false;
myopt.translate_header = true;
printQuery(res, myopt, pset.queryFout, pset.logfile);
--- 3728,3734
myopt.nullPrint = NULL;
myopt.title = title.data;
myopt.footers = NULL;
! myopt.topt.default_footer = false;
myopt.translate_header = true;
printQuery(res, myopt, pset.queryFout, pset.logfile);
*** a/src/bin/psql/print.c
--- b/src/bin/psql/print.c
***
*** 44,49 static char *decimal_point;
--- 44,52
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 =
{
***
*** 278,283 print_separator(struct separator sep, FILE *fout)
--- 281,314
}
+ /*
+ * Return