Re: pgsql-server/ oc/src/sgml/ref/psql-ref.sgml rc ... - Mailing list pgsql-committers

From Bruce Momjian
Subject Re: pgsql-server/ oc/src/sgml/ref/psql-ref.sgml rc ...
Date
Msg-id 200211082203.gA8M3QX29475@candle.pha.pa.us
Whole thread Raw
In response to Re: pgsql-server/ oc/src/sgml/ref/psql-ref.sgml rc ...  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers
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

pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgsql-server/ oc/src/sgml/ref/psql-ref.sgml rc ...
Next
From: "Marc G. Fournier"
Date:
Subject: Re: pgsql-server/src/backend access/transam/xlog.c ...