[patch] psql tab completion for grant execute
Hi,
When tab-completing after GRANT EXECUTE, currently psql injects
"PROCEDURE", rather than the expected "ON".
The code for completing with "ON" is there, but it's not reached due to
falling earlier into another branch, one that handles CREATE TRIGGER.
A trivial patch is attached. It adds the condition that if EXECUTE is
preceded by GRANT itself preceded by nothing, then that completion
with PROCEDURE is skipped.
I've looked at fixing it more directly, by testing if the EXECUTE
is part of a CREATE TRIGGER, but it didn't seem fitting to go
looking backwards that many words into the string (more
than the 5 words suggested by the rest of the code).
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite
Attachments:
patch-psql-complete-grant.difftext/x-patch; name=patch-psql-complete-grant.diffDownload
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 62cb721..816deda 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2622,6 +2622,7 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views, NULL);
/* complete CREATE TRIGGER ... EXECUTE with PROCEDURE */
else if (pg_strcasecmp(prev_wd, "EXECUTE") == 0 &&
+ !(pg_strcasecmp(prev2_wd, "GRANT") == 0 && prev3_wd[0] == '\0') &&
prev2_wd[0] != '\0')
COMPLETE_WITH_CONST("PROCEDURE");
On Tue, Aug 18, 2015 at 6:07 AM, Daniel Verite <daniel@manitou-mail.org> wrote:
Hi,
When tab-completing after GRANT EXECUTE, currently psql injects
"PROCEDURE", rather than the expected "ON".The code for completing with "ON" is there, but it's not reached due to
falling earlier into another branch, one that handles CREATE TRIGGER.A trivial patch is attached. It adds the condition that if EXECUTE is
preceded by GRANT itself preceded by nothing, then that completion
with PROCEDURE is skipped.I've looked at fixing it more directly, by testing if the EXECUTE
is part of a CREATE TRIGGER, but it didn't seem fitting to go
looking backwards that many words into the string (more
than the 5 words suggested by the rest of the code).
You should consider adding it to the next CF:
https://commitfest.postgresql.org/6/
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Mon, Aug 17, 2015 at 5:07 PM, Daniel Verite <daniel@manitou-mail.org> wrote:
When tab-completing after GRANT EXECUTE, currently psql injects
"PROCEDURE", rather than the expected "ON".The code for completing with "ON" is there, but it's not reached due to
falling earlier into another branch, one that handles CREATE TRIGGER.A trivial patch is attached. It adds the condition that if EXECUTE is
preceded by GRANT itself preceded by nothing, then that completion
with PROCEDURE is skipped.
Thanks, I committed this. I don't think we usually back-patch tab
completion fixes, but I back-patched this one to 9.5 anyway, so that
it gets out into the wild a little sooner.
--
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
Robert Haas wrote:
A trivial patch is attached. It adds the condition that if EXECUTE is
preceded by GRANT itself preceded by nothing, then that completion
with PROCEDURE is skipped.Thanks, I committed this. I don't think we usually back-patch tab
completion fixes, but I back-patched this one to 9.5 anyway, so that
it gets out into the wild a little sooner.
Thanks! I had added it in the CF earlier, I've taken the liberty to mark
it as committed by you:
https://commitfest.postgresql.org/6/329/
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers