Skip to content

Commit a01f6fa

Browse files
committed
psql: Tab completion for JOIN ... ON/USING
Offer ON/USING clauses for join types that require join conditions (i.e. anything except for NATURAL/CROSS joins). Author: Andreas Karlsson Reviewed-By: Tomas Vondra Discussion: https://postgr.es/m/3a7e27bc-d6ed-4cb0-9b21-f21143fc1b37@proxel.se
1 parent 5dd5786 commit a01f6fa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5167,6 +5167,18 @@ match_previous_words(int pattern_id,
51675167
/* ... JOIN ... */
51685168
else if (TailMatches("JOIN"))
51695169
COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_selectables, "LATERAL");
5170+
else if (TailMatches("JOIN", MatchAny) && !TailMatches("CROSS|NATURAL", "JOIN", MatchAny))
5171+
COMPLETE_WITH("ON", "USING (");
5172+
else if (TailMatches("JOIN", MatchAny, MatchAny) &&
5173+
!TailMatches("CROSS|NATURAL", "JOIN", MatchAny, MatchAny) && !TailMatches("ON|USING"))
5174+
COMPLETE_WITH("ON", "USING (");
5175+
else if (TailMatches("JOIN", "LATERAL", MatchAny, MatchAny) &&
5176+
!TailMatches("CROSS|NATURAL", "JOIN", "LATERAL", MatchAny, MatchAny) && !TailMatches("ON|USING"))
5177+
COMPLETE_WITH("ON", "USING (");
5178+
else if (TailMatches("JOIN", MatchAny, "USING") ||
5179+
TailMatches("JOIN", MatchAny, MatchAny, "USING") ||
5180+
TailMatches("JOIN", "LATERAL", MatchAny, MatchAny, "USING"))
5181+
COMPLETE_WITH("(");
51705182

51715183
/* ... AT [ LOCAL | TIME ZONE ] ... */
51725184
else if (TailMatches("AT"))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy