Re: [HACKERS] psql omits row count under \x auto

2012-05-01 Thread Robert Haas
On Fri, Apr 27, 2012 at 3:05 PM, Noah Misch n...@leadboat.com wrote:
 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.

Committed.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] psql omits row count under \x auto

2012-04-27 Thread Noah Misch
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 

Re: [HACKERS] psql omits row count under \x auto

2012-04-26 Thread Peter Eisentraut
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.



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] psql omits row count under \x auto

2012-04-25 Thread Robert Haas
On Mon, Apr 23, 2012 at 12:30 PM, Noah Misch n...@leadboat.com wrote:
 Looks like the logic in printQuery() needs further treatment.

Do you want to propose a patch, or are you hoping someone else is
going to address this?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] psql omits row count under \x auto

2012-04-25 Thread Noah Misch
On Wed, Apr 25, 2012 at 04:57:36PM -0400, Robert Haas wrote:
 On Mon, Apr 23, 2012 at 12:30 PM, Noah Misch n...@leadboat.com wrote:
  Looks like the logic in printQuery() needs further treatment.
 
 Do you want to propose a patch, or are you hoping someone else is
 going to address this?

I figured Peter might have a preference for how to fix it.  If not, I can put
something together.

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] psql omits row count under \x auto

2012-04-23 Thread Noah Misch
I've been enjoying \x auto in .psqlrc, but I noticed the row count footer
missing when it chooses ordinary output:

[local] test=# \x off
Expanded display is off.
[local] test=# select 1;
 ?column?
--
1
(1 row)

[local] test=# \x auto
Expanded display is used automatically.
[local] test=# select 1;
 ?column?
--
1

[local] test=#

Looks like the logic in printQuery() needs further treatment.

Thanks,
nm

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers