Skip to content

Commit 7bdc655

Browse files
committed
Tab completion for CREATE TYPE.
Author: Thomas Munro Reviewed-by: Kyotaro Horiguchi Discussion: https://postgr.es/m/CA%2BhUKGLk%3D0yLDjfviONJLzcHEzygj%3Dx6VbGH43LnXbBUvQb52g%40mail.gmail.com
1 parent b91dd9d commit 7bdc655

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/bin/psql/tab-complete.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,6 +2686,45 @@ psql_completion(const char *text, int start, int end)
26862686
else if (Matches("CREATE", "ROLE|USER|GROUP", MatchAny, "IN"))
26872687
COMPLETE_WITH("GROUP", "ROLE");
26882688

2689+
/* CREATE TYPE */
2690+
else if (Matches("CREATE", "TYPE", MatchAny))
2691+
COMPLETE_WITH("(", "AS");
2692+
else if (Matches("CREATE", "TYPE", MatchAny, "AS"))
2693+
COMPLETE_WITH("ENUM", "RANGE", "(");
2694+
else if (HeadMatches("CREATE", "TYPE", MatchAny, "AS", "("))
2695+
{
2696+
if (TailMatches("(|*,", MatchAny))
2697+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
2698+
else if (TailMatches("(|*,", MatchAny, MatchAnyExcept("*)")))
2699+
COMPLETE_WITH("COLLATE", ",", ")");
2700+
}
2701+
else if (Matches("CREATE", "TYPE", MatchAny, "AS", "ENUM|RANGE"))
2702+
COMPLETE_WITH("(");
2703+
else if (HeadMatches("CREATE", "TYPE", MatchAny, "("))
2704+
{
2705+
if (TailMatches("(|*,"))
2706+
COMPLETE_WITH("INPUT", "OUTPUT", "RECEIVE", "SEND",
2707+
"TYPMOD_IN", "TYPMOD_OUT", "ANALYZE",
2708+
"INTERNALLENGTH", "PASSBYVALUE", "ALIGNMENT",
2709+
"STORAGE", "LIKE", "CATEGORY", "PREFERRED",
2710+
"DEFAULT", "ELEMENT", "DELIMITER",
2711+
"COLLATABLE");
2712+
else if (TailMatches("(*|*,", MatchAnyExcept("*=")))
2713+
COMPLETE_WITH("=");
2714+
else if (TailMatches("=", MatchAnyExcept("*)")))
2715+
COMPLETE_WITH(",", ")");
2716+
}
2717+
else if (HeadMatches("CREATE", "TYPE", MatchAny, "AS", "RANGE", "("))
2718+
{
2719+
if (TailMatches("(|*,"))
2720+
COMPLETE_WITH("SUBTYPE", "SUBTYPE_OPCLASS", "COLLATION",
2721+
"CANONICAL", "SUBTYPE_DIFF");
2722+
else if (TailMatches("(*|*,", MatchAnyExcept("*=")))
2723+
COMPLETE_WITH("=");
2724+
else if (TailMatches("=", MatchAnyExcept("*)")))
2725+
COMPLETE_WITH(",", ")");
2726+
}
2727+
26892728
/* CREATE VIEW --- is allowed inside CREATE SCHEMA, so use TailMatches */
26902729
/* Complete CREATE VIEW <name> with AS */
26912730
else if (TailMatches("CREATE", "VIEW", MatchAny))

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