Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8140c1b

Browse files
committed
Make psql support tab completion of EXECUTE <prepared-statement-name>.
Andreas Karlsson, reviewed by Josh Kupershmidt
1 parent 7299778 commit 8140c1b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/bin/psql/tab-complete.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,11 @@ static const SchemaQuery Query_for_list_of_views = {
588588
" FROM pg_catalog.pg_available_extensions "\
589589
" WHERE substring(pg_catalog.quote_ident(name),1,%d)='%s' AND installed_version IS NULL"
590590

591+
#define Query_for_list_of_prepared_statements \
592+
" SELECT pg_catalog.quote_ident(name) "\
593+
" FROM pg_catalog.pg_prepared_statements "\
594+
" WHERE substring(pg_catalog.quote_ident(name),1,%d)='%s'"
595+
591596
/*
592597
* This is a list of all "things" in Pgsql, which can show up after CREATE or
593598
* 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)
19081913
pg_strcasecmp(prev_wd, "ON") == 0)
19091914
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views, NULL);
19101915
/* complete CREATE TRIGGER ... EXECUTE with PROCEDURE */
1911-
else if (pg_strcasecmp(prev_wd, "EXECUTE") == 0)
1916+
else if (pg_strcasecmp(prev_wd, "EXECUTE") == 0 &&
1917+
prev2_wd[0] != '\0')
19121918
COMPLETE_WITH_CONST("PROCEDURE");
19131919

19141920
/* CREATE ROLE,USER,GROUP */
@@ -2117,6 +2123,11 @@ psql_completion(char *text, int start, int end)
21172123
COMPLETE_WITH_LIST(list_ALTERTEXTSEARCH);
21182124
}
21192125

2126+
/* EXECUTE, but not EXECUTE embedded in other commands */
2127+
else if (pg_strcasecmp(prev_wd, "EXECUTE") == 0 &&
2128+
prev2_wd[0] == '\0')
2129+
COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);
2130+
21202131
/* EXPLAIN */
21212132

21222133
/*

0 commit comments

Comments
 (0)