Re: psql and readline - Mailing list pgsql-hackers

From Ross J. Reedstrom
Subject Re: psql and readline
Date
Msg-id 20030109224620.GB30740@wallace.ece.rice.edu
Whole thread Raw
In response to Re: psql and readline  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
On Thu, Jan 09, 2003 at 10:49:33PM +0100, Peter Eisentraut wrote:
> Christopher Kings-Lynne writes:
> 
> > Is there any way of making the 'up' arrow retrieve all of the last multiline
> > query, instead of just the last line?
> 
> There is nothing technical that should prevent you from implementing it.
> But you need to come up with a reasonable system to keep the history
> straight if meta commands are mixed with multiline commands, such as
> 
> select *
> \x
> from foo;

Peter, what do you think about pushing the query buffer onto the history
stack at execution time, any time it's a multiline query? That way,
after the above sequence, you'd have:

(1) select *
(2) \x
(3) from foo;
(4) select *    from foo;

Yeah, this wastes a history slot, but it does solve the problem. It's also
dead simple to code. ;-)

BTW, the behavior in bash for multiline interactive entered commands
is to concatenate them into a single line and dump them in the history,
replacing the individual parts.  The individual parts are in the history
while you're at the secondary prompt, then go away after execution. In
psql, we'd probably just lose interstitial metacommands.

Ross


pgsql-hackers by date:

Previous
From: "Dann Corbit"
Date:
Subject: Re: Dollar in identifiers
Next
From: Jan Wieck
Date:
Subject: Re: Dollar in identifiers