psql: Tab completion for CREATE MATERIALIZED VIEW ... USING

The tab completion didn't offer USING for CREATE MATERIALIZED VIEW, so
add it, and offer a list of access methods, followed by SELECT.

Author: Kirill Reshke
Reviewed-By: Karina Litskevich
Discussion: https://postgr.es/m/CALdSSPhVELkvutquqrDB=Ujfq_Pjz=6jn-kzh+291KPNViLTfw@mail.gmail.com
This commit is contained in:
Tomas Vondra 2024-12-16 16:46:56 +01:00
parent 1e1f70c34a
commit de1e298857

View File

@ -3981,11 +3981,26 @@ match_previous_words(int pattern_id,
/* CREATE MATERIALIZED VIEW */
else if (Matches("CREATE", "MATERIALIZED"))
COMPLETE_WITH("VIEW");
/* Complete CREATE MATERIALIZED VIEW <name> with AS */
/* Complete CREATE MATERIALIZED VIEW <name> with AS or USING */
else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny))
COMPLETE_WITH("AS", "USING");
/*
* Complete CREATE MATERIALIZED VIEW <name> USING with list of access
* methods
*/
else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny, "USING"))
COMPLETE_WITH_QUERY(Query_for_list_of_table_access_methods);
/* Complete CREATE MATERIALIZED VIEW <name> USING <access method> with AS */
else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny, "USING", MatchAny))
COMPLETE_WITH("AS");
/* Complete "CREATE MATERIALIZED VIEW <sth> AS with "SELECT" */
else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny, "AS"))
/*
* Complete CREATE MATERIALIZED VIEW <name> [USING <access method> ] AS
* with "SELECT"
*/
else if (Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny, "AS") ||
Matches("CREATE", "MATERIALIZED", "VIEW", MatchAny, "USING", MatchAny, "AS"))
COMPLETE_WITH("SELECT");
/* CREATE EVENT TRIGGER */