A bug of psql completion

Started by Kyotaro HORIGUCHIabout 9 years ago3 messages
#1Kyotaro HORIGUCHI
horiguchi.kyotaro@lab.ntt.co.jp
1 attachment(s)

Hello.

I noticed that the psql completion code for "ALTER TABLE x ALTER
[COLUMN] x DROP" is wrong. It works as the following

=# alter table x alter x drop <tab>
[nothing suggested]
=# alter table x table x alter x drop <tab>
DEFAULT NOT NULL

The attached patch fixes it.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachments:

psqlcomp_alter_column_drop_fix.patchtext/x-patch; charset=us-asciiDownload
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index b556c00..6aa3f20 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1804,7 +1804,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_LIST4("PLAIN", "EXTERNAL", "EXTENDED", "MAIN");
 	/* ALTER TABLE ALTER [COLUMN] <foo> DROP */
 	else if (Matches7("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "DROP") ||
-			 Matches8("ALTER", "TABLE", MatchAny, "TABLE", MatchAny, "ALTER", MatchAny, "DROP"))
+			 Matches6("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "DROP"))
 		COMPLETE_WITH_LIST2("DEFAULT", "NOT NULL");
 	else if (Matches4("ALTER", "TABLE", MatchAny, "CLUSTER"))
 		COMPLETE_WITH_CONST("ON");
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Kyotaro HORIGUCHI (#1)
Re: A bug of psql completion

Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> writes:

I noticed that the psql completion code for "ALTER TABLE x ALTER
[COLUMN] x DROP" is wrong. It works as the following

=# alter table x alter x drop <tab>
[nothing suggested]
=# alter table x table x alter x drop <tab>
DEFAULT NOT NULL

The attached patch fixes it.

Pushed, thanks.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Kyotaro HORIGUCHI
horiguchi.kyotaro@lab.ntt.co.jp
In reply to: Tom Lane (#2)
Re: A bug of psql completion

At Mon, 28 Nov 2016 11:52:07 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote in <4624.1480351927@sss.pgh.pa.us>
tgl> Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> writes:
tgl> > I noticed that the psql completion code for "ALTER TABLE x ALTER
tgl> > [COLUMN] x DROP" is wrong. It works as the following
...
tgl> > The attached patch fixes it.
tgl>
tgl> Pushed, thanks.

Thanks for committing.

--
Kyotaro Horiguchi
NTT Open Source Software Center

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers