postgres.git / summary / log / commit / refs

commit    a01f6fa6ad5e232e1bd38c05d443875ae3ba7ee8
Author:   Tomas Vondra <tomas.vondra@postgresql.org>
Date:     Mon Dec 16 17:08:30 2024 +0000
First released in: 18.0

    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


src/bin/psql/tab-complete.in.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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")) [parent: 5dd5786b94ce]