psql tab completion: \c [ dbname [ username ] ]

Started by Ian Barwickabout 11 years ago3 messages
#1Ian Barwick
ian@2ndquadrant.com
1 attachment(s)

Hi

Attached is a mighty trivial patch to extend psql tab completion
for \c / \connect to generate a list of role names, as lack thereof
was annoying me recently and I can't see any downside to doing
this.

The patch is a whole two lines so I haven't submitted it to the next
commitfest but will happily do so if appropriate.

Regards

Ian Barwick

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

Attachments:

psql-slash-c-user.patchtext/plain; charset=UTF-8; name=psql-slash-c-user.patch; x-mac-creator=0; x-mac-type=0Download
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
new file mode 100644
index 886188c..56dc688
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
*************** psql_completion(const char *text, int st
*** 3704,3709 ****
--- 3704,3711 ----
  	}
  	else if (strcmp(prev_wd, "\\connect") == 0 || strcmp(prev_wd, "\\c") == 0)
  		COMPLETE_WITH_QUERY(Query_for_list_of_databases);
+ 	else if (strcmp(prev2_wd, "\\connect") == 0 || strcmp(prev2_wd, "\\c") == 0)
+ 		COMPLETE_WITH_QUERY(Query_for_list_of_roles);
  
  	else if (strncmp(prev_wd, "\\da", strlen("\\da")) == 0)
  		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_aggregates, NULL);
#2Robert Haas
robertmhaas@gmail.com
In reply to: Ian Barwick (#1)
Re: psql tab completion: \c [ dbname [ username ] ]

On Sun, Nov 9, 2014 at 6:13 PM, Ian Barwick <ian@2ndquadrant.com> wrote:

Attached is a mighty trivial patch to extend psql tab completion
for \c / \connect to generate a list of role names, as lack thereof
was annoying me recently and I can't see any downside to doing
this.

Committed, thanks.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

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

#3Ian Barwick
ian@2ndquadrant.com
In reply to: Robert Haas (#2)
Re: psql tab completion: \c [ dbname [ username ] ]

On 10/11/14 22:20, Robert Haas wrote:

On Sun, Nov 9, 2014 at 6:13 PM, Ian Barwick <ian@2ndquadrant.com> wrote:

Attached is a mighty trivial patch to extend psql tab completion
for \c / \connect to generate a list of role names, as lack thereof
was annoying me recently and I can't see any downside to doing
this.

Committed, thanks.

Many thanks!

Regards

Ian Barwick

--
Ian Barwick http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, 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