Re: Review: query result history in psql

Lists: pgsql-hackers
From: ian link <ian(at)ilink(dot)io>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Review: query result history in psql
Date: 2013-06-25 21:29:15
Message-ID: CAOOwM5+bhSnxTyEs=k_UdR2xROcfRPOxHQOfqP60+TT_pahwcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Maciej,

I've been reviewing your patch for the ongoing commitfest. First let me say
that I think it's a great idea and provides some very useful functionality.

However, there are a few minor problems. There were a few
english/grammatical mistakes that I went ahead and fixed. Additionally, I
think some of the string manipulation might be placed outside of the main
ans.c file. I don't know if there's a better place for 'EscapeForCopy' and
'GetEscapedLen'. Not really a big deal, just an organizational idea. I also
changed 'EscapeForCopy' to 'EscapeAndCopy'. I think that better describes
the functionality. 'EscapeForCopy' kind of implies that another function is
needed to copy the string.

What does 'ans' stand for? I am not sure how it relates to the concept of a
query history. It didn't stop my understanding of the code, but I don't
know if a user will immediately know the meaning.

Probably the biggest problem is that the query history list is missing a
maximum size variable. I think this could be valuable for preventing users
from shooting themselves in the foot. If the user is running large queries,
they might accidentally store too much data. This probably somewhat of an
edge-case but I believe it is worth considering. We could provide a
sensible default limit (10 queries?) and also allow the user to change it.

Finally, is it worth resetting the query history every time a user
reconnects to the database? I can see how this might interrupt a user's
workflow. If the user suddenly disconnects (network connection interrupted,
etc) then they would lose their history. I think this is definitely up for
debate. It would add more management overhead (psql options etc) and might
just be unnecessary. However, with a sane limit to the size of the query
history, I don't know if there would be too many drawbacks from a storage
perspective.

Those issues aside - I think it's a great feature! I can add the
grammatical fixes I made whenever the final patch is ready. Or earlier,
whatever works for you. Also, this is my first time reviewing a patch, so
please let me know if I can improve on anything. Thanks!

Ian Link


From: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
To: ian link <ian(at)ilink(dot)io>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-27 10:54:28
Message-ID: CAEcSYXJT8SbFuicGJSp5Ujp4-8r+GFhBbDxpYcjs=hdcskHvog@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thank you for the review!

There were a few english/grammatical mistakes that I went ahead and fixed.
>

Thank you for that. If you could send me a patch-to-a-patch so I can
correct all the mistakes in the next release?

> Additionally, I think some of the string manipulation might be placed
> outside of the main ans.c file. I don't know if there's a better place for
> 'EscapeForCopy' and 'GetEscapedLen'. Not really a big deal, just an
> organizational idea. I also changed 'EscapeForCopy' to 'EscapeAndCopy'. I
> think that better describes the functionality. 'EscapeForCopy' kind of
> implies that another function is needed to copy the string.
>

The 'EscapeForCopy' was meant to mean 'Escape string in a format require by
the COPY TEXT format', so 'copy' in the name refers to the escaping format,
not the action performed by the function.

They could be, indeed, placed in separate module. I'll do it.

>
> What does 'ans' stand for? I am not sure how it relates to the concept of
> a query history. It didn't stop my understanding of the code, but I don't
> know if a user will immediately know the meaning.
>

Some mathematical toolkits, like Matlab or Mathematica, automatically set a
variable called 'ans' (short for "answer") containing the result of the
last operation. I was trying to emulate exactly this behaviour.

> Probably the biggest problem is that the query history list is missing a
> maximum size variable. I think this could be valuable for preventing users
> from shooting themselves in the foot. If the user is running large queries,
> they might accidentally store too much data. This probably somewhat of an
> edge-case but I believe it is worth considering. We could provide a
> sensible default limit (10 queries?) and also allow the user to change it.
>

I was considering such a behaviour. But since the feature is turned off by
default, I decided that whoever is using it, is aware of cost. Instead of
truncating the history automatically (which could lead to a nasty
surprise), I decided to equip the user with \ansclean , a command erasing
the history. I believe that it is better to let the user decide when
history should be erased, instead of doing it automatically.

Finally, is it worth resetting the query history every time a user
> reconnects to the database? I can see how this might interrupt a user's
> workflow. If the user suddenly disconnects (network connection interrupted,
> etc) then they would lose their history. I think this is definitely up for
> debate. It would add more management overhead (psql options etc) and might
> just be unnecessary. However, with a sane limit to the size of the query
> history, I don't know if there would be too many drawbacks from a storage
> perspective.
>

The history is not erased. The history is always stored in the client's
memory. When a history item is used for the first time, a TEMPORARY table
is created in the database that stores the data server-side. When user
disconnects from the database, the session ends and all these tables are
dropped.
Tables names have to be removed from the history, so next time the item is
used, the table will be created and populated again.

I use the feature while switching often between databases, and it works
seamlessly. Actually, it's quite useful to move bits of data across
databases:
Connect to database A, run a query, connect to database B, run another
query joining local data with the results of the previous query.

> Those issues aside - I think it's a great feature! I can add the
> grammatical fixes I made whenever the final patch is ready. Or earlier,
> whatever works for you. Also, this is my first time reviewing a patch, so
> please let me know if I can improve on anything. Thanks!
>

This is my first submitted patch, so I can't really comment on the
process. But if you could add the author's email to CC, the message would
be much easier to spot. I replied after two days only because I missed the
message in the flood of other pgsql-hacker messages. I think I need to scan
the list more carefully...

Maciej


From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
Cc: ian link <ian(at)ilink(dot)io>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-27 17:53:20
Message-ID: 20130627175319.GH3757@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Maciej Gajewski escribió:

> > Those issues aside - I think it's a great feature! I can add the
> > grammatical fixes I made whenever the final patch is ready. Or earlier,
> > whatever works for you. Also, this is my first time reviewing a patch, so
> > please let me know if I can improve on anything. Thanks!
>
> This is my first submitted patch, so I can't really comment on the
> process. But if you could add the author's email to CC, the message would
> be much easier to spot. I replied after two days only because I missed the
> message in the flood of other pgsql-hacker messages. I think I need to scan
> the list more carefully...

It's better to post a review as a reply to the message which contains
the patch.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: ian link <ian(at)ilink(dot)io>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-28 06:11:19
Message-ID: CAOOwM5++hTguczTfz+w5g1B6P49scV0Vc=tqRx4x-mRT9iP-3g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>
> It's better to post a review as a reply to the message which contains
> the patch.

Sorry about that, I did not have the email in my inbox and couldn't figure
out how to use the old message ID to send a reply. Here is the thread:
http://www.postgresql.org/message-id/flat/CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw(at)mail(dot)gmail(dot)com#CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw@mail.gmail.com

