pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Jungwirth <pj@illuminatedcomputing.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: psql -f and PAGER
Date: Tue, 29 Mar 2022 18:30:46 -0700
Message-ID: <db80016d-d0b6-a721-611b-21292a895af5@illuminatedcomputing.com> (raw)

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





view thread (3+ messages)  latest in thread

Message-ID: <db80016d-d0b6-a721-611b-21292a895af5@illuminatedcomputing.com>
Permalink:  ../db80016d-d0b6-a721-611b-21292a895af5@illuminatedcomputing.com/
Also on:    postgresql.org/message-id/db80016d-d0b6-a721-611b-21292a895af5@illuminatedcomputing.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: pj@illuminatedcomputing.com
  Subject: Re: psql -f and PAGER
  In-Reply-To: <db80016d-d0b6-a721-611b-21292a895af5@illuminatedcomputing.com>
  References: <db80016d-d0b6-a721-611b-21292a895af5@illuminatedcomputing.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox