Re: pasting a lot of commands to psql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Dmitry Shalashov <skaurus(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: pasting a lot of commands to psql
Date: 2016-07-08 00:04:32
Message-ID: 4159.1467936272@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> Tom Lane wrote:
>> You might have better luck with "psql -n", or maybe not.

> I've wished sometimes for a "\set READLINE off" psql metacommand for
> this kind of thing. It's pretty annoying when the text being pasted
> contains tabs and readline uses to do completion.

Seems like the readline aspect of that wouldn't be too hard. The fun
part would be agreeing on how we want history to behave if you flip
this on/off during a session. Which lines get added to history?
Does ~/.psql_history get written at all if READLINE is off at the
end of the session?

A spec that seems reasonable and probably not too hard to implement is:

1. ~/.psql_history is read the first time you turn on READLINE during
a session.

2. Input lines are added to history only when READLINE is on.

3. ~/.psql_history is written at session exit if any lines have been
added to history during the session (regardless of whether READLINE
is currently on).

People might complain about point 2, but I think it would be rather
difficult to do otherwise, seeing that the active history storage
is mostly under libreadline's control. Also, other definitions might
lead to retaining a history buffer even in totally non-interactive
sessions (where READLINE never gets turned on). That doesn't sound
like what we'd want.

Another definitional issue is whether turning on READLINE does anything
if stdin is not a tty. I'd vote no.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Prashanth Adiyodi 2016-07-08 02:40:56 Re: Where clause in pg_dump: need help
Previous Message FarjadFarid(ChkNet) 2016-07-07 20:48:24 Re: Fastest memmove in C