Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > So you are suggesting invoking the pager if the output goes over the
> > display length, no matter how many rows? Do you know how to determine
> > the output width before displaying any rows?
>
> The thing must compute the output width in order to align the column
> headers, no? It might be that the code is structured in a way that
> the info isn't readily available when we'd start the pager, but at
> least in principle it's doable ...
Yes, it does compute the width, but later than the opening of the output
FILE*. See psql/print.c:
switch (opt->format)
{
case PRINT_UNALIGNED:
if (opt->expanded)
print_unaligned_vertical(title, headers, cells, footers, opt->fi
eldSep, opt->recordSep, opt->tuples_only, output);
else
print_unaligned_text(title, headers, cells, footers, opt->fieldS
ep, opt->recordSep, opt->tuples_only, output);
break;
Theoretically, yes, it could be done. My feeling is we can remove
'\pset pager always' is someone wants to implement this. Also, consider
that the \x and other output formats don't pre-align data, so overly
long lines may be much harder to determine in those cases.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073