psql -f and PAGER - Mailing list pgsql-general

From Paul Jungwirth
Subject psql -f and PAGER
Date
Msg-id db80016d-d0b6-a721-611b-21292a895af5@illuminatedcomputing.com
Whole thread Raw
Responses Re: psql -f and PAGER
List pgsql-general
Hello,

I noticed that this runs your pager:

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

but not this:

     echo 'select * from pg_class;' | psql

A client encountered this when the psql command run from their deb's 
.postinst file started to hang.

We can prevent it with PSQL_PAGER='', but it almost seems like a bug to 
me, since I expect -f to be for non-interactive use. I'd at least call 
it a footgun.

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

 > Using this option is subtly different from writing psql < filename. 
In general, both will do what you expect, but using -f enables some nice 
features such as error messages with line numbers. There is also a 
slight chance that using this option will reduce the start-up overhead. 
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?

Yours,

-- 
Paul              ~{:-)
pj@illuminatedcomputing.com



pgsql-general by date:

Previous
From: Philip Semanchuk
Date:
Subject: Re: Why is my function inlined only when STABLE?
Next
From: "David G. Johnston"
Date:
Subject: Re: psql -f and PAGER