[PATCH] psql: add tab completion for \df slash command suffixes

Started by Ian Barwickover 6 years ago4 messages
#1Ian Barwick
ian.barwick@2ndquadrant.com
3 attachment(s)

Hi

I just noticed "\df[TAB]" fails to offer any tab-completion for
the possible suffixes ("\dfa", "\dfn", "\dfp", "\dft" and "\dfw").
Trivial patch attached, which applies back to Pg96, and separate
patches for Pg95 and Pg94.

I'll add this to the next commitfest.

Regards

Ian Barwick

--
Ian Barwick https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachments:

psql-df-tab-completion.v1.patchtext/x-patch; name=psql-df-tab-completion.v1.patchDownload
commit 41a4ca2f70a1ea3bf0deb17ad54a14446de0a300
Author: Ian Barwick <ian@2ndquadrant.com>
Date:   Fri Aug 30 13:30:47 2019 +0900

    psql: add tab completion for \df slash commands
    
    "\df" itself was listed for tab completion, but none of the
    possible suffixes were.

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index bcc7404c55..bc8a7bd78b 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1418,7 +1418,8 @@ psql_completion(const char *text, int start, int end)
 		"\\connect", "\\conninfo", "\\C", "\\cd", "\\copy",
 		"\\copyright", "\\crosstabview",
 		"\\d", "\\da", "\\dA", "\\db", "\\dc", "\\dC", "\\dd", "\\ddp", "\\dD",
-		"\\des", "\\det", "\\deu", "\\dew", "\\dE", "\\df",
+		"\\des", "\\det", "\\deu", "\\dew", "\\dE",
+		"\\df", "\\dfa", "\\dfn", "\\dfp", "\\dft", "\\dfw",
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\dP", "\\dPi", "\\dPt",
 		"\\drds", "\\dRs", "\\dRp", "\\ds", "\\dS",
psql-df-tab-completion-pg94.v1.patchtext/x-patch; name=psql-df-tab-completion-pg94.v1.patchDownload
commit 616745c6c2c1f96446cebed7dbadd6f6307c7817
Author: Ian Barwick <ian@2ndquadrant.com>
Date:   Fri Aug 30 13:45:24 2019 +0900

    psql: add tab completion for \df slash commands
    
    "\df" itself was listed for tab completion, but none of the
    possible suffixes were.

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index d6988f2654..9c8a18ab48 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -870,7 +870,8 @@ psql_completion(const char *text, int start, int end)
 
 	static const char *const backslash_commands[] = {
 		"\\a", "\\connect", "\\conninfo", "\\C", "\\cd", "\\copy", "\\copyright",
-		"\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\des", "\\det", "\\deu", "\\dew", "\\df",
+		"\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\des", "\\det", "\\deu", "\\dew",
+		"\\df", "\\dfa", "\\dfn", "\\dfp", "\\dft", "\\dfw",
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dn", "\\do", "\\dp", "\\drds", "\\ds", "\\dS", "\\dt", "\\dT", "\\dv", "\\du", "\\dx",
 		"\\e", "\\echo", "\\ef", "\\encoding",
psql-df-tab-completion-pg95.v1.patchtext/x-patch; name=psql-df-tab-completion-pg95.v1.patchDownload
commit 8ed98bb4cad91c71f0a04c28428c1e4cd862d938
Author: Ian Barwick <ian@2ndquadrant.com>
Date:   Fri Aug 30 13:41:09 2019 +0900

    psql: add tab completion for \df slash commands
    
    "\df" itself was listed for tab completion, but none of the
    possible suffixes were.

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index b657ab7b8d..784e2a6bad 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -913,7 +913,8 @@ psql_completion(const char *text, int start, int end)
 	static const char *const backslash_commands[] = {
 		"\\a", "\\connect", "\\conninfo", "\\C", "\\cd", "\\copy", "\\copyright",
 		"\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\ddp", "\\dD",
-		"\\des", "\\det", "\\deu", "\\dew", "\\dE", "\\df",
+		"\\des", "\\det", "\\deu", "\\dew", "\\dE",
+		"\\df", "\\dfa", "\\dfn", "\\dfp", "\\dft", "\\dfw",
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\drds", "\\ds", "\\dS",
 		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dy",
#2Kuntal Ghosh
kuntalghosh.2007@gmail.com
In reply to: Ian Barwick (#1)
Re: [PATCH] psql: add tab completion for \df slash command suffixes

Hello Ian,

On Fri, Aug 30, 2019 at 10:31 AM Ian Barwick
<ian.barwick@2ndquadrant.com> wrote:

I just noticed "\df[TAB]" fails to offer any tab-completion for
the possible suffixes ("\dfa", "\dfn", "\dfp", "\dft" and "\dfw").
Trivial patch attached, which applies back to Pg96, and separate
patches for Pg95 and Pg94.

I'll add this to the next commitfest.

I've reviewed the patch. It works as expected in master. But, the
syntax "\dfp" doesn't exist beyond Pg11. So, you've to remove the same
from the patches for Pg95 and Pg94. I guess the same patch should be
applied on Pg10 and Pg96.

--
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com

#3Ian Barwick
ian.barwick@2ndquadrant.com
In reply to: Kuntal Ghosh (#2)
Re: [PATCH] psql: add tab completion for \df slash command suffixes

On 2019/09/04 15:14, Kuntal Ghosh wrote:

Hello Ian,

On Fri, Aug 30, 2019 at 10:31 AM Ian Barwick
<ian.barwick@2ndquadrant.com> wrote:

I just noticed "\df[TAB]" fails to offer any tab-completion for
the possible suffixes ("\dfa", "\dfn", "\dfp", "\dft" and "\dfw").
Trivial patch attached, which applies back to Pg96, and separate
patches for Pg95 and Pg94.

I'll add this to the next commitfest.

I've reviewed the patch. It works as expected in master. But, the
syntax "\dfp" doesn't exist beyond Pg11. So, you've to remove the same
from the patches for Pg95 and Pg94. I guess the same patch should be
applied on Pg10 and Pg96.

Ah, good catch, I will update and resubmit.

Thanks!

Ian Barwick

--
Ian Barwick https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

#4Michael Paquier
michael@paquier.xyz
In reply to: Ian Barwick (#3)
Re: [PATCH] psql: add tab completion for \df slash command suffixes

On Wed, Sep 04, 2019 at 03:19:57PM +0900, Ian Barwick wrote:

Ah, good catch, I will update and resubmit.

Ping. Ian, could you update and resubmit please?
--
Michael