Hi,
> It's not really that complicated. Here's a patch. This follows what
> Tom suggested in http://postgr.es/m/30157.1513058300@sss.pgh.pa.us and
> what I suggested in
> https://www.postgresql.org/message-id/CA%2BTgmoZswp00PtcgPfQ9zbbh7HUTgsLLJ9Z1x9E2s8Y7ep048g%40mail.gmail.com
>
> 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:
>
> rhaas=# select $$
> rhaas$# quit
> Use \q to quit or press control-C to clear the input buffer.
> rhaas$# \q
> rhaas$# well this sucks
> rhaas$#
>
> Obviously this leaves something to be desired, but I think it's
> probably just a matter of rephrasing the hint somehow. I didn't have
> a good idea off-hand though, so here's the patch as I have it.
I reviewed and checked your patch on master branch, and it seems to work
well. Here are the results:
test=# create table t (quit integer);
CREATE TABLE
test=# insert into t values (1);
INSERT 0 1
test=# select quit from t;
quit
------
1
(1 row)
test=# select
test-# quit
Use \q to quit or press control-C to clear the input buffer.
test-# from t;
quit
------
1
(1 row)
test=# select 'quit' from t;
?column?
----------
quit
(1 row)
test=# select '
test'# quit
Use \q to quit or press control-C to clear the input buffer.
test'# ' from t;
?column?
----------
+
quit +
(1 row)
test=# select $$quit$$ from t;
?column?
----------
quit
(1 row)
test=# select $$
test$# quit
Use \q to quit or press control-C to clear the input buffer.
test$# $$ from t;
?column?
----------
+
quit +
(1 row)
test=# select
test-# \q
bash-4.2$
(psql ended)
test=# select '
test'# \q
test'# ' from t;
?column?
----------
+
\q +
(1 row)
test=# select $$
test$# \q
test$# $$ from t;
?column?
----------
+
\q +
(1 row)
I tried the same test using some commands such as 'exit', 'help' or '\h',
and this patch worked well too. Then this patch passed the 'make check'
regression tests too. So I think it can be committed.
But if you want to modify this patch, I'll check it again.
Thanks.
Ryoji.