Re: proposal: alternative psql commands quit and exit

From: KAWAMICHI Ryoji <kawamichi(at)tkl(dot)iis(dot)u-tokyo(dot)ac(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
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>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-24 09:17:02
Message-ID: 652594193.5891867.1516785422410.JavaMail.zimbra@tkl.iis.u-tokyo.ac.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-01-24 09:30:39 Re: [HACKERS] proposal - Default namespaces for XPath expressions (PostgreSQL 11)
Previous Message Daniel Gustafsson 2018-01-24 08:47:50 Re: [HACKERS] Refactoring identifier checks to consistently use strcmp