Re: Not so happy with psql's new multiline behavior

From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Not so happy with psql's new multiline behavior
Date: 2006-03-05 03:46:44
Message-ID: Pine.LNX.4.44.0603050527180.16830-100000@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 4 Mar 2006, Tom Lane wrote:

> Has anyone else been finding the recent behavior of CVS-tip psql
> to be a disimprovement? I've gotten sufficiently annoyed with it
> that I'm ready to propose reverting this patch:
>
> 2006-02-11 16:55 momjian
>
> * src/bin/psql/: help.c, input.c, input.h, mainloop.c, prompt.c,
> tab-complete.c: o Improve psql's handling of multi-line statements
>
> Currently, while \e saves a single statement as one entry,
> interactive
> statements are saved one line at a time. Ideally all
> statements
> would be saved like \e does.
>
> Sergey E. Koposov
>
>
> Maybe it's just that I'm too used to the old behavior, but I don't like
> anything about the way it works now. As an example, the new behavior is
> extremely unfriendly to backslash commands. I just got done typing a
> long command and then deciding that I would like to have \timing on, so
> I hit return (which in prior versions would have entered the line into
> the history buffer), typed \timing, hit return again, hit control-P, and
> found that I'd lost my long command.

I don't understand really this point. For example (in 8.1.3):

wsdb=# select 'your long query here ' ||
wsdb-# \timing
Timing is on.
wsdb-# 'plus something additional (also long)';
?column?
------------------------------------------------------------
your long query here plus something additional (also long)
(1 row)

Time: 3,644 ms

(all the time in that example I hit only return button)

Example in 8.2devel:

wsdb=# select 'your long query here ' ||
wsdb-# \timing
Timing is on.
wsdb-# 'something additional (also long)';
?column?
-------------------------------------------------------
your long query here something additional (also long)
(1 row)

Time: 0,760 ms

(again I hit only return button)

Yes, in the second example \timing WILL go to the history. And I think
that IS ok(even for example in 8.1.3 case the backslash commands are
also NOT stripped away from the SQL commands) Like this:

wsdb=# select 'your long query here ' \timing
Timing is on.
wsdb-# 'plus something additional (also long)';
?column?
------------------------------------------------------------
your long query here plus something additional (also long)
(1 row)

Time: 0,287 ms

The history will contain "select 'your long query here ' \timing"

So, do you think, that stripping away the \backslash commands from
multiline history entry is logical and is needed often? I certainly don't.

---------
Second issue:

In your example you probably forgot to say about pressing Ctrl+C. In that
case
in 8.1.3

wsdb=# select 'your long query here '
wsdb-# \timing
Timing is on.
wsdb-#

(after pressing Ctrl+C in last line, the "select ..." will be in the history),
and in 8.2devel it will NOT.

I fixed that issue. I've send the patch to -patches.

So, except that, I do not really see any problems with multiline queries.

Yes, I agree that for longterm PG hackers, the behaviour can seem a bit
unusual, but it is better ... (my opinion).

Regards,
Sergey

*****************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math(at)sai(dot)msu(dot)ru

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-03-05 04:45:07 Re: Building Windows Server Extensions Using VC++ 2005
Previous Message David Fetter 2006-03-05 03:24:07 Re: drop if exists remainder