From c525f740661104e3d8578a133ed6b4a8cd7028ac Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Thu, 13 Apr 2017 11:26:36 +0900 Subject: [PATCH] Improve tab-completion of DDL for publication and subscription. Author: Masahiko Sawada Discussion: http://postgr.es/m/CAD21AoC32YgtateNqTFXzTJmHHe6hXs4cpJTND3n-Ts8f-aMqw@mail.gmail.com --- src/bin/psql/tab-complete.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 9dbb4a0074..e2a3351210 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1501,7 +1501,7 @@ psql_completion(const char *text, int start, int end) /* ALTER PUBLICATION ...*/ else if (Matches3("ALTER","PUBLICATION",MatchAny)) { - COMPLETE_WITH_LIST6("WITH", "ADD TABLE", "SET TABLE", "DROP TABLE", + COMPLETE_WITH_LIST6("WITH (", "ADD TABLE", "SET TABLE", "DROP TABLE", "OWNER TO", "RENAME TO"); } /* ALTER PUBLICATION .. WITH ( ... */ @@ -1513,9 +1513,16 @@ psql_completion(const char *text, int start, int end) /* ALTER SUBSCRIPTION ... */ else if (Matches3("ALTER","SUBSCRIPTION",MatchAny)) { - COMPLETE_WITH_LIST7("WITH", "CONNECTION", "SET PUBLICATION", "ENABLE", - "DISABLE", "OWNER TO", "RENAME TO"); + COMPLETE_WITH_LIST8("WITH (", "CONNECTION", "SET PUBLICATION", "ENABLE", + "DISABLE", "OWNER TO", "RENAME TO", "REFRESH PUBLICATION WITH ("); } + /* ALTER SUBSCRIPTION REFRESH PUBLICATION WITH ( ... */ + else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && + TailMatches4("REFRESH", "PUBLICATION", "WITH", "(")) + { + COMPLETE_WITH_LIST2("COPY DATA", "NOCOPY DATA"); + } + /* ALTER SUBSCRIPTION .. WITH ( ... */ else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches2("WITH", "(")) { COMPLETE_WITH_CONST("SLOT NAME"); @@ -2419,10 +2426,13 @@ psql_completion(const char *text, int start, int end) { /* complete with nothing here as this refers to remote publications */ } + else if (HeadMatches2("CREATE", "SUBSCRIPTION") && TailMatches2("PUBLICATION", MatchAny)) + COMPLETE_WITH_CONST("WITH ("); /* Complete "CREATE SUBSCRIPTION ... WITH ( " */ else if (HeadMatches2("CREATE", "SUBSCRIPTION") && TailMatches2("WITH", "(")) - COMPLETE_WITH_LIST5("ENABLED", "DISABLED", "CREATE SLOT", - "NOCREATE SLOT", "SLOT NAME"); + COMPLETE_WITH_LIST8("ENABLED", "DISABLED", "CREATE SLOT", + "NOCREATE SLOT", "SLOT NAME", "COPY DATA", "NOCOPY DATA", + "NOCONNECT"); /* CREATE TRIGGER --- is allowed inside CREATE SCHEMA, so use TailMatches */ /* complete CREATE TRIGGER with BEFORE,AFTER,INSTEAD OF */ @@ -2681,6 +2691,10 @@ psql_completion(const char *text, int start, int end) else if (Matches5("DROP", "RULE", MatchAny, "ON", MatchAny)) COMPLETE_WITH_LIST2("CASCADE", "RESTRICT"); + /* DROP SUBSCRIPTION */ + else if (Matches3("DROP", "SUBSCRIPTION", MatchAny)) + COMPLETE_WITH_LIST2("DROP SLOT", "NODROP SLOT"); + /* EXECUTE */ else if (Matches1("EXECUTE")) COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements); -- 2.40.0