psql: Tab completion for JOIN ... USING column list
authorTomas Vondra <[email protected]>
Mon, 16 Dec 2024 17:12:29 +0000 (18:12 +0100)
committerTomas Vondra <[email protected]>
Mon, 16 Dec 2024 17:47:03 +0000 (18:47 +0100)
For JOIN ... USING, offer attribute names for the first member of the
column list.

Author: Andreas Karlsson
Reviewed-By: Tomas Vondra
Discussion: https://postgr.es/m/3a7e27bc-d6ed-4cb0-9b21-f21143fc1b37@proxel.se

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

index e9af7b37ac88e8dfc78a43d89259eed82139767b..31c77214b4f06ff107ea51bf826289bd4940d197 100644 (file)
@@ -5179,6 +5179,10 @@ match_previous_words(int pattern_id,
             TailMatches("JOIN", MatchAny, MatchAny, "USING") ||
             TailMatches("JOIN", "LATERAL", MatchAny, MatchAny, "USING"))
        COMPLETE_WITH("(");
+   else if (TailMatches("JOIN", MatchAny, "USING", "("))
+       COMPLETE_WITH_ATTR(prev3_wd);
+   else if (TailMatches("JOIN", MatchAny, MatchAny, "USING", "("))
+       COMPLETE_WITH_ATTR(prev4_wd);
 
 /* ... AT [ LOCAL | TIME ZONE ] ... */
    else if (TailMatches("AT"))