The 'EscapeForCopy' was meant to mean 'Escape string in a format require by
> the COPY TEXT format', so 'copy' in the name refers to the escaping format,
> not the action performed by the function.
>

I see, that makes sense now. Keep it as you see fit, it's not a big deal in
my opinion.

Some mathematical toolkits, like Matlab or Mathematica, automatically set
> a variable called 'ans' (short for "answer") containing the result of the
> last operation. I was trying to emulate exactly this behaviour.

I've actually been using Matlab lately, which must be why the name made
sense to me intuitively. I don't know if this is the best name, however. It
kind of assumes that our users use Matlab/Octave/Mathematica. Maybe 'qhist'
or 'hist' or something?

The history is not erased. The history is always stored in the client's
> memory.

Ah, I did not pick up on that. Thank you for explaining it! That's actually
a very neat way of doing it. Sorry I did not realize that at first.

I was considering such a behaviour. But since the feature is turned off by
> default, I decided that whoever is using it, is aware of cost. Instead of
> truncating the history automatically (which could lead to a nasty
> surprise), I decided to equip the user with \ansclean , a command erasing
> the history. I believe that it is better to let the user decide when
> history should be erased, instead of doing it automatically.

I think you are correct. However, if we turn on the feature by default (at
some point in the future) the discussion should probably be re-visited.

This is my first submitted patch, so I can't really comment on the
> process. But if you could add the author's email to CC, the message would
> be much easier to spot. I replied after two days only because I missed the
> message in the flood of other pgsql-hacker messages. I think I need to scan
> the list more carefully...

My fault, I definitely should have CC'd you.

As for the patch, I made a new version of the latest one you provided in
the original thread. Let me know if anything breaks, but it compiles fine
on my box. Thanks for the feedback!

Ian

Attachment Content-Type Size
query-history-review1.patch application/octet-stream 17.0 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: ian link <ian(at)ilink(dot)io>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-28 06:28:19
Message-ID: CAFj8pRDfMsW5qnzFitbO3Kw3n4gDkxYP9u72o4ihAUm8LT++dw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

after patching I god segfault

