[PATCH] Add missing \ddp psql command

Started by David Christensenover 10 years ago6 messages
#1David Christensen
david@endpoint.com
1 attachment(s)

Quickie patch for spotted missing psql \ddp tab-completion.

Attachments:

0001-Add-missing-ddp-psql-tab-completion.patchapplication/octet-stream; name=0001-Add-missing-ddp-psql-tab-completion.patchDownload
>From adc84de48a549039c888aebc18465c9080a80d2f Mon Sep 17 00:00:00 2001
From: David Christensen <david@endpoint.com>
Date: Mon, 6 Jul 2015 12:09:40 -0500
Subject: [PATCH] Add missing \ddp psql tab completion

---
 src/bin/psql/tab-complete.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 8a0bb78..c7ff58a 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -897,7 +897,7 @@ 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", "\\ddp", "\\dD", "\\des", "\\det", "\\deu", "\\dew", "\\df",
 		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
 		"\\dn", "\\do", "\\dp", "\\drds", "\\ds", "\\dS", "\\dt", "\\dT", "\\dv", "\\du", "\\dx",
 		"\\e", "\\echo", "\\ef", "\\encoding", "\\ev",
-- 
2.3.5

#2Fujii Masao
masao.fujii@gmail.com
In reply to: David Christensen (#1)
1 attachment(s)
Re: [PATCH] Add missing \ddp psql command

On Tue, Jul 7, 2015 at 2:11 AM, David Christensen <david@endpoint.com> wrote:

Quickie patch for spotted missing psql \ddp tab-completion.

Thanks for the report and patch!

I found that tab-completion was not supported in not only \ddp
but also other psql meta commands like \dE, \dm, \dO, \dy, \s and
\setenv. Attached patch adds all those missing tab-completions.

Thought?

Regards,

--
Fujii Masao

Attachments:

add_missing_tab_completions_fujii.patchtext/x-patch; charset=US-ASCII; name=add_missing_tab_completions_fujii.patchDownload
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 897,910 **** 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",
  		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
! 		"\\dn", "\\do", "\\dp", "\\drds", "\\ds", "\\dS", "\\dt", "\\dT", "\\dv", "\\du", "\\dx",
  		"\\e", "\\echo", "\\ef", "\\encoding", "\\ev",
  		"\\f", "\\g", "\\gset", "\\h", "\\help", "\\H", "\\i", "\\ir", "\\l",
  		"\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",
  		"\\o", "\\p", "\\password", "\\prompt", "\\pset", "\\q", "\\qecho", "\\r",
! 		"\\set", "\\sf", "\\sv", "\\t", "\\T",
  		"\\timing", "\\unset", "\\x", "\\w", "\\watch", "\\z", "\\!", NULL
  	};
  
--- 897,912 ----
  
  	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",
  		"\\dF", "\\dFd", "\\dFp", "\\dFt", "\\dg", "\\di", "\\dl", "\\dL",
! 		"\\dm", "\\dn", "\\do", "\\dO", "\\dp", "\\drds", "\\ds", "\\dS",
! 		"\\dt", "\\dT", "\\dv", "\\du", "\\dx", "\\dy",
  		"\\e", "\\echo", "\\ef", "\\encoding", "\\ev",
  		"\\f", "\\g", "\\gset", "\\h", "\\help", "\\H", "\\i", "\\ir", "\\l",
  		"\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink",
  		"\\o", "\\p", "\\password", "\\prompt", "\\pset", "\\q", "\\qecho", "\\r",
! 		"\\s", "\\set", "\\setenv", "\\sf", "\\sv", "\\t", "\\T",
  		"\\timing", "\\unset", "\\x", "\\w", "\\watch", "\\z", "\\!", NULL
  	};
  
***************
*** 3791,3796 **** psql_completion(const char *text, int start, int end)
--- 3793,3802 ----
  		COMPLETE_WITH_QUERY(Query_for_list_of_extensions);
  	else if (strncmp(prev_wd, "\\dm", strlen("\\dm")) == 0)
  		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
+ 	else if (strncmp(prev_wd, "\\dE", strlen("\\dE")) == 0)
+ 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_foreign_tables, NULL);
+ 	else if (strncmp(prev_wd, "\\dy", strlen("\\dy")) == 0)
+ 		COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers);
  
  	/* must be at end of \d list */
  	else if (strncmp(prev_wd, "\\d", strlen("\\d")) == 0)
#3David Christensen
david@endpoint.com
In reply to: Fujii Masao (#2)
Re: [PATCH] Add missing \ddp psql command

On Jul 7, 2015, at 3:53 AM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Tue, Jul 7, 2015 at 2:11 AM, David Christensen <david@endpoint.com> wrote:

Quickie patch for spotted missing psql \ddp tab-completion.

Thanks for the report and patch!

I found that tab-completion was not supported in not only \ddp
but also other psql meta commands like \dE, \dm, \dO, \dy, \s and
\setenv. Attached patch adds all those missing tab-completions.

From a completeness standpoint makes sense to me to have all of them, but from a practical standpoint a single-character completion like \s isn’t going to do much. :)

David
--
David Christensen
PostgreSQL Team Manager
End Point Corporation
david@endpoint.com
785-727-1171

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

#4Fujii Masao
masao.fujii@gmail.com
In reply to: David Christensen (#3)
Re: [PATCH] Add missing \ddp psql command

On Tue, Jul 7, 2015 at 10:44 PM, David Christensen <david@endpoint.com> wrote:

On Jul 7, 2015, at 3:53 AM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Tue, Jul 7, 2015 at 2:11 AM, David Christensen <david@endpoint.com> wrote:

Quickie patch for spotted missing psql \ddp tab-completion.

Thanks for the report and patch!

I found that tab-completion was not supported in not only \ddp
but also other psql meta commands like \dE, \dm, \dO, \dy, \s and
\setenv. Attached patch adds all those missing tab-completions.

From a completeness standpoint makes sense to me to have all of them, but from a practical standpoint a single-character completion like \s isn’t going to do much. :)

Sometimes I type TAB after \ to display all the psql meta commands.
Even single-character completion like \s may be useful for that case.
Yeah, I agree that's narrow use case, though.

Regards,

--
Fujii Masao

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

#5Fujii Masao
masao.fujii@gmail.com
In reply to: Fujii Masao (#4)
Re: [PATCH] Add missing \ddp psql command

On Tue, Jul 7, 2015 at 11:08 PM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Tue, Jul 7, 2015 at 10:44 PM, David Christensen <david@endpoint.com> wrote:

On Jul 7, 2015, at 3:53 AM, Fujii Masao <masao.fujii@gmail.com> wrote:

On Tue, Jul 7, 2015 at 2:11 AM, David Christensen <david@endpoint.com> wrote:

Quickie patch for spotted missing psql \ddp tab-completion.

Thanks for the report and patch!

I found that tab-completion was not supported in not only \ddp
but also other psql meta commands like \dE, \dm, \dO, \dy, \s and
\setenv. Attached patch adds all those missing tab-completions.

Pushed.

Regards,

--
Fujii Masao

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

#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Fujii Masao (#4)
Re: [PATCH] Add missing \ddp psql command

Fujii Masao wrote:

Sometimes I type TAB after \ to display all the psql meta commands.
Even single-character completion like \s may be useful for that case.
Yeah, I agree that's narrow use case, though.

I agree that that's useful, so thanks for having pushed it.

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

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