Re: proposal: alternative psql commands quit and exit

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: proposal: alternative psql commands quit and exit
Дата
Msg-id 20180125204630.GA27619@momjian.us
обсуждение исходный текст
Ответ на Re: proposal: alternative psql commands quit and exit  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: proposal: alternative psql commands quit and exit
Список 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@sss.pgh.pa.us> wrote:
> > Robert Haas <robertmhaas@gmail.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@momjian.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 +


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [HACKERS] Patch: Add --no-comments to skip COMMENTs with pg_dump
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: [HACKERS] Patch: Add --no-comments to skip COMMENTs with pg_dump