Program terminated with signal 11, Segmentation fault.
#0 0x0805aab4 in get_prompt (status=PROMPT_READY) at prompt.c:98
98 for (p = prompt_string;
Missing separate debuginfos, use: debuginfo-install glibc-2.13-2.i686
ncurses-libs-5.7-9.20100703.fc14.i686 readline-6.1-2.fc14.i386
(gdb) bt
#0 0x0805aab4 in get_prompt (status=PROMPT_READY) at prompt.c:98
#1 0x0805786a in MainLoop (source=0xc45440) at mainloop.c:134
#2 0x0805a68d in main (argc=2, argv=0xbfcf2894) at startup.c:336

Regards

Pavel Stehule

2013/6/28 ian link <ian(at)ilink(dot)io>:
>> It's better to post a review as a reply to the message which contains
>> the patch.
>
> Sorry about that, I did not have the email in my inbox and couldn't figure
> out how to use the old message ID to send a reply. Here is the thread:
> http://www.postgresql.org/message-id/flat/CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw(at)mail(dot)gmail(dot)com#CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw@mail.gmail.com
>
>> The 'EscapeForCopy' was meant to mean 'Escape string in a format require
>> by the COPY TEXT format', so 'copy' in the name refers to the escaping
>> format, not the action performed by the function.
>
>
> I see, that makes sense now. Keep it as you see fit, it's not a big deal in
> my opinion.
>
>> Some mathematical toolkits, like Matlab or Mathematica, automatically set
>> a variable called 'ans' (short for "answer") containing the result of the
>> last operation. I was trying to emulate exactly this behaviour.
>
>
> I've actually been using Matlab lately, which must be why the name made
> sense to me intuitively. I don't know if this is the best name, however. It
> kind of assumes that our users use Matlab/Octave/Mathematica. Maybe 'qhist'
> or 'hist' or something?
>
>> The history is not erased. The history is always stored in the client's
>> memory.
>
> Ah, I did not pick up on that. Thank you for explaining it! That's actually
> a very neat way of doing it. Sorry I did not realize that at first.
>
>> I was considering such a behaviour. But since the feature is turned off by
>> default, I decided that whoever is using it, is aware of cost. Instead of
>> truncating the history automatically (which could lead to a nasty surprise),
>> I decided to equip the user with \ansclean , a command erasing the history.
>> I believe that it is better to let the user decide when history should be
>> erased, instead of doing it automatically.
>
>
> I think you are correct. However, if we turn on the feature by default (at
> some point in the future) the discussion should probably be re-visited.
>
>> This is my first submitted patch, so I can't really comment on the
>> process. But if you could add the author's email to CC, the message would be
>> much easier to spot. I replied after two days only because I missed the
>> message in the flood of other pgsql-hacker messages. I think I need to scan
>> the list more carefully...
>
> My fault, I definitely should have CC'd you.
>
> As for the patch, I made a new version of the latest one you provided in the
> original thread. Let me know if anything breaks, but it compiles fine on my
> box. Thanks for the feedback!
>
> Ian
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>


From: ian link <ian(at)ilink(dot)io>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-28 06:54:31
Message-ID: CAOOwM5L3hA1vU0k6uiZoe647hiSvw6tBx=70o64TTuHHVX1Gog@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I just applied the patch to a clean branch from the latest master. I
couldn't get a segfault from using the new feature. Could you provide a
little more info to reproduce the segfault? Thanks

On Thu, Jun 27, 2013 at 11:28 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>wrote:

> Hello
>
> after patching I god segfault
>
> Program terminated with signal 11, Segmentation fault.
> #0 0x0805aab4 in get_prompt (status=PROMPT_READY) at prompt.c:98
> 98 for (p = prompt_string;
> Missing separate debuginfos, use: debuginfo-install glibc-2.13-2.i686
> ncurses-libs-5.7-9.20100703.fc14.i686 readline-6.1-2.fc14.i386
> (gdb) bt
> #0 0x0805aab4 in get_prompt (status=PROMPT_READY) at prompt.c:98
> #1 0x0805786a in MainLoop (source=0xc45440) at mainloop.c:134
> #2 0x0805a68d in main (argc=2, argv=0xbfcf2894) at startup.c:336
>
> Regards
>
> Pavel Stehule
>
> 2013/6/28 ian link <ian(at)ilink(dot)io>:
> >> It's better to post a review as a reply to the message which contains
> >> the patch.
> >
> > Sorry about that, I did not have the email in my inbox and couldn't
> figure
> > out how to use the old message ID to send a reply. Here is the thread:
> >
> http://www.postgresql.org/message-id/flat/CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw(at)mail(dot)gmail(dot)com#CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw@mail.gmail.com
> >
> >> The 'EscapeForCopy' was meant to mean 'Escape string in a format require
> >> by the COPY TEXT format', so 'copy' in the name refers to the escaping
> >> format, not the action performed by the function.
> >
> >
> > I see, that makes sense now. Keep it as you see fit, it's not a big deal
> in
> > my opinion.
> >
> >> Some mathematical toolkits, like Matlab or Mathematica, automatically
> set
> >> a variable called 'ans' (short for "answer") containing the result of
> the
> >> last operation. I was trying to emulate exactly this behaviour.
> >
> >
> > I've actually been using Matlab lately, which must be why the name made
> > sense to me intuitively. I don't know if this is the best name, however.
> It
> > kind of assumes that our users use Matlab/Octave/Mathematica. Maybe
> 'qhist'
> > or 'hist' or something?
> >
> >> The history is not erased. The history is always stored in the client's
> >> memory.
> >
> > Ah, I did not pick up on that. Thank you for explaining it! That's
> actually
> > a very neat way of doing it. Sorry I did not realize that at first.
> >
> >> I was considering such a behaviour. But since the feature is turned off
> by
> >> default, I decided that whoever is using it, is aware of cost. Instead
> of
> >> truncating the history automatically (which could lead to a nasty
> surprise),
> >> I decided to equip the user with \ansclean , a command erasing the
> history.
> >> I believe that it is better to let the user decide when history should
> be
> >> erased, instead of doing it automatically.
> >
> >
> > I think you are correct. However, if we turn on the feature by default
> (at
> > some point in the future) the discussion should probably be re-visited.
> >
> >> This is my first submitted patch, so I can't really comment on the
> >> process. But if you could add the author's email to CC, the message
> would be
> >> much easier to spot. I replied after two days only because I missed the
> >> message in the flood of other pgsql-hacker messages. I think I need to
> scan
> >> the list more carefully...
> >
> > My fault, I definitely should have CC'd you.
> >
> > As for the patch, I made a new version of the latest one you provided in
> the
> > original thread. Let me know if anything breaks, but it compiles fine on
> my
> > box. Thanks for the feedback!
> >
> > Ian
> >
> >
> > --
> > Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-hackers
> >
>


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: ian link <ian(at)ilink(dot)io>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-28 07:20:29
Message-ID: CAFj8pRA-dx_0w7Vdyn_j+1uR8q0+MAKt=5VvR1304a=RRTA7Cw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

It's look like my bug - wrong compilation

I am sorry

Pavel

2013/6/28 ian link <ian(at)ilink(dot)io>:
> I just applied the patch to a clean branch from the latest master. I
> couldn't get a segfault from using the new feature. Could you provide a
> little more info to reproduce the segfault? Thanks
>
>
> On Thu, Jun 27, 2013 at 11:28 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>>
>> Hello
>>
>> after patching I god segfault
>>
>> Program terminated with signal 11, Segmentation fault.
>> #0 0x0805aab4 in get_prompt (status=PROMPT_READY) at prompt.c:98
>> 98 for (p = prompt_string;
>> Missing separate debuginfos, use: debuginfo-install glibc-2.13-2.i686
>> ncurses-libs-5.7-9.20100703.fc14.i686 readline-6.1-2.fc14.i386
>> (gdb) bt
>> #0 0x0805aab4 in get_prompt (status=PROMPT_READY) at prompt.c:98
>> #1 0x0805786a in MainLoop (source=0xc45440) at mainloop.c:134
>> #2 0x0805a68d in main (argc=2, argv=0xbfcf2894) at startup.c:336
>>
>> Regards
>>
>> Pavel Stehule
>>
>> 2013/6/28 ian link <ian(at)ilink(dot)io>:
>> >> It's better to post a review as a reply to the message which contains
>> >> the patch.
>> >
>> > Sorry about that, I did not have the email in my inbox and couldn't
>> > figure
>> > out how to use the old message ID to send a reply. Here is the thread:
>> >
>> > http://www.postgresql.org/message-id/flat/CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw(at)mail(dot)gmail(dot)com#CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw@mail.gmail.com
>> >
>> >> The 'EscapeForCopy' was meant to mean 'Escape string in a format
>> >> require
>> >> by the COPY TEXT format', so 'copy' in the name refers to the escaping
>> >> format, not the action performed by the function.
>> >
>> >
>> > I see, that makes sense now. Keep it as you see fit, it's not a big deal
>> > in
>> > my opinion.
>> >
>> >> Some mathematical toolkits, like Matlab or Mathematica, automatically
>> >> set
>> >> a variable called 'ans' (short for "answer") containing the result of
>> >> the
>> >> last operation. I was trying to emulate exactly this behaviour.
>> >
>> >
>> > I've actually been using Matlab lately, which must be why the name made
>> > sense to me intuitively. I don't know if this is the best name, however.
>> > It
>> > kind of assumes that our users use Matlab/Octave/Mathematica. Maybe
>> > 'qhist'
>> > or 'hist' or something?
>> >
>> >> The history is not erased. The history is always stored in the client's
>> >> memory.
>> >
>> > Ah, I did not pick up on that. Thank you for explaining it! That's
>> > actually
>> > a very neat way of doing it. Sorry I did not realize that at first.
>> >
>> >> I was considering such a behaviour. But since the feature is turned off
>> >> by
>> >> default, I decided that whoever is using it, is aware of cost. Instead
>> >> of
>> >> truncating the history automatically (which could lead to a nasty
>> >> surprise),
>> >> I decided to equip the user with \ansclean , a command erasing the
>> >> history.
>> >> I believe that it is better to let the user decide when history should
>> >> be
>> >> erased, instead of doing it automatically.
>> >
>> >
>> > I think you are correct. However, if we turn on the feature by default
>> > (at
>> > some point in the future) the discussion should probably be re-visited.
>> >
>> >> This is my first submitted patch, so I can't really comment on the
>> >> process. But if you could add the author's email to CC, the message
>> >> would be
>> >> much easier to spot. I replied after two days only because I missed the
>> >> message in the flood of other pgsql-hacker messages. I think I need to
>> >> scan
>> >> the list more carefully...
>> >
>> > My fault, I definitely should have CC'd you.
>> >
>> > As for the patch, I made a new version of the latest one you provided in
>> > the
>> > original thread. Let me know if anything breaks, but it compiles fine on
>> > my
>> > box. Thanks for the feedback!
>> >
>> > Ian
>> >
>> >
>> > --
>> > Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
>> > To make changes to your subscription:
>> > http://www.postgresql.org/mailpref/pgsql-hackers
>> >
>
>


From: ian link <ian(at)ilink(dot)io>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-28 07:21:29
Message-ID: CAOOwM5+KW2bktDr0e0Tm7uSkAEk3VDCGuF_tBNkm2pw7mFM1Yw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

No worries! :)

On Fri, Jun 28, 2013 at 12:20 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>wrote:

> Hello
>
> It's look like my bug - wrong compilation
>
> I am sorry
>
> Pavel
>
> 2013/6/28 ian link <ian(at)ilink(dot)io>:
> > I just applied the patch to a clean branch from the latest master. I
> > couldn't get a segfault from using the new feature. Could you provide a
> > little more info to reproduce the segfault? Thanks
> >
> >
> > On Thu, Jun 27, 2013 at 11:28 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com
> >
> > wrote:
> >>
> >> Hello
> >>
> >> after patching I god segfault
> >>
> >> Program terminated with signal 11, Segmentation fault.
> >> #0 0x0805aab4 in get_prompt (status=PROMPT_READY) at prompt.c:98
> >> 98 for (p = prompt_string;
> >> Missing separate debuginfos, use: debuginfo-install glibc-2.13-2.i686
> >> ncurses-libs-5.7-9.20100703.fc14.i686 readline-6.1-2.fc14.i386
> >> (gdb) bt
> >> #0 0x0805aab4 in get_prompt (status=PROMPT_READY) at prompt.c:98
> >> #1 0x0805786a in MainLoop (source=0xc45440) at mainloop.c:134
> >> #2 0x0805a68d in main (argc=2, argv=0xbfcf2894) at startup.c:336
> >>
> >> Regards
> >>
> >> Pavel Stehule
> >>
> >> 2013/6/28 ian link <ian(at)ilink(dot)io>:
> >> >> It's better to post a review as a reply to the message which contains
> >> >> the patch.
> >> >
> >> > Sorry about that, I did not have the email in my inbox and couldn't
> >> > figure
> >> > out how to use the old message ID to send a reply. Here is the thread:
> >> >
> >> >
> http://www.postgresql.org/message-id/flat/CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw(at)mail(dot)gmail(dot)com#CAEcSYXJRi++T3pevDyzAWH2yGx7kG9ZrhX8KAWtP1fXV3H02vw@mail.gmail.com
> >> >
> >> >> The 'EscapeForCopy' was meant to mean 'Escape string in a format
> >> >> require
> >> >> by the COPY TEXT format', so 'copy' in the name refers to the
> escaping
> >> >> format, not the action performed by the function.
> >> >
> >> >
> >> > I see, that makes sense now. Keep it as you see fit, it's not a big
> deal
> >> > in
> >> > my opinion.
> >> >
> >> >> Some mathematical toolkits, like Matlab or Mathematica,
> automatically
> >> >> set
> >> >> a variable called 'ans' (short for "answer") containing the result of
> >> >> the
> >> >> last operation. I was trying to emulate exactly this behaviour.
> >> >
> >> >
> >> > I've actually been using Matlab lately, which must be why the name
> made
> >> > sense to me intuitively. I don't know if this is the best name,
> however.
> >> > It
> >> > kind of assumes that our users use Matlab/Octave/Mathematica. Maybe
> >> > 'qhist'
> >> > or 'hist' or something?
> >> >
> >> >> The history is not erased. The history is always stored in the
> client's
> >> >> memory.
> >> >
> >> > Ah, I did not pick up on that. Thank you for explaining it! That's
> >> > actually
> >> > a very neat way of doing it. Sorry I did not realize that at first.
> >> >
> >> >> I was considering such a behaviour. But since the feature is turned
> off
> >> >> by
> >> >> default, I decided that whoever is using it, is aware of cost.
> Instead
> >> >> of
> >> >> truncating the history automatically (which could lead to a nasty
> >> >> surprise),
> >> >> I decided to equip the user with \ansclean , a command erasing the
> >> >> history.
> >> >> I believe that it is better to let the user decide when history
> should
> >> >> be
> >> >> erased, instead of doing it automatically.
> >> >
> >> >
> >> > I think you are correct. However, if we turn on the feature by default
> >> > (at
> >> > some point in the future) the discussion should probably be
> re-visited.
> >> >
> >> >> This is my first submitted patch, so I can't really comment on the
> >> >> process. But if you could add the author's email to CC, the message
> >> >> would be
> >> >> much easier to spot. I replied after two days only because I missed
> the
> >> >> message in the flood of other pgsql-hacker messages. I think I need
> to
> >> >> scan
> >> >> the list more carefully...
> >> >
> >> > My fault, I definitely should have CC'd you.
> >> >
> >> > As for the patch, I made a new version of the latest one you provided
> in
> >> > the
> >> > original thread. Let me know if anything breaks, but it compiles fine
> on
> >> > my
> >> > box. Thanks for the feedback!
> >> >
> >> > Ian
> >> >
> >> >
> >> > --
> >> > Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> >> > To make changes to your subscription:
> >> > http://www.postgresql.org/mailpref/pgsql-hackers
> >> >
> >
> >
>


From: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
To: ian link <ian(at)ilink(dot)io>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-28 08:10:02
Message-ID: CAEcSYX+fTZ=Dr4sgiDkBi=deNeogrYwCdFO+4=QdOSxBpBVKPw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thanks for checking the patch!

So what's left to fix?
* Moving the escaping-related functions to separate module,
* applying your corrections.

Did I missed anything?

I'll submit corrected patch after the weekend.

M


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
Cc: ian link <ian(at)ilink(dot)io>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-06-28 15:49:28
Message-ID: CAFj8pRAiWL79DStWt=qOiSmXrpgVEynpMQ=Jz0qiQ6nQxjgL5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

I am not sure, this interface is really user friendly

there is not possible "searching" in history, and not every query push
to history some interesting content.

It require:

* simply decision if content should be stored in history or not,
* simply remove last entry (table) of history
* queries should be joined to content, only name is not enough

Regards

Pavel

2013/6/28 Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>:
> Thanks for checking the patch!
>
> So what's left to fix?
> * Moving the escaping-related functions to separate module,
> * applying your corrections.
>
> Did I missed anything?
>
> I'll submit corrected patch after the weekend.
>
> M
>


From: ian link <ian(at)ilink(dot)io>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-01 01:19:02
Message-ID: CAOOwM5Lxvj=VnROxq_7Y_Y+7YFwiUtVzrurUHF3DN9JD0Q0Jhg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Not sure about all of your suggestions. Let me see if I can clarify what
you're looking for.

> * simply decision if content should be stored in history or not,

Do you mean that the user should use a flag to place the result of a query
into the history?
like:
--ans SELECT * FROM cities...
Not sure if that's what you mean, but it seems kind of unnecesary. They can
just hit the \ans flag beforehand.

* simply remove last entry (table) of history

That could be useful. What do you think Maciej?

* queries should be joined to content, only name is not enough

Don't know what you mean. Could you try re-wording that?

Ian

On Fri, Jun 28, 2013 at 8:49 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>wrote:

> Hello
>
> I am not sure, this interface is really user friendly
>
> there is not possible "searching" in history, and not every query push
> to history some interesting content.
>
> It require:
>
> * simply decision if content should be stored in history or not,
> * simply remove last entry (table) of history
> * queries should be joined to content, only name is not enough
>
> Regards
>
> Pavel
>
> 2013/6/28 Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>:
> > Thanks for checking the patch!
> >
> > So what's left to fix?
> > * Moving the escaping-related functions to separate module,
> > * applying your corrections.
> >
> > Did I missed anything?
> >
> > I'll submit corrected patch after the weekend.
> >
> > M
> >
>


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: ian link <ian(at)ilink(dot)io>
Cc: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-01 06:35:44
Message-ID: CAFj8pRCTth1Zj=dbHA6jrw4bYyMWg7J8ymASDrGQvAA_PuePsw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

2013/7/1 ian link <ian(at)ilink(dot)io>:
> Not sure about all of your suggestions. Let me see if I can clarify what
> you're looking for.
>
>>
>> * simply decision if content should be stored in history or not,
>
> Do you mean that the user should use a flag to place the result of a query
> into the history?
> like:
> --ans SELECT * FROM cities...
> Not sure if that's what you mean, but it seems kind of unnecesary. They can
> just hit the \ans flag beforehand.

switching off on is not user friendly

but maybe some interactive mode should be usefull - so after
execution, and showing result, will be prompt if result should be
saved or not.

some like:

\ans interactive
> SELECT * FROM pg_proc;

**** result ****

should be saved last result [y, n]?
> y
result is saved in :ans22

>

>
>> * simply remove last entry (table) of history
>
> That could be useful. What do you think Maciej?

yes, lot of queries is just +/- experiment and you don't would store result

>
>> * queries should be joined to content, only name is not enough
>
> Don't know what you mean. Could you try re-wording that?
>

yes, the names :ans01, :ans02, ... miss semantics - How I can join
this name (and content) with some SQL query?

I needs to reverese search in SQL of stored caches, and I need a information

ans01 SELECT * FROM pg_proc
ans02 SELECT * FROM ans02 WHERE ...
ans03 ...

Regards

Pavel

> Ian
>
>
>
> On Fri, Jun 28, 2013 at 8:49 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>>
>> Hello
>>
>> I am not sure, this interface is really user friendly
>>
>> there is not possible "searching" in history, and not every query push
>> to history some interesting content.
>>
>> It require:
>>
>> * simply decision if content should be stored in history or not,
>> * simply remove last entry (table) of history
>> * queries should be joined to content, only name is not enough
>>
>> Regards
>>
>> Pavel
>>
>> 2013/6/28 Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>:
>> > Thanks for checking the patch!
>> >
>> > So what's left to fix?
>> > * Moving the escaping-related functions to separate module,
>> > * applying your corrections.
>> >
>> > Did I missed anything?
>> >
>> > I'll submit corrected patch after the weekend.
>> >
>> > M
>> >
>
>


From: ian link <ian(at)ilink(dot)io>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-01 07:19:15
Message-ID: CAOOwM5K+8=2=ANsGeAHi5hWB_meD9OspV_1Y-6ATc9AkLvdcdw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>
> but maybe some interactive mode should be usefull - so after
> execution, and showing result, will be prompt if result should be
> saved or not.

I like the idea, in addition to the ordinary mode. Personally, I would use
the ordinary mode, but I can see how 'interactive' would be useful.

yes, the names :ans01, :ans02, ... miss semantics - How I can join

this name (and content) with some SQL query?

That makes sense. I think having part of / the whole query string would be
very helpful. Great suggestion!

Maciej, would you be able/have time to implement these? Or do you need any
help getting them done?

On Sun, Jun 30, 2013 at 11:35 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>wrote:

> Hello
>
> 2013/7/1 ian link <ian(at)ilink(dot)io>:
> > Not sure about all of your suggestions. Let me see if I can clarify what
> > you're looking for.
> >
> >>
> >> * simply decision if content should be stored in history or not,
> >
> > Do you mean that the user should use a flag to place the result of a
> query
> > into the history?
> > like:
> > --ans SELECT * FROM cities...
> > Not sure if that's what you mean, but it seems kind of unnecesary. They
> can
> > just hit the \ans flag beforehand.
>
> switching off on is not user friendly
>
> but maybe some interactive mode should be usefull - so after
> execution, and showing result, will be prompt if result should be
> saved or not.
>
> some like:
>
> \ans interactive
> > SELECT * FROM pg_proc;
>
> **** result ****
>
> should be saved last result [y, n]?
> > y
> result is saved in :ans22
>
> >
>
>
> >
> >> * simply remove last entry (table) of history
> >
> > That could be useful. What do you think Maciej?
>
> yes, lot of queries is just +/- experiment and you don't would store result
>
> >
> >> * queries should be joined to content, only name is not enough
> >
> > Don't know what you mean. Could you try re-wording that?
> >
>
> yes, the names :ans01, :ans02, ... miss semantics - How I can join
> this name (and content) with some SQL query?
>
> I needs to reverese search in SQL of stored caches, and I need a
> information
>
> ans01 SELECT * FROM pg_proc
> ans02 SELECT * FROM ans02 WHERE ...
> ans03 ...
>
> Regards
>
> Pavel
>
> > Ian
> >
> >
> >
> > On Fri, Jun 28, 2013 at 8:49 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> > wrote:
> >>
> >> Hello
> >>
> >> I am not sure, this interface is really user friendly
> >>
> >> there is not possible "searching" in history, and not every query push
> >> to history some interesting content.
> >>
> >> It require:
> >>
> >> * simply decision if content should be stored in history or not,
> >> * simply remove last entry (table) of history
> >> * queries should be joined to content, only name is not enough
> >>
> >> Regards
> >>
> >> Pavel
> >>
> >> 2013/6/28 Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>:
> >> > Thanks for checking the patch!
> >> >
> >> > So what's left to fix?
> >> > * Moving the escaping-related functions to separate module,
> >> > * applying your corrections.
> >> >
> >> > Did I missed anything?
> >> >
> >> > I'll submit corrected patch after the weekend.
> >> >
> >> > M
> >> >
> >
> >
>


From: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
To: ian link <ian(at)ilink(dot)io>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-01 08:23:13
Message-ID: CAEcSYXLXM7bUqyxKMwdf5wciZGiNmc_HZ1TLT-mST3KKvRGnHQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I'm not really bought into some of the ideas.

but maybe some interactive mode should be usefull - so after
>> execution, and showing result, will be prompt if result should be
>> saved or not.
>
> I like the idea, in addition to the ordinary mode. Personally, I would use
> the ordinary mode, but I can see how 'interactive' would be useful.
>
>
This would require a complex change to the client code. And the result
would eventually become annoying: an interactive question after each and
every query. Currently, when turned on, every result is stored and simple
notification is printed.

> yes, the names :ans01, :ans02, ... miss semantics - How I can join
>
> this name (and content) with some SQL query?
>
> That makes sense. I think having part of / the whole query string would be
> very helpful. Great suggestion!
>
>

The naming is obscure and non-informative, I agree. If you have a nice idea
how to make it better, I'd love to discuss it. But please remember that it
has one huge advantage: simplicity. The client is a classical command-line
tool, and as such it delegates some of the functionality to external
programs, like pager or terminal.

I'm pretty sure that your terminal emulator has a 'find' function that
would allow you to quickly locate the variable and associated query in the
scrollback.

M


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
Cc: ian link <ian(at)ilink(dot)io>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-01 08:31:28
Message-ID: CAFj8pRA8UykuYW4uPBqvYiSkNzewx3=o8FM-RJTLhmTrf5NPyw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2013/7/1 Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>:
> I'm not really bought into some of the ideas.
>
>
>>> but maybe some interactive mode should be usefull - so after
>>> execution, and showing result, will be prompt if result should be
>>> saved or not.
>>
>> I like the idea, in addition to the ordinary mode. Personally, I would use
>> the ordinary mode, but I can see how 'interactive' would be useful.
>>
>
> This would require a complex change to the client code. And the result would
> eventually become annoying: an interactive question after each and every
> query. Currently, when turned on, every result is stored and simple
> notification is printed.
>
.
When I tested this feature, I had 30 caches per 5 minutes, and only a
few from these queries had a sense. Switch between off and on is not
user friendly. I believe so there can be other solution than mine, but
a possibility to friendly clean unwanted caches is necessary.

>
>>>
>>> yes, the names :ans01, :ans02, ... miss semantics - How I can join
>>>
>>> this name (and content) with some SQL query?
>>
>> That makes sense. I think having part of / the whole query string would be
>> very helpful. Great suggestion!
>>
>
>
> The naming is obscure and non-informative, I agree. If you have a nice idea
> how to make it better, I'd love to discuss it. But please remember that it
> has one huge advantage: simplicity. The client is a classical command-line
> tool, and as such it delegates some of the functionality to external
> programs, like pager or terminal.
>

Personally, I don't see a strong price for all users without friendly
interface.

Regards

Pavel

> I'm pretty sure that your terminal emulator has a 'find' function that would
> allow you to quickly locate the variable and associated query in the
> scrollback.
>
> M
>


From: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-01 11:01:01
Message-ID: CAEcSYXLiRbWCO_sycJrpoc_T2oRO5QH65G7n8Jfv30TFZAYiTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> When I tested this feature, I had 30 caches per 5 minutes, and only a
> few from these queries had a sense. Switch between off and on is not
> user friendly. I believe so there can be other solution than mine, but
> a possibility to friendly clean unwanted caches is necessary.

If you know that you'll need the result of a query beforehand, you can
always use SELECT ... INTO ... . No client-side features required.

This feature is intended for people running plenty of ad-hoc queries, when
every result could potentially be useful.


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-01 11:05:13
Message-ID: CAFj8pRBh0dMZaJjHrYbrTKyggJa3KfuWCYHjbLVULp2=OOvxrA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2013/7/1 Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>:
>
>> When I tested this feature, I had 30 caches per 5 minutes, and only a
>> few from these queries had a sense. Switch between off and on is not
>> user friendly. I believe so there can be other solution than mine, but
>> a possibility to friendly clean unwanted caches is necessary.
>
>
> If you know that you'll need the result of a query beforehand, you can
> always use SELECT ... INTO ... . No client-side features required.
>
> This feature is intended for people running plenty of ad-hoc queries, when
> every result could potentially be useful.
>

a idea is good, but I don't think, it can be useful with current
implementation. How I can identify, what is correct answer for my
query? Have I remember twenty numbers and twenty queries?

Regards

Pavel


From: Ian Link <ian(at)ilink(dot)io>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-02 07:42:29
Message-ID: 51D28465.6030901@ilink.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Maciej - I can see your resistance to some kind of interactive mode. It
would definitely be more code and create a less simple user interface. I
would be perfectly happy if we left that part as it is now.

However, I think it would be important to have a way of displaying the
query history. Yes, you can search through your console backwards. You
can still search through your old queries, but this would be a good
alternative. What if the user reconnects after working for a while?
Their old bash history might be gone. This would leave them with a big
query history and no point of reference. Personally, I would find this
feature very worthwhile. The query history wouldn't be crippled without
it, but it would be a lot less flexible.

> Pavel Stehule <mailto:pavel(dot)stehule(at)gmail(dot)com>
> Monday, July 01, 2013 4:05 AM
>
> a idea is good, but I don't think, it can be useful with current
> implementation. How I can identify, what is correct answer for my
> query? Have I remember twenty numbers and twenty queries?
>
> Regards
>
> Pavel
>
>
> Maciej Gajewski <mailto:maciej(dot)gajewski0(at)gmail(dot)com>
> Monday, July 01, 2013 4:01 AM
>
> When I tested this feature, I had 30 caches per 5 minutes, and only a
> few from these queries had a sense. Switch between off and on is not
> user friendly. I believe so there can be other solution than mine, but
> a possibility to friendly clean unwanted caches is necessary.
>
>
> If you know that you'll need the result of a query beforehand, you
> can always use SELECT ... INTO ... . No client-side features required.
>
> This feature is intended for people running plenty of ad-hoc queries,
> when every result could potentially be useful.
>
> Pavel Stehule <mailto:pavel(dot)stehule(at)gmail(dot)com>
> Monday, July 01, 2013 1:31 AM
> 2013/7/1 Maciej Gajewski<maciej(dot)gajewski0(at)gmail(dot)com>:
>> I'm not really bought into some of the ideas.
>>
>>
>>>> but maybe some interactive mode should be usefull - so after
>>>> execution, and showing result, will be prompt if result should be
>>>> saved or not.
>>> I like the idea, in addition to the ordinary mode. Personally, I would use
>>> the ordinary mode, but I can see how 'interactive' would be useful.
>>>
>> This would require a complex change to the client code. And the result would
>> eventually become annoying: an interactive question after each and every
>> query. Currently, when turned on, every result is stored and simple
>> notification is printed.
>>
> .
> When I tested this feature, I had 30 caches per 5 minutes, and only a
> few from these queries had a sense. Switch between off and on is not
> user friendly. I believe so there can be other solution than mine, but
> a possibility to friendly clean unwanted caches is necessary.
>
>>>> yes, the names :ans01, :ans02, ... miss semantics - How I can join
>>>>
>>>> this name (and content) with some SQL query?
>>> That makes sense. I think having part of / the whole query string would be
>>> very helpful. Great suggestion!
>>>
>> The naming is obscure and non-informative, I agree. If you have a nice idea
>> how to make it better, I'd love to discuss it. But please remember that it
>> has one huge advantage: simplicity. The client is a classical command-line
>> tool, and as such it delegates some of the functionality to external
>> programs, like pager or terminal.
>>
>
> Personally, I don't see a strong price for all users without friendly
> interface.
>
> Regards
>
> Pavel
>
>> I'm pretty sure that your terminal emulator has a 'find' function that would
>> allow you to quickly locate the variable and associated query in the
>> scrollback.
>>
>> M
>>
> Maciej Gajewski <mailto:maciej(dot)gajewski0(at)gmail(dot)com>
> Monday, July 01, 2013 1:23 AM
> I'm not really bought into some of the ideas.
>
>
> but maybe some interactive mode should be usefull - so after
> execution, and showing result, will be prompt if result should be
> saved or not.
>
> I like the idea, in addition to the ordinary mode. Personally, I
> would use the ordinary mode, but I can see how 'interactive' would
> be useful.
>
>
> This would require a complex change to the client code. And the result
> would eventually become annoying: an interactive question after each
> and every query. Currently, when turned on, every result is stored and
> simple notification is printed.
>
> yes, the names :ans01, :ans02, ... miss semantics - How I can join
>
> this name (and content) with some SQL query?
>
> That makes sense. I think having part of / the whole query string
> would be very helpful. Great suggestion!
>
>
>
> The naming is obscure and non-informative, I agree. If you have a nice
> idea how to make it better, I'd love to discuss it. But please
> remember that it has one huge advantage: simplicity. The client is a
> classical command-line tool, and as such it delegates some of the
> functionality to external programs, like pager or terminal.
>
> I'm pretty sure that your terminal emulator has a 'find' function that
> would allow you to quickly locate the variable and associated query in
> the scrollback.
>
> M
>
> ian link <mailto:ian(at)ilink(dot)io>
> Monday, July 01, 2013 12:19 AM
>
> but maybe some interactive mode should be usefull - so after
> execution, and showing result, will be prompt if result should be
> saved or not.
>
> I like the idea, in addition to the ordinary mode. Personally, I would
> use the ordinary mode, but I can see how 'interactive' would be useful.
>
> yes, the names :ans01, :ans02, ... miss semantics - How I can join
>
> this name (and content) with some SQL query?
>
> That makes sense. I think having part of / the whole query string
> would be very helpful. Great suggestion!
>
> Maciej, would you be able/have time to implement these? Or do you need
> any help getting them done?
>
>
>
> On Sun, Jun 30, 2013 at 11:35 PM, Pavel Stehule
> <pavel(dot)stehule(at)gmail(dot)com <mailto:pavel(dot)stehule(at)gmail(dot)com>> wrote:
>
> Hello
>
> 2013/7/1 ian link <ian(at)ilink(dot)io <mailto:ian(at)ilink(dot)io>>:
> > Not sure about all of your suggestions. Let me see if I can
> clarify what
> > you're looking for.
> >
> >>
> >> * simply decision if content should be stored in history or not,
> >
> > Do you mean that the user should use a flag to place the result
> of a query
> > into the history?
> > like:
> > --ans SELECT * FROM cities...
> > Not sure if that's what you mean, but it seems kind of
> unnecesary. They can
> > just hit the \ans flag beforehand.
>
> switching off on is not user friendly
>
> but maybe some interactive mode should be usefull - so after
> execution, and showing result, will be prompt if result should be
> saved or not.
>
> some like:
>
> \ans interactive
> > SELECT * FROM pg_proc;
>
> **** result ****
>
> should be saved last result [y, n]?
> > y
> result is saved in :ans22
>
> >
>
>
> >
> >> * simply remove last entry (table) of history
> >
> > That could be useful. What do you think Maciej?
>
> yes, lot of queries is just +/- experiment and you don't would
> store result
>
> >
> >> * queries should be joined to content, only name is not enough
> >
> > Don't know what you mean. Could you try re-wording that?
> >
>
> yes, the names :ans01, :ans02, ... miss semantics - How I can join
> this name (and content) with some SQL query?
>
> I needs to reverese search in SQL of stored caches, and I need a
> information
>
> ans01 SELECT * FROM pg_proc
> ans02 SELECT * FROM ans02 WHERE ...
> ans03 ...
>
> Regards
>
> Pavel
>
> > Ian
> >
> >
> >
> > On Fri, Jun 28, 2013 at 8:49 AM, Pavel Stehule
> <pavel(dot)stehule(at)gmail(dot)com <mailto:pavel(dot)stehule(at)gmail(dot)com>>
> > wrote:
> >>
> >> Hello
> >>
> >> I am not sure, this interface is really user friendly
> >>
> >> there is not possible "searching" in history, and not every
> query push
> >> to history some interesting content.
> >>
> >> It require:
> >>
> >> * simply decision if content should be stored in history or not,
> >> * simply remove last entry (table) of history
> >> * queries should be joined to content, only name is not enough
> >>
> >> Regards
> >>
> >> Pavel
> >>
> >> 2013/6/28 Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com
> <mailto:maciej(dot)gajewski0(at)gmail(dot)com>>:
> >> > Thanks for checking the patch!
> >> >
> >> > So what's left to fix?
> >> > * Moving the escaping-related functions to separate module,
> >> > * applying your corrections.
> >> >
> >> > Did I missed anything?
> >> >
> >> > I'll submit corrected patch after the weekend.
> >> >
> >> > M
> >> >
> >
> >
>
>


From: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
To: Ian Link <ian(at)ilink(dot)io>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-02 09:53:39
Message-ID: CAEcSYXKzUgOTHFj1L0e=n95nY2Mo_ExgseYXFngrgJshwark0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The query history is stored within the client, so once the user stops
the client, it is gone. But yes, it would be useful to have some tool
that would allow you to see what's in there.

I could be a command (\showans ?) that would list all :ansXXX
variables, together with the query text and the size of the answer.
It would probably look ugly for very long queries, but could be useful
anyway.

I'm not sure if I'll be able to implement this feature any time soon,
as I'm very busy at the moment and going for a business trip in few
days.

In the meantime, I've applied your suggestions and moved the
sting-manipulating functions to stringutils. Also fixed a tiny bug.
Patch attached.

M

Attachment Content-Type Size
psql-ans.3.diff application/octet-stream 16.9 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>
Cc: Ian Link <ian(at)ilink(dot)io>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-02 12:36:59
Message-ID: 51D2C96B.8010508@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 7/2/13 5:53 AM, Maciej Gajewski wrote:
> In the meantime, I've applied your suggestions and moved the
> sting-manipulating functions to stringutils. Also fixed a tiny bug.
> Patch attached.

I haven't been able to find any real documentation on this feature,
other than the additions to the psql help. Could someone write some
mock documentation at least, so we know what the proposed interfaces and
intended ways of use are?

What is "ans"?


From: ian link <ian(at)ilink(dot)io>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-03 00:16:18
Message-ID: CAOOwM5LZ_69m2pHViyKJ0A9+g395oAJeUzAmF2hHSbKqfTiXdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>
> I haven't been able to find any real documentation on this feature,
> other than the additions to the psql help.

You're right, I missed that in my review. I agree that it needs some more
documentation.

What is "ans"?

We covered that earlier in the email thread, but it's the current name for
the query history. I think we are going to change it to something a little
more descriptive. I was thinking "qh" for short or "query-history".

I'm not sure if I'll be able to implement this feature any time soon,
> as I'm very busy at the moment and going for a business trip in few
> days.

I can try implementing the feature, I might have some time.

On Tue, Jul 2, 2013 at 5:36 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> On 7/2/13 5:53 AM, Maciej Gajewski wrote:
> > In the meantime, I've applied your suggestions and moved the
> > sting-manipulating functions to stringutils. Also fixed a tiny bug.
> > Patch attached.
>
> I haven't been able to find any real documentation on this feature,
> other than the additions to the psql help. Could someone write some
> mock documentation at least, so we know what the proposed interfaces and
> intended ways of use are?
>
> What is "ans"?
>
>


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: ian link <ian(at)ilink(dot)io>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-03 01:16:05
Message-ID: CA+TgmoYU9z3CR2Ffsg14BxiQ1SQ5UhDyrpLFhejFNyMHk04Wuw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Jul 2, 2013 at 8:16 PM, ian link <ian(at)ilink(dot)io> wrote:
> We covered that earlier in the email thread, but it's the current name for
> the query history. I think we are going to change it to something a little
> more descriptive. I was thinking "qh" for short or "query-history".
>
>> I'm not sure if I'll be able to implement this feature any time soon,
>> as I'm very busy at the moment and going for a business trip in few
>> days.
>
> I can try implementing the feature, I might have some time.

I'm kinda not all that convinced that this feature does anything
that's actually useful. If you want to save your query results, you
can just stick "CREATE TEMP TABLE ans AS" in front of your query.
What does that not give you that this gives you?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: ian link <ian(at)ilink(dot)io>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-03 01:43:39
Message-ID: CAOOwM5+37pRWXr2j_sAq7HLhJ20T5805O_9+0z5t8prp0m2KgA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>
> I'm kinda not all that convinced that this feature does anything
> that's actually useful. If you want to save your query results, you
> can just stick "CREATE TEMP TABLE ans AS" in front of your query.
> What does that not give you that this gives you?

Convenience. It auto-increments with each new query, giving you a different
temporary table for each query. Seems pretty helpful to me.

On Tue, Jul 2, 2013 at 6:16 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Tue, Jul 2, 2013 at 8:16 PM, ian link <ian(at)ilink(dot)io> wrote:
> > We covered that earlier in the email thread, but it's the current name
> for
> > the query history. I think we are going to change it to something a
> little
> > more descriptive. I was thinking "qh" for short or "query-history".
> >
> >> I'm not sure if I'll be able to implement this feature any time soon,
> >> as I'm very busy at the moment and going for a business trip in few
> >> days.
> >
> > I can try implementing the feature, I might have some time.
>
> I'm kinda not all that convinced that this feature does anything
> that's actually useful. If you want to save your query results, you
> can just stick "CREATE TEMP TABLE ans AS" in front of your query.
> What does that not give you that this gives you?
>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: ian link <ian(at)ilink(dot)io>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-03 04:13:31
Message-ID: CAFj8pRBthEcYzZmEEaYHQOZ+cpdE96=D1gy-7HPkQnJEjvB=PA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2013/7/3 Robert Haas <robertmhaas(at)gmail(dot)com>:
> On Tue, Jul 2, 2013 at 8:16 PM, ian link <ian(at)ilink(dot)io> wrote:
>> We covered that earlier in the email thread, but it's the current name for
>> the query history. I think we are going to change it to something a little
>> more descriptive. I was thinking "qh" for short or "query-history".
>>
>>> I'm not sure if I'll be able to implement this feature any time soon,
>>> as I'm very busy at the moment and going for a business trip in few
>>> days.
>>
>> I can try implementing the feature, I might have some time.
>
> I'm kinda not all that convinced that this feature does anything
> that's actually useful. If you want to save your query results, you
> can just stick "CREATE TEMP TABLE ans AS" in front of your query.
> What does that not give you that this gives you?

it solve lot of chars. I am thinking so idea is interesting.

I can imagine, so it can works similar like our \g statement, but
result will be stored to temp table and immediately showed.

Regards

Pavel

>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: ian link <ian(at)ilink(dot)io>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Maciej Gajewski <maciej(dot)gajewski0(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: query result history in psql
Date: 2013-07-05 20:20:19
Message-ID: 51D72A83.7040201@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 07/02/2013 06:16 PM, Robert Haas wrote:
> I'm kinda not all that convinced that this feature does anything
> that's actually useful. If you want to save your query results, you
> can just stick "CREATE TEMP TABLE ans AS" in front of your query.
> What does that not give you that this gives you?

Convenience. Think of the times when you were doing a "quick check" on
some query result from several different queries and wanted to flip back
and forth between them, but you can't do that by scrolling because the
pager has the query result and hides it from terminal scrolling. If we
had this feature, I'd use it a lot, personally.

My take on the issues discussed:

Interactive Mode: I personally don't see value in this, and wouldn't use
it if it existed. Plus even if there is value in it, it could be added
later on, so shouldn't block this patch.

Finding Query Results: I don't find the approach of "ans01/ans02/ans03"
useful. For any place where I really need this feature, I'm going to
have enough buffered queries that there's no way I can remember which is
which. I don't, however, have an immediate solution for something which
would be overall easier. Maybe a prompt after each query for what name
to put it in the history as? Not sure.

"ans": I agree that this is not intuitive for most DBAs. The other
applications which use that abbreviation do not have sufficient overlap
with PostgreSQL for it to be natural. What about just "result"?

Size Limits: before this becomes a PostgreSQL feature, we really do need
to have some limits, both for total memory size, and for number of saved
query result sets. Otherwise we'll have lots of people crashing their
clients because they forgot that result history was on.

Also, I'd like to think some about how this could, potentially, in the
future tie in to being able to dispatch asyncronous queries from psql.
If we have a query result cache, it's one short step to allowing that
result cache to be populated asyncrhonously.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com