]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
psql: Fix tab completion for VACUUM option values. master github/master
authorMasahiko Sawada <msawada@postgresql.org>
Wed, 24 Dec 2025 21:55:29 +0000 (13:55 -0800)
committerMasahiko Sawada <msawada@postgresql.org>
Wed, 24 Dec 2025 21:55:29 +0000 (13:55 -0800)
Commit 8a3e4011 introduced tab completion for the ONLY option of
VACUUM and ANALYZE, along with some code simplification using
MatchAnyN. However, it caused a regression in tab completion for
VACUUM option values. For example, neither ON nor OFF was suggested
after "VACUUM (VERBOSE". In addition, the ONLY keyword was not
suggested immediately after a completed option list.

Backpatch to v18.

Author: Yugo Nagata <nagata@sraoss.co.jp>
Discussion: https://postgr.es/m/20251223021509.19bba68ecbbc70c9f983c2b4@sraoss.co.jp
Backpatch-through: 18

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

index ab2712216b5e50c45b012aff33cbb27aa488d9d2..75a101c6ab51134d8a0451e66234b90f2ec87abf 100644 (file)
@@ -3170,6 +3170,9 @@ match_previous_words(int pattern_id,
                else if (TailMatches("VERBOSE|SKIP_LOCKED"))
                        COMPLETE_WITH("ON", "OFF");
        }
+       else if (Matches("ANALYZE", "(*)"))
+               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables,
+                                                                               "ONLY");
        else if (Matches("ANALYZE", MatchAnyN, "("))
                /* "ANALYZE (" should be caught above, so assume we want columns */
                COMPLETE_WITH_ATTR(prev2_wd);
@@ -5303,24 +5306,6 @@ match_previous_words(int pattern_id,
                                                                                "VERBOSE",
                                                                                "ANALYZE",
                                                                                "ONLY");
-       else if (Matches("VACUUM", "FULL"))
-               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
-                                                                               "FREEZE",
-                                                                               "VERBOSE",
-                                                                               "ANALYZE",
-                                                                               "ONLY");
-       else if (Matches("VACUUM", MatchAnyN, "FREEZE"))
-               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
-                                                                               "VERBOSE",
-                                                                               "ANALYZE",
-                                                                               "ONLY");
-       else if (Matches("VACUUM", MatchAnyN, "VERBOSE"))
-               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
-                                                                               "ANALYZE",
-                                                                               "ONLY");
-       else if (Matches("VACUUM", MatchAnyN, "ANALYZE"))
-               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
-                                                                               "ONLY");
        else if (HeadMatches("VACUUM", "(*") &&
                         !HeadMatches("VACUUM", "(*)"))
        {
@@ -5340,6 +5325,27 @@ match_previous_words(int pattern_id,
                else if (TailMatches("INDEX_CLEANUP"))
                        COMPLETE_WITH("AUTO", "ON", "OFF");
        }
+       else if (Matches("VACUUM", "(*)"))
+               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
+                                                                               "ONLY");
+       else if (Matches("VACUUM", "FULL"))
+               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
+                                                                               "FREEZE",
+                                                                               "VERBOSE",
+                                                                               "ANALYZE",
+                                                                               "ONLY");
+       else if (Matches("VACUUM", MatchAnyN, "FREEZE"))
+               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
+                                                                               "VERBOSE",
+                                                                               "ANALYZE",
+                                                                               "ONLY");
+       else if (Matches("VACUUM", MatchAnyN, "VERBOSE"))
+               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
+                                                                               "ANALYZE",
+                                                                               "ONLY");
+       else if (Matches("VACUUM", MatchAnyN, "ANALYZE"))
+               COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
+                                                                               "ONLY");
        else if (Matches("VACUUM", MatchAnyN, "("))
                /* "VACUUM (" should be caught above, so assume we want columns */
                COMPLETE_WITH_ATTR(prev2_wd);