aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2024-12-16 18:08:30 +0100
committerTomas Vondra <tomas.vondra@postgresql.org>2024-12-16 18:47:03 +0100
commita01f6fa6ad5e232e1bd38c05d443875ae3ba7ee8 (patch)
tree5015a704dcb656ab1241d4de871006219e4618e1 /src
parent5dd5786b94cea4652035a5dc55c103ed09b0365b (diff)
downloadpostgresql-a01f6fa6ad5e232e1bd38c05d443875ae3ba7ee8.tar.gz
postgresql-a01f6fa6ad5e232e1bd38c05d443875ae3ba7ee8.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/tab-complete.in.c12
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 6a9c5e240fb..e9af7b37ac8 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"))