Обсуждение: pgsql-server/ oc/src/sgml/ref/psql-ref.sgml rc ...

Поиск
Список
Период
Сортировка

pgsql-server/ oc/src/sgml/ref/psql-ref.sgml rc ...

От
momjian@postgresql.org (Bruce Momjian - CVS)
Дата:
CVSROOT:    /cvsroot
Module name:    pgsql-server
Changes by:    momjian@postgresql.org    02/11/08 14:12:22

Modified files:
    doc/src/sgml/ref: psql-ref.sgml
    src/bin/psql   : command.c common.c help.c help.h print.h
                     startup.c

Log message:
    Here is a patch that does just that, while maintaining the
    "traditional" behavior, so the change should be transparent. Use the
    command "\pset pager always" to turn it on. Anything else does the
    normal toggle between "on" and "off"

    Greg Sabino Mullane


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

От
Tom Lane
Дата:
momjian@postgresql.org (Bruce Momjian - CVS) writes:
> Log message:
>     Here is a patch that does just that, while maintaining the
>     "traditional" behavior, so the change should be transparent. Use the
>     command "\pset pager always" to turn it on. Anything else does the
>     normal toggle between "on" and "off"

Wasn't that patch rejected in favor of doing it another way?  I thought
we were going to make the use-the-pager decision depend on width as well
as height, so that it would work automatically instead of needing an
"always" kluge.

            regards, tom lane

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

От
Bruce Momjian
Дата:
Tom Lane wrote:
> momjian@postgresql.org (Bruce Momjian - CVS) writes:
> > Log message:
> >     Here is a patch that does just that, while maintaining the
> >     "traditional" behavior, so the change should be transparent. Use the
> >     command "\pset pager always" to turn it on. Anything else does the
> >     normal toggle between "on" and "off"
>
> Wasn't that patch rejected in favor of doing it another way?  I thought
> we were going to make the use-the-pager decision depend on width as well
> as height, so that it would work automatically instead of needing an
> "always" kluge.

His reply was that there is no way to know what pager they chose and how
it handles wide output (wrap or horizontal scroll), so he felt we still
need the option.

--
  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

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

От
Tom Lane
Дата:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Tom Lane wrote:
>> Wasn't that patch rejected in favor of doing it another way?  I thought
>> we were going to make the use-the-pager decision depend on width as well
>> as height, so that it would work automatically instead of needing an
>> "always" kluge.

> His reply was that there is no way to know what pager they chose and how
> it handles wide output (wrap or horizontal scroll), so he felt we still
> need the option.

That argument seems to miss the point: if your pager doesn't handle
horizontal scroll, so what?  I don't see how you lose anything if the
system invokes the pager on wide-but-short displays.  It can't be worse
than not invoking the pager, can it?

            regards, tom lane

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

От
Bruce Momjian
Дата:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> Wasn't that patch rejected in favor of doing it another way?  I thought
> >> we were going to make the use-the-pager decision depend on width as well
> >> as height, so that it would work automatically instead of needing an
> >> "always" kluge.
>
> > His reply was that there is no way to know what pager they chose and how
> > it handles wide output (wrap or horizontal scroll), so he felt we still
> > need the option.
>
> That argument seems to miss the point: if your pager doesn't handle
> horizontal scroll, so what?  I don't see how you lose anything if the
> system invokes the pager on wide-but-short displays.  It can't be worse
> than not invoking the pager, can it?

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?

--
  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

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

От
Tom Lane
Дата:
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 ...

            regards, tom lane

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

От
Bruce Momjian
Дата:
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