On Mon, Jan 15, 2018 at 11:55 AM, Tom Lane <t...@sss.pgh.pa.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

Reply via email to