Re: psql -f and PAGER

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: psql -f and PAGER
Дата
Msg-id CAKFQuwaAB4S=ACPK+Ghairm50S2__eDy2DQDhwzrkjKfKqOujg@mail.gmail.com
обсуждение исходный текст
Ответ на psql -f and PAGER  (Paul Jungwirth <pj@illuminatedcomputing.com>)
Ответы Re: psql -f and PAGER  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
Список pgsql-general
On Tue, Mar 29, 2022 at 6:30 PM Paul Jungwirth <pj@illuminatedcomputing.com> 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Paul Jungwirth
Дата:
Сообщение: psql -f and PAGER
Следующее
От: Sai Ch
Дата:
Сообщение: Reg: User creation script/List of privileges