psql: Tab completion for CREATE MATERIALIZED VIEW ... USING
authorTomas Vondra <tomas.vondra@postgresql.org>
Mon, 16 Dec 2024 15:46:56 +0000 (16:46 +0100)
committerTomas Vondra <tomas.vondra@postgresql.org>
Mon, 16 Dec 2024 16:30:32 +0000 (17:30 +0100)
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

src/bin/psql/tab-complete.in.c

index d1cd7c54f6eb42c82ce7984c1f9b4c359f8c0c58..9e23272fc0e76280431fd800d05cf63d355c756d 100644 (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 */