Search Postgresql Archives

Re: psql -f and PAGER

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 29, 2022 at 6:30 PM Paul Jungwirth <pj@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I noticed that this runs your pager:

     psql -f <(echo 'select * from pg_class;')

but not this:

     echo 'select * from pg_class;' | psql

Indeed running the pager for -f but not stdin seems opposite of the last
line of these docs (https://www.postgresql.org/docs/14/app-psql.html):

On the other hand, the variant using the shell's input redirection is
(in theory) guaranteed to yield exactly the same output you would have
received had you entered everything by hand.

Does it seem wrong to anyone else to run the pager from -f? Is it
something the community would accept patches to change?


If anything the behavior of the echo is contrary to the documentation (though I get your point about "yield exactly the same output").

For both examples:
pager defaults to on
the output of the psql session is a terminal
the full contents of pg_class are not going to fit on one terminal screen
ergo, the output of select * from pg_class; should be piped to the pager in both cases

I'd be on board with having the documentation better match reality (if we can figure out why echo-pipe is different and it's something we control) but I'm against changing the longstanding behavior to an only subjectively different one.

Seems like both setting pager to off and ON_ERROR_STOP to on should be the first things people do in their psql non-interactive automations (or run them through the "tee" command...).  It would be nice to not have to change the pager but I also don't see messing with the default.

David J.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux