@@ -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)
19081913pg_strcasecmp (prev_wd ,"ON" )== 0 )
19091914COMPLETE_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' )
19121918COMPLETE_WITH_CONST ("PROCEDURE" );
19131919
19141920/* CREATE ROLE,USER,GROUP */
@@ -2117,6 +2123,11 @@ psql_completion(char *text, int start, int end)
21172123COMPLETE_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/*