fix of some issues with multi-line query editing

Lists: pgsql-patches
From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: pgsql-patches(at)postgresql(dot)org
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, <alvherre(at)commandprompt(dot)com>
Subject: fix of some issues with multi-line query editing
Date: 2006-03-05 03:57:19
Message-ID: Pine.LNX.4.44.0603050647060.16830-200000@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Fix of several issues:

1) Fix the problems with the \s command.
When the saveHistory is executed by the \s command we must not do the
conversion \n -> \x01 (per
http://archives.postgresql.org/pgsql-hackers/2006-03/msg00317.php )

2) Fix the handling of Ctrl+C

Now when you do
wsdb=# select 'your long query here '
wsdb-#
and press afterwards the CtrlC the line "select 'your long query here '"
will be in the history

(partly per
http://archives.postgresql.org/pgsql-hackers/2006-03/msg00297.php )

3) Fix the handling of commands with not closed brackets, quotes, double
quotes. (now those commands are not splitted in parts...)

4) Fix the behaviour when SINGLELINE mode is used. (before it was almost
broken ;(

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

Attachment Content-Type Size
multiline.diff text/plain 4.7 KB

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Cc: pgsql-patches(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us, alvherre(at)commandprompt(dot)com
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-06 04:47:24
Message-ID: 200603060447.k264lO211093@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


I have applied the following patch which saves psql history for
backslash commands used in multi-line statements before the command,
rather than inside it, e.g:

test=> SELECT
test-> \d
No relations found.
test-> 1;
?column?
----------
1
(1 row)

has history in this order:

test=> \d
No relations found.
test=> SELECT
1;
?column?
----------
1
(1 row)

I also renamed some of the history functions for clarity.

---------------------------------------------------------------------------

Sergey E. Koposov wrote:
> Fix of several issues:
>
> 1) Fix the problems with the \s command.
> When the saveHistory is executed by the \s command we must not do the
> conversion \n -> \x01 (per
> http://archives.postgresql.org/pgsql-hackers/2006-03/msg00317.php )
>
> 2) Fix the handling of Ctrl+C
>
> Now when you do
> wsdb=# select 'your long query here '
> wsdb-#
> and press afterwards the CtrlC the line "select 'your long query here '"
> will be in the history
>
> (partly per
> http://archives.postgresql.org/pgsql-hackers/2006-03/msg00297.php )
>
> 3) Fix the handling of commands with not closed brackets, quotes, double
> quotes. (now those commands are not splitted in parts...)
>
> 4) Fix the behaviour when SINGLELINE mode is used. (before it was almost
> broken ;(
>
> 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
>
>
>

Content-Description:

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
unknown_filename text/plain 6.5 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>, pgsql-patches(at)postgresql(dot)org, alvherre(at)commandprompt(dot)com
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-13 04:24:35
Message-ID: 26953.1142223875@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> 3) Fix the handling of commands with not closed brackets, quotes, double
>> quotes. (now those commands are not splitted in parts...)

Really? CVS tip seems to treat a multiline command as a single history
entry *unless* it contains newlines within quoted strings (including
single, double, dollar quotes) or newlines within /* comments.

I think this patch is seriously broken, and I don't agree with what it's
trying to accomplish in the first place --- I still haven't found any
cases where it's an improvement to pull back multiple lines as one
history entry. For example, if you made a mistake on the fifth line of
a ten-line CREATE TABLE command, the current code makes it extremely
inconvenient to fix that: you have to back-arrow or forward-arrow
tediously over five lines, where before you could pull back one line at
a time and just edir the line that needed fixing.

I'm still a vote to revert the patch altogether. But there is no theory
under which the current behavior is sane.

regards, tom lane


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: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, <pgsql-patches(at)postgresql(dot)org>, <alvherre(at)commandprompt(dot)com>
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-13 08:47:32
Message-ID: Pine.LNX.4.44.0603131139340.11667-100000@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


On Sun, 12 Mar 2006, Tom Lane wrote:

> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> >> 3) Fix the handling of commands with not closed brackets, quotes, double
> >> quotes. (now those commands are not splitted in parts...)
>
> Really? CVS tip seems to treat a multiline command as a single history
> entry *unless* it contains newlines within quoted strings (including
> single, double, dollar quotes) or newlines within /* comments.

Bruce have NOT applied MY patch, which really contained the fixes of the
described problems... So, I'm waiting for it...

>
> I think this patch is seriously broken, and I don't agree with what it's
> trying to accomplish in the first place --- I still haven't found any
> cases where it's an improvement to pull back multiple lines as one
> history entry. For example, if you made a mistake on the fifth line of
> a ten-line CREATE TABLE command, the current code makes it extremely
> inconvenient to fix that: you have to back-arrow or forward-arrow
> tediously over five lines, where before you could pull back one line at
> a time and just edir the line that needed fixing.

(you do always Ctrl+Left_arrow ... to do that faster...) I don't see
anything bad here, that's the normal way to do it...

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


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org, alvherre(at)commandprompt(dot)com
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-13 13:38:51
Message-ID: 200603131338.k2DDcpQ19755@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Sergey E. Koposov wrote:
>
> On Sun, 12 Mar 2006, Tom Lane wrote:
>
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > >> 3) Fix the handling of commands with not closed brackets, quotes, double
> > >> quotes. (now those commands are not splitted in parts...)
> >
> > Really? CVS tip seems to treat a multiline command as a single history
> > entry *unless* it contains newlines within quoted strings (including
> > single, double, dollar quotes) or newlines within /* comments.
>
>
> Bruce have NOT applied MY patch, which really contained the fixes of the
> described problems... So, I'm waiting for it...

Uh, what patch? I don't have any additional patch for this? Can you
resend it or give the subject line.

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>, pgsql-patches(at)postgresql(dot)org
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-13 13:42:12
Message-ID: 20060313134212.GC8274@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:

> I think this patch is seriously broken, and I don't agree with what it's
> trying to accomplish in the first place --- I still haven't found any
> cases where it's an improvement to pull back multiple lines as one
> history entry. For example, if you made a mistake on the fifth line of
> a ten-line CREATE TABLE command, the current code makes it extremely
> inconvenient to fix that: you have to back-arrow or forward-arrow
> tediously over five lines, where before you could pull back one line at
> a time and just edir the line that needed fixing.

Huh, I find precisely that behavior very difficult to use; you end up
pressing up-arrow ten times to get the first line, ten times to get the
second line, ten more times to get the third line, up to a total of a
hundred times! And if you press it nine or eleven times instead of ten
and press "enter" before realizing it (a mistake very easily made), you
are hosed and have to start all over.

Instead of waiting for back-arrow I usually use Alt-b and Alt-f. Or if
I have to go back 20 words, esc-20 alt-b. This is much quicker.

(I agree that there are still bugs. But we should correct those, not
remove the useful behavior.)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-patches(at)postgresql(dot)org>, <alvherre(at)commandprompt(dot)com>
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-13 13:53:47
Message-ID: Pine.LNX.4.44.0603131650330.11667-100000@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Mon, 13 Mar 2006, Bruce Momjian wrote:
> Sergey E. Koposov wrote:
> > Bruce have NOT applied MY patch, which really contained the fixes of the
> > described problems... So, I'm waiting for it...
>
> Uh, what patch? I don't have any additional patch for this? Can you
> resend it or give the subject line.
>

The patch from here:
http://archives.postgresql.org/pgsql-patches/2006-03/msg00058.php

(from exactly This thread: [fix of some issues with multi-line query editing])
^^^^

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


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org, alvherre(at)commandprompt(dot)com
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-13 14:06:40
Message-ID: 200603131406.k2DE6eC07744@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Sergey E. Koposov wrote:
> On Mon, 13 Mar 2006, Bruce Momjian wrote:
> > Sergey E. Koposov wrote:
> > > Bruce have NOT applied MY patch, which really contained the fixes of the
> > > described problems... So, I'm waiting for it...
> >
> > Uh, what patch? I don't have any additional patch for this? Can you
> > resend it or give the subject line.
> >
>
> The patch from here:
> http://archives.postgresql.org/pgsql-patches/2006-03/msg00058.php
>
> (from exactly This thread: [fix of some issues with multi-line query editing])

Great. Sorry I had missed that patch. Added to patch queue now.

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Cc: pgsql-patches(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us, alvherre(at)commandprompt(dot)com
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-21 13:38:27
Message-ID: 200603211338.k2LDcRF14008@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Sergey E. Koposov wrote:
> Fix of several issues:
>
> 1) Fix the problems with the \s command.
> When the saveHistory is executed by the \s command we must not do the
> conversion \n -> \x01 (per
> http://archives.postgresql.org/pgsql-hackers/2006-03/msg00317.php )
>
> 2) Fix the handling of Ctrl+C
>
> Now when you do
> wsdb=# select 'your long query here '
> wsdb-#
> and press afterwards the CtrlC the line "select 'your long query here '"
> will be in the history
>
> (partly per
> http://archives.postgresql.org/pgsql-hackers/2006-03/msg00297.php )
>
> 3) Fix the handling of commands with not closed brackets, quotes, double
> quotes. (now those commands are not splitted in parts...)
>
> 4) Fix the behaviour when SINGLELINE mode is used. (before it was almost
> broken ;(

Great. Patch applied. I had to adjust your patch around changes made
to put backslash commands embedded in queries to the top of the history.

Updated patch attached.

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
unknown_filename text/plain 4.6 KB

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>, pgsql-patches(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us
Subject: Re: fix of some issues with multi-line query editing
Date: 2006-03-21 14:28:23
Message-ID: 20060321142823.GB5683@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian wrote:

> Great. Patch applied. I had to adjust your patch around changes made
> to put backslash commands embedded in queries to the top of the history.

I have tested it and it works according to my expectations; the bugs I
noticed are no longer there. Thanks!

It's a bit annoying (you could say bogus) when the query buffer is
longer than the terminal. Not sure if that's a problem of the patch or
it has always been like this. It's possible to workaround using \e.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support