summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2011-10-23 23:25:34 +0000
committerTom Lane2011-10-23 23:25:34 +0000
commit8140c1bcf355c4925114cc127de476384053dc96 (patch)
tree607485a645a155a3b05df47e3976f54f1da8b726
parent7299778a958112b0339ab29365ba0d654bd5d21c (diff)
Make psql support tab completion of EXECUTE <prepared-statement-name>.
Andreas Karlsson, reviewed by Josh Kupershmidt
-rw-r--r--src/bin/psql/tab-complete.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index abf9bc7396..aba9b4b5aa 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -588,6 +588,11 @@ static const SchemaQuery Query_for_list_of_views = {
" FROM pg_catalog.pg_available_extensions "\
" WHERE substring(pg_catalog.quote_ident(name),1,%d)='%s' AND installed_version IS NULL"
+#define Query_for_list_of_prepared_statements \
+" SELECT pg_catalog.quote_ident(name) "\
+" FROM pg_catalog.pg_prepared_statements "\
+" WHERE substring(pg_catalog.quote_ident(name),1,%d)='%s'"
+
/*
* This is a list of all "things" in Pgsql, which can show up after CREATE or
* DROP; and there is also a query to get a list of them.
@@ -1908,7 +1913,8 @@ psql_completion(char *text, int start, int end)
pg_strcasecmp(prev_wd, "ON") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views, NULL);
/* complete CREATE TRIGGER ... EXECUTE with PROCEDURE */
- else if (pg_strcasecmp(prev_wd, "EXECUTE") == 0)
+ else if (pg_strcasecmp(prev_wd, "EXECUTE") == 0 &&
+ prev2_wd[0] != '\0')
COMPLETE_WITH_CONST("PROCEDURE");
/* CREATE ROLE,USER,GROUP */
@@ -2117,6 +2123,11 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_LIST(list_ALTERTEXTSEARCH);
}
+/* EXECUTE, but not EXECUTE embedded in other commands */
+ else if (pg_strcasecmp(prev_wd, "EXECUTE") == 0 &&
+ prev2_wd[0] == '\0')
+ COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);
+
/* EXPLAIN */
/*