Re: proposal: alternative psql commands quit and exit

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: 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-16 17:17:50
Message-ID: CA+TgmoZV74dNVxQGPFsOsi44dsqQLtOcPKcPJvPHwAiEKFuYdw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 15, 2018 at 11:55 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Right, but if we're willing to look at the parse state, we don't need
> to cram all possible knowledge into one 80-character string. I'm
> thinking about just responding to the current situation, say
>
> You have begun a quoted string. To end it, type '
>
> (or ", or $foo$ as appropriate). I'm inclined to violate our usual
> message style guidelines here by not putting any quotes or punctuation
> around the ending quote ... more likely to confuse than help.
>
> Or, if you're not in a string but there's text in the buffer,
>
> You have entered an incomplete SQL command.
> Type ; to send it or \r to discard it.
>
> Or, if there's no text in the buffer, we print the existing help
> message for "help", or just exit for quit/exit.

This gets a little complex; you need to note only the parser state but
also, in the case of dollar-quoting, what appeared between the two
dollar signs when the dollar quotes were opened. Plus, it's quite
possible that there are multiple levels of quoting open; I'm not sure
I want to print a message like:

You have begun a quoted string, To end it, type $$too$$'$$complicated$$

The other problem with this sort of thing is that it gives the user no
hint as to why the message got generated. The messages in the patch I
sent before were:

Use \? for help or press control-C to clear the input buffer.
Use \q to quit or press control-C to clear the input buffer.

If the user does a cut-and-paste of a bunch of text and gets one of
those messages, it doesn't explicitly spell out what triggered the
message, but it hints at it. With your proposed message, someone
might reply "I know I have begun a quoted string. Why are you telling
me about it?".

I also think that pressing control-C to clear the input buffer, rather
than trying to close out the quotes or the SQL command, is likely to
be what most people want to do in this situation. Generally, by the
time you resort to typing "quit" or "help" into a program and hoping
something good happens, it's a good bet that whatever came before that
point wasn't anything great. But I don't know what to do about the
revelation that my trusty standby control-C isn't universally the
right thing either.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2018-01-16 17:20:31 Re: proposal: alternative psql commands quit and exit
Previous Message Simon Riggs 2018-01-16 17:16:44 Re: [HACKERS] Replication status in logical replication