From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Everaldo Canuto <everaldo(dot)canuto(at)gmail(dot)com>, Chapman Flack <chap(at)anastigmatix(dot)net>, Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: alternative psql commands quit and exit |
Date: | 2018-01-28 23:35:06 |
Message-ID: | 20180128233506.GD5022@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Jan 25, 2018 at 03:46:30PM -0500, Bruce Momjian wrote:
> On Mon, Jan 15, 2018 at 11:10:44AM -0500, Robert Haas wrote:
> > prompt_status does seem to be available in psql's MainLoop(), so I
> > think that could be done, but the problem is that I don't know exactly
> > what message would be useful to print when we're in a "in quotes"
> > state. If I had a good message text for that state, I might just
> > choose to use it always rather than multiplying the number of
> > messages.
> >
> > More broadly, I think what is needed here is less C-fu than
> > English-fu. If we come up with something good, we can make it print
> > that thing.
>
> I just read this thread and have some ideas. First, the reason 'help'
> was added so easily is because it pointed users at getting more
> information, and it required to be the first command in the query
> buffer.
>
> I realize we are now considering allowing 'help', 'quit', and 'exit' to
> appear alone on a line with whitespace before it, and remove the
> requirement that it be the first thing in the query buffer.
>
> I think there are a few things to consider.
>
> First, allowing whitespace to be before the keyword --- do we really
> think that typing <space>exit will more likely be typed by a user trying
> to exit than part of an SQL query? I think requiring no space around
> the keyword would reduce the number of false hints.
>
> Second, I am thinking we can check prompt_status and report "Use \q" if
> we are not in a quoted string, and suggest "Use Control-D then \q" (or
> "Use Control-C then \q" on Windows) and be done with it. By printing
> the Control-D only when we are in a quoted strong, we minimize the
> number of times that we are wrong due to stty changes.
I used Robert's patch and modified it to match the ideas I had above.
Specifically no white space can be before 'help', 'exit' or 'quit' and
prompt_status is used to adjust the suggestion. Here is the visible
behavior:
test=> exit
(exits)
test=> SELECT
test-> exit
--> Use \q to quit.
test-> \q
test=> SELECT '
test'> exit
--> Use control-D to quit.
test'> \q
test=> SELECT "
test"> exit
--> Use control-D to quit.
test"> \q
test=> SELECT /*
test*> exit
--> Use control-D to quit.
test*> \q
test=> SELECT 'asbs' AS
test-> exit
--> Use \q to quit.
test-> \q
test=> SELECT 'asbs' AS
test-> exit
test-> ;
exit
------
asbs
(1 row)
One open issue is the existing help display is inaccurate on Windows:
Use \\? for help or press control-C to clear the input buffer.
Oh, it clears the input buffer alright, _and_ exits psql. This patch
also removes the control-C mention on Windows.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Attachment | Content-Type | Size |
---|---|---|
exit.diff | text/x-diff | 4.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2018-01-28 23:53:10 | Re: [PERFORM] performance drop after upgrade (9.6 > 10) |
Previous Message | Ivan Novick | 2018-01-28 23:11:25 | Re: Built-in connection pooling |