synchronous_commit option is not visible after pressing TAB

Started by tusharover 8 years ago4 messages
#1tushar
tushar.ahuja@enterprisedb.com

Hi,

While creating subscription - if we press TAB button to see the
available parameters , synchronous_commit parameter is not visible.

postgres=# CREATE SUBSCRIPTION sub123 CONNECTION 'dbname=postgres
port=5000' PUBLICATION pub WITH (<Press TAB>
CONNECT COPY_DATA CREATE_SLOT ENABLED SLOT_NAME

synchronous_commit option is not visible

--
regards,tushar
EnterpriseDB https://www.enterprisedb.com/
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Michael Paquier
michael.paquier@gmail.com
In reply to: tushar (#1)
1 attachment(s)
Re: synchronous_commit option is not visible after pressing TAB

On Tue, May 16, 2017 at 8:18 PM, tushar <tushar.ahuja@enterprisedb.com> wrote:

While creating subscription - if we press TAB button to see the available
parameters , synchronous_commit parameter is not visible.

postgres=# CREATE SUBSCRIPTION sub123 CONNECTION 'dbname=postgres port=5000'
PUBLICATION pub WITH (<Press TAB>
CONNECT COPY_DATA CREATE_SLOT ENABLED SLOT_NAME

synchronous_commit option is not visible

Yes, and the items should be ordered alphabetically.
--
Michael

Attachments:

create-sub-tab.patchapplication/octet-stream; name=create-sub-tab.patchDownload
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index b9e3491aec..66d2551b26 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2458,8 +2458,8 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_CONST("WITH (");
 	/* Complete "CREATE SUBSCRIPTION <name> ...  WITH ( <opt>" */
 	else if (HeadMatches2("CREATE", "SUBSCRIPTION") && TailMatches2("WITH", "("))
-		COMPLETE_WITH_LIST5("enabled", "create_slot", "slot_name",
-							"copy_data", "connect");
+		COMPLETE_WITH_LIST6("copy_data", "connect", "create_slot", "enabled",
+							"slot_name", "synchronous_commit");
 
 /* CREATE TRIGGER --- is allowed inside CREATE SCHEMA, so use TailMatches */
 	/* complete CREATE TRIGGER <name> with BEFORE,AFTER,INSTEAD OF */
#3Peter Eisentraut
peter.eisentraut@2ndquadrant.com
In reply to: Michael Paquier (#2)
Re: synchronous_commit option is not visible after pressing TAB

On 5/16/17 19:45, Michael Paquier wrote:

On Tue, May 16, 2017 at 8:18 PM, tushar <tushar.ahuja@enterprisedb.com> wrote:

While creating subscription - if we press TAB button to see the available
parameters , synchronous_commit parameter is not visible.

postgres=# CREATE SUBSCRIPTION sub123 CONNECTION 'dbname=postgres port=5000'
PUBLICATION pub WITH (<Press TAB>
CONNECT COPY_DATA CREATE_SLOT ENABLED SLOT_NAME

synchronous_commit option is not visible

Yes, and the items should be ordered alphabetically.

Fixed. There were a few more things that needed tweaking, too.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Masahiko Sawada
sawada.mshk@gmail.com
In reply to: Peter Eisentraut (#3)
1 attachment(s)
Re: synchronous_commit option is not visible after pressing TAB

On Wed, May 17, 2017 at 11:21 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

On 5/16/17 19:45, Michael Paquier wrote:

On Tue, May 16, 2017 at 8:18 PM, tushar <tushar.ahuja@enterprisedb.com> wrote:

While creating subscription - if we press TAB button to see the available
parameters , synchronous_commit parameter is not visible.

postgres=# CREATE SUBSCRIPTION sub123 CONNECTION 'dbname=postgres port=5000'
PUBLICATION pub WITH (<Press TAB>
CONNECT COPY_DATA CREATE_SLOT ENABLED SLOT_NAME

synchronous_commit option is not visible

Yes, and the items should be ordered alphabetically.

Fixed. There were a few more things that needed tweaking, too.

In addition to that, attached patch fixes two tab completion issues.

* ALTER SUBSCRIPTION hoge_sub SET PUBLICATION hoge_pub [TAB]
-> Complete with "REFRESH ..." or "SKIP REFRESH".
* CREATE PUBLICATION hoge_pub FOR ALL TABLES [TAB] and CREATE
PUBLICATION hoge_pub FOR TABLE hoge_table [TAB]
-> Complete with "WITH ("

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachments:

fix_tab_completion.patchapplication/octet-stream; name=fix_tab_completion.patchDownload
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 31105d8..b48927c 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1562,6 +1562,24 @@ psql_completion(const char *text, int start, int end)
 	{
 		/* complete with nothing here as this refers to remote publications */
 	}
+	/* ALTER SUBSCRIPTION <name> SET PUBLICATION <name> */
+	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
+			 TailMatches3("SET", "PUBLICATION", MatchAny))
+	{
+		COMPLETE_WITH_LIST2("REFRESH", "SKIP REFRESH");
+	}
+	/* ALTER SUBSCRIPTION <name> SET PUBLICATION <name> REFRESH */
+	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
+			 TailMatches4("SET", "PUBLICATION", MatchAny, "REFRESH"))
+	{
+		COMPLETE_WITH_CONST("WITH (");
+	}
+	/* ALTER SUBSCRIPTION <name> SET PUBLICATION <name> REFRESH WITH ( */
+	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
+			 TailMatches6("SET", "PUBLICATION", MatchAny, "REFRESH", "WITH", "("))
+	{
+		COMPLETE_WITH_CONST("copy_data");
+	}
 	/* ALTER SCHEMA <name> */
 	else if (Matches3("ALTER", "SCHEMA", MatchAny))
 		COMPLETE_WITH_LIST2("OWNER TO", "RENAME TO");
@@ -2387,6 +2405,10 @@ psql_completion(const char *text, int start, int end)
 	/* Complete "CREATE PUBLICATION <name> FOR TABLE <table>" */
 	else if (Matches4("CREATE", "PUBLICATION", MatchAny, "FOR TABLE"))
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
+	/* Complete "CREATE PUBLICATION <name> [...]" */
+	else if (HeadMatches3("CREATE", "PUBLICATION", MatchAny) &&
+			 (TailMatches3("FOR", "TABLE", MatchAny) || TailMatches3("FOR", "ALL", "TABLES")))
+		COMPLETE_WITH_CONST("WITH (");
 	/* Complete "CREATE PUBLICATION <name> [...] WITH" */
 	else if (HeadMatches2("CREATE", "PUBLICATION") && TailMatches2("WITH", "("))
 		COMPLETE_WITH_CONST("publish");