diff options
author | Tomas Vondra | 2024-12-16 17:08:30 +0000 |
---|---|---|
committer | Tomas Vondra | 2024-12-16 17:47:03 +0000 |
commit | a01f6fa6ad5e232e1bd38c05d443875ae3ba7ee8 (patch) | |
tree | 5015a704dcb656ab1241d4de871006219e4618e1 | |
parent | 5dd5786b94cea4652035a5dc55c103ed09b0365b (diff) |
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/[email protected]
-rw-r--r-- | src/bin/psql/tab-complete.in.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 6a9c5e240f..e9af7b37ac 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5167,6 +5167,18 @@ match_previous_words(int pattern_id, /* ... JOIN ... */ else if (TailMatches("JOIN")) COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_selectables, "LATERAL"); + else if (TailMatches("JOIN", MatchAny) && !TailMatches("CROSS|NATURAL", "JOIN", MatchAny)) + COMPLETE_WITH("ON", "USING ("); + else if (TailMatches("JOIN", MatchAny, MatchAny) && + !TailMatches("CROSS|NATURAL", "JOIN", MatchAny, MatchAny) && !TailMatches("ON|USING")) + COMPLETE_WITH("ON", "USING ("); + else if (TailMatches("JOIN", "LATERAL", MatchAny, MatchAny) && + !TailMatches("CROSS|NATURAL", "JOIN", "LATERAL", MatchAny, MatchAny) && !TailMatches("ON|USING")) + COMPLETE_WITH("ON", "USING ("); + else if (TailMatches("JOIN", MatchAny, "USING") || + TailMatches("JOIN", MatchAny, MatchAny, "USING") || + TailMatches("JOIN", "LATERAL", MatchAny, MatchAny, "USING")) + COMPLETE_WITH("("); /* ... AT [ LOCAL | TIME ZONE ] ... */ else if (TailMatches("AT")) |