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-25 20:46:30 |
Message-ID: | 20180125204630.GA27619@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jan 15, 2018 at 11:10:44AM -0500, Robert Haas wrote:
> On Mon, Jan 15, 2018 at 10:57 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> >> I've discovered one thing about this design that is not so good, which
> >> is that if you open a single, double, or dollar quote, then the
> >> instructions that are provided under that design do not work:
> >
> > I was kind of imagining that we could make the hint text vary depending
> > on the parsing state. Maybe that's too hard to get to --- but if the
> > prompt-creating code knows what it is, perhaps this can too.
>
> 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.
--
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 +
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2018-01-25 20:52:57 | Re: [HACKERS] Patch: Add --no-comments to skip COMMENTs with pg_dump |
Previous Message | Alvaro Herrera | 2018-01-25 20:45:00 | Re: [HACKERS] Patch: Add --no-comments to skip COMMENTs with pg_dump |