Re: pasting a lot of commands to psql - Mailing list pgsql-general

From Tom Lane
Subject Re: pasting a lot of commands to psql
Date
Msg-id 4159.1467936272@sss.pgh.pa.us
Whole thread Raw
In response to Re: pasting a lot of commands to psql  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-general
Alvaro Herrera <alvherre@2ndquadrant.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


pgsql-general by date:

Previous
From: "FarjadFarid\(ChkNet\)"
Date:
Subject: Re: Fastest memmove in C
Next
From: Francisco Olarte
Date:
Subject: Re: [BUGS] Where clause in pg_dump: need help