Fix bogus tab-completion queries.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 13 Mar 2022 23:52:48 +0000 (19:52 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 13 Mar 2022 23:52:48 +0000 (19:52 -0400)
My (tgl's) thinko in commit 02b8048ba: I forgot that the first
argument of COMPLETE_WITH_QUERY_PLUS is a format string, and
hence failed to double a literal %.  These two places seem to
be the only ones that are wrong, though.

Vignesh C

Discussion: https://postgr.es/m/CALDaNm0hBO+tZqBWhBjTVxyET1GWANq5K9XpQ07atSxnFXbG7w@mail.gmail.com

src/bin/psql/tab-complete.c

index 6957567264ac51e4cce78fcf6545999b3e05d0e5..6d5c928c100791e8b7b177bdb59a8c6412a171c7 100644 (file)
@@ -1811,7 +1811,7 @@ psql_completion(const char *text, int start, int end)
        COMPLETE_WITH("(", "ALL TABLES IN SCHEMA", "TABLE");
    else if (Matches("ALTER", "PUBLICATION", MatchAny, "ADD|DROP|SET", "ALL", "TABLES", "IN", "SCHEMA"))
        COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_schemas
-                                " AND nspname NOT LIKE E'pg\\\\_%'",
+                                " AND nspname NOT LIKE E'pg\\\\_%%'",
                                 "CURRENT_SCHEMA");
    /* ALTER PUBLICATION <name> SET ( */
    else if (HeadMatches("ALTER", "PUBLICATION", MatchAny) && TailMatches("SET", "("))
@@ -2956,7 +2956,7 @@ psql_completion(const char *text, int start, int end)
     */
    else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES", "IN", "SCHEMA"))
        COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_schemas
-                                " AND nspname NOT LIKE E'pg\\\\_%'",
+                                " AND nspname NOT LIKE E'pg\\\\_%%'",
                                 "CURRENT_SCHEMA");
    else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES", "IN", "SCHEMA", MatchAny) && (!ends_with(prev_wd, ',')))
        COMPLETE_WITH("WITH (");