Added missing tab completion for alter subscription set option

Started by vignesh Cover 4 years ago15 messages
#1vignesh C
vignesh21@gmail.com
1 attachment(s)

Hi,

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

Regards,
Vignesh

Attachments:

v1-0001-Added-missing-tab-completion-for-alter-subscripti.patchapplication/x-patch; name=v1-0001-Added-missing-tab-completion-for-alter-subscripti.patchDownload
From 84a0c07760c913576ef38d74ab37ffd9ee3ad686 Mon Sep 17 00:00:00 2001
From: vignesh <vignesh21@gmail.com>
Date: Fri, 14 May 2021 11:37:05 +0530
Subject: [PATCH v1] Added missing tab completion for alter subscription set
 option.

Streaming and binary options were missing in tab completion for alter
subscription set option, included it.
---
 src/bin/psql/tab-complete.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 6598c5369a..2c15d8064b 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1665,7 +1665,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH("(", "PUBLICATION");
 	/* ALTER SUBSCRIPTION <name> SET ( */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "("))
-		COMPLETE_WITH("slot_name", "synchronous_commit");
+		COMPLETE_WITH("binary", "slot_name", "synchronous_commit", "streaming");
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "PUBLICATION"))
 	{
-- 
2.25.1

#2Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: vignesh C (#1)
Re: Added missing tab completion for alter subscription set option

On Fri, May 14, 2021 at 12:00 PM vignesh C <vignesh21@gmail.com> wrote:

Hi,

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

+1.

Without patch:
postgres=# alter subscription testsub set (S
SLOT_NAME SYNCHRONOUS_COMMIT

With patch:
postgres=# alter subscription testsub set (
BINARY SLOT_NAME STREAMING SYNCHRONOUS_COMMIT

How about ordering the options alphabetically as the tab complete
output anyways shows that way? I'm not sure if that's the practice,
but just a thought.
Change:
+        COMPLETE_WITH("binary", "slot_name", "synchronous_commit",
"streaming");
To:
+        COMPLETE_WITH("binary", "slot_name", "streaming",
"synchronous_commit");

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

#3vignesh C
vignesh21@gmail.com
In reply to: Bharath Rupireddy (#2)
1 attachment(s)
Re: Added missing tab completion for alter subscription set option

On Fri, May 14, 2021 at 12:25 PM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:

On Fri, May 14, 2021 at 12:00 PM vignesh C <vignesh21@gmail.com> wrote:

Hi,

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

+1.

Without patch:
postgres=# alter subscription testsub set (S
SLOT_NAME SYNCHRONOUS_COMMIT

With patch:
postgres=# alter subscription testsub set (
BINARY SLOT_NAME STREAMING SYNCHRONOUS_COMMIT

How about ordering the options alphabetically as the tab complete
output anyways shows that way? I'm not sure if that's the practice,
but just a thought.

I did not see any rule for this, but also did not see any harm in
keeping it in alphabetical order, so changed it in the attached patch.

Regards,
Vignesh

Attachments:

v2-0001-Added-missing-tab-completion-for-alter-subscripti.patchtext/x-patch; charset=US-ASCII; name=v2-0001-Added-missing-tab-completion-for-alter-subscripti.patchDownload
From 0d209ae307841827aec5478a4ca3f8e3d945eef3 Mon Sep 17 00:00:00 2001
From: vignesh <vignesh21@gmail.com>
Date: Fri, 14 May 2021 11:37:05 +0530
Subject: [PATCH v2] Added missing tab completion for alter subscription set
 option.

Streaming and binary options were missing in tab completion for alter
subscription set option, included it.
---
 src/bin/psql/tab-complete.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 6598c5369a..1b9661fb24 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1665,7 +1665,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH("(", "PUBLICATION");
 	/* ALTER SUBSCRIPTION <name> SET ( */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "("))
-		COMPLETE_WITH("slot_name", "synchronous_commit");
+		COMPLETE_WITH("binary", "slot_name", "streaming", "synchronous_commit");
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "PUBLICATION"))
 	{
-- 
2.25.1

#4Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: vignesh C (#3)
Re: Added missing tab completion for alter subscription set option

On Fri, May 14, 2021 at 6:51 PM vignesh C <vignesh21@gmail.com> wrote:

On Fri, May 14, 2021 at 12:25 PM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:

On Fri, May 14, 2021 at 12:00 PM vignesh C <vignesh21@gmail.com> wrote:

Hi,

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

+1.

Without patch:
postgres=# alter subscription testsub set (S
SLOT_NAME SYNCHRONOUS_COMMIT

With patch:
postgres=# alter subscription testsub set (
BINARY SLOT_NAME STREAMING SYNCHRONOUS_COMMIT

How about ordering the options alphabetically as the tab complete
output anyways shows that way? I'm not sure if that's the practice,
but just a thought.

I did not see any rule for this, but also did not see any harm in
keeping it in alphabetical order, so changed it in the attached patch.

Thanks. Just a few nitpicks:
1) How about patch name: "Add tab completion for ALTER SUBSCRIPTION
SET options streaming and binary"?
2) How about a detailed message: "Tab completion for the options
streaming and binary were missing in case of ALTER SUBSCRIPTION SET
command. This patch adds them."?

You may want to add this in commitfest so that we don't lose track of it.

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

#5vignesh C
vignesh21@gmail.com
In reply to: Bharath Rupireddy (#4)
1 attachment(s)
Re: Added missing tab completion for alter subscription set option

On Fri, May 14, 2021 at 7:10 PM Bharath Rupireddy <
bharath.rupireddyforpostgres@gmail.com> wrote:

On Fri, May 14, 2021 at 6:51 PM vignesh C <vignesh21@gmail.com> wrote:

On Fri, May 14, 2021 at 12:25 PM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:

On Fri, May 14, 2021 at 12:00 PM vignesh C <vignesh21@gmail.com>

wrote:

Hi,

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes

for

the same.
Thoughts?

+1.

Without patch:
postgres=# alter subscription testsub set (S
SLOT_NAME SYNCHRONOUS_COMMIT

With patch:
postgres=# alter subscription testsub set (
BINARY SLOT_NAME STREAMING

SYNCHRONOUS_COMMIT

How about ordering the options alphabetically as the tab complete
output anyways shows that way? I'm not sure if that's the practice,
but just a thought.

I did not see any rule for this, but also did not see any harm in
keeping it in alphabetical order, so changed it in the attached patch.

Thanks. Just a few nitpicks:
1) How about patch name: "Add tab completion for ALTER SUBSCRIPTION
SET options streaming and binary"?

Modified.

2) How about a detailed message: "Tab completion for the options
streaming and binary were missing in case of ALTER SUBSCRIPTION SET
command. This patch adds them."?

Modified.

You may want to add this in commitfest so that we don't lose track of it.

I have added a commitfest entry at [1]https://commitfest.postgresql.org/33/3116/.
Thanks for the comments, the attached patch has the changes for the same.

[1]: https://commitfest.postgresql.org/33/3116/

Regards,
Vignesh

Attachments:

v3-0001-Add-tab-completion-for-ALTER-SUBSCRIPTION-SET-opt.patchtext/x-patch; charset=US-ASCII; name=v3-0001-Add-tab-completion-for-ALTER-SUBSCRIPTION-SET-opt.patchDownload
From 9baa6c750c99a8e3bbd5a3581980b10f10e9e45e Mon Sep 17 00:00:00 2001
From: vignesh <vignesh21@gmail.com>
Date: Fri, 14 May 2021 11:37:05 +0530
Subject: [PATCH v3] Add tab completion for ALTER SUBSCRIPTION SET options
 streaming and binary.

Tab completion for the options streaming and binary were missing in case of
ALTER SUBSCRIPTION SET command. This patch adds them.
---
 src/bin/psql/tab-complete.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 6598c5369a..1b9661fb24 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1665,7 +1665,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH("(", "PUBLICATION");
 	/* ALTER SUBSCRIPTION <name> SET ( */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "("))
-		COMPLETE_WITH("slot_name", "synchronous_commit");
+		COMPLETE_WITH("binary", "slot_name", "streaming", "synchronous_commit");
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "PUBLICATION"))
 	{
-- 
2.25.1

#6Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: vignesh C (#5)
Re: Added missing tab completion for alter subscription set option

On Sat, May 15, 2021 at 10:44 AM vignesh C <vignesh21@gmail.com> wrote:

I have added a commitfest entry at [1].
Thanks for the comments, the attached patch has the changes for the same.

[1] - https://commitfest.postgresql.org/33/3116/

Thanks Vignesh. The v3 patch looks good to me. It applies and compiles
well, works as expected i.e. the streaming and binary options are
shown in the tab-complete of the ALTER SUBSCRIPTION SET command. I
have no further comments, hence moving it to "ready for committer"
state.

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

#7Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: vignesh C (#1)
Re: Added missing tab completion for alter subscription set option

On 2021-May-14, vignesh C wrote:

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

I wish we didn't have to keep knowledge in the psql source on which
option names are to be used for each command. If we had some function
SELECT pg_completion_options('alter subscription set');
that returned the list of options usable for each command, we wouldn't
have to ... psql would just retrieve the list of options for the current
command.

Maintaining such a list does not seem hard -- for example we could just
have a function alongside parse_subscription_option() that returns the
names that are recognized by that one. If we drive the implementation
of both off a single struct, it would never be outdated.

--
�lvaro Herrera 39�49'30"S 73�17'W
"[PostgreSQL] is a great group; in my opinion it is THE best open source
development communities in existence anywhere." (Lamar Owen)

#8Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: Alvaro Herrera (#7)
Re: Added missing tab completion for alter subscription set option

On Tue, May 18, 2021 at 9:21 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

On 2021-May-14, vignesh C wrote:

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

I wish we didn't have to keep knowledge in the psql source on which
option names are to be used for each command. If we had some function
SELECT pg_completion_options('alter subscription set');
that returned the list of options usable for each command, we wouldn't
have to ... psql would just retrieve the list of options for the current
command.

Maintaining such a list does not seem hard -- for example we could just
have a function alongside parse_subscription_option() that returns the
names that are recognized by that one. If we drive the implementation
of both off a single struct, it would never be outdated.

Yeah, having something similar to table_storage_parameters works better.

While on this, I found that all the options are not listed for CREATE
SUBSCRIPTION command in tab-complete.c, missing ones are binary and
streaming:
else if (HeadMatches("CREATE", "SUBSCRIPTION") && TailMatches("WITH", "("))
COMPLETE_WITH("copy_data", "connect", "create_slot", "enabled",
"slot_name", "synchronous_commit");

Similarly, CREATE and ALTER PUBLICATION don't have
publish_via_partition_root option:
else if (HeadMatches("CREATE", "PUBLICATION") && TailMatches("WITH", "("))
COMPLETE_WITH("publish");

I think having some structures like below in subscriptioncmds.h,
publicationcmds.h and using them in tab-complete.c would make more
sense.

static const char *const create_subscription_params[] = {
"copy_data",
"create_slot",
"enabled",
"slot_name",
"synchronous_commit",
"binary",
"connect",
"streaming",
NULL
}

static const char *const alter_subscription_set_params[] = {
"binary",
"slot_name",
"streaming",
"synchronous_commit",
NULL
}

static const char *const create_or_alter_publication_params[] = {
"publish",
"publish_via_partition_root"
NULL
}

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

#9vignesh C
vignesh21@gmail.com
In reply to: Alvaro Herrera (#7)
Re: Added missing tab completion for alter subscription set option

On Tue, May 18, 2021 at 9:20 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

On 2021-May-14, vignesh C wrote:

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

I wish we didn't have to keep knowledge in the psql source on which
option names are to be used for each command. If we had some function
SELECT pg_completion_options('alter subscription set');
that returned the list of options usable for each command, we wouldn't
have to ... psql would just retrieve the list of options for the current
command.

Maintaining such a list does not seem hard -- for example we could just
have a function alongside parse_subscription_option() that returns the
names that are recognized by that one. If we drive the implementation
of both off a single struct, it would never be outdated.

I like the idea of maintaining a common list, that will also prevent
options getting missed in the future. I will work on this and provide
a patch for it.

Regards,
Vignesh

#10vignesh C
vignesh21@gmail.com
In reply to: Alvaro Herrera (#7)
Re: Added missing tab completion for alter subscription set option

On Tue, May 18, 2021 at 9:20 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

On 2021-May-14, vignesh C wrote:

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

I wish we didn't have to keep knowledge in the psql source on which
option names are to be used for each command. If we had some function
SELECT pg_completion_options('alter subscription set');
that returned the list of options usable for each command, we wouldn't
have to ... psql would just retrieve the list of options for the current
command.

Maintaining such a list does not seem hard -- for example we could just
have a function alongside parse_subscription_option() that returns the
names that are recognized by that one. If we drive the implementation
of both off a single struct, it would never be outdated.

On further analysis, I felt that as psql is a front end client, we
should not put any dependency on backend code. I felt that might be
the reason it has been coded to mention the options directly in
tab-complete instead of having any dependency on backend code. we
could have the common module to maintain the options and have both
frontend and backend access it or Should we retain the changes like
the earlier patch.
Thoughts?

Regards,
Vignesh

#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: vignesh C (#10)
Re: Added missing tab completion for alter subscription set option

vignesh C <vignesh21@gmail.com> writes:

On Tue, May 18, 2021 at 9:20 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

I wish we didn't have to keep knowledge in the psql source on which
option names are to be used for each command. If we had some function
SELECT pg_completion_options('alter subscription set');
that returned the list of options usable for each command, we wouldn't
have to ... psql would just retrieve the list of options for the current
command.

On further analysis, I felt that as psql is a front end client, we
should not put any dependency on backend code. I felt that might be
the reason it has been coded to mention the options directly in
tab-complete instead of having any dependency on backend code.

Well, the problem with Alvaro's proposal is how do you square it
with psql's need to support back versions of the server. Maybe
you could code tab-complete.c like "if server >= v15 then do X
else do Y", but since Y would be largely duplicative of the
server-side knowledge accessed by X, you haven't really gotten
rid of the two-places-that-know-this issue. And I'm afraid that
tab-complete.c would become even more of a mess than it is now;
although maybe somebody can see a cute way to avoid that.

regards, tom lane

#12vignesh C
vignesh21@gmail.com
In reply to: Tom Lane (#11)
Re: Added missing tab completion for alter subscription set option

On Thu, May 20, 2021 at 9:40 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

vignesh C <vignesh21@gmail.com> writes:

On Tue, May 18, 2021 at 9:20 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

I wish we didn't have to keep knowledge in the psql source on which
option names are to be used for each command. If we had some function
SELECT pg_completion_options('alter subscription set');
that returned the list of options usable for each command, we wouldn't
have to ... psql would just retrieve the list of options for the current
command.

On further analysis, I felt that as psql is a front end client, we
should not put any dependency on backend code. I felt that might be
the reason it has been coded to mention the options directly in
tab-complete instead of having any dependency on backend code.

Well, the problem with Alvaro's proposal is how do you square it
with psql's need to support back versions of the server. Maybe
you could code tab-complete.c like "if server >= v15 then do X
else do Y", but since Y would be largely duplicative of the
server-side knowledge accessed by X, you haven't really gotten
rid of the two-places-that-know-this issue. And I'm afraid that
tab-complete.c would become even more of a mess than it is now;
although maybe somebody can see a cute way to avoid that.

In my opinion let's not make that change as part of this fix. I think
we can fix the existing problem with the existing way of just
including the options directly in the tab-complete client code because
the new design has an impact on the older versions and also could end
up in duplication like Tom Lane had pointed out. We can start a new
thread for this and try to get others' opinions on it.

Regards,
Vignesh

#13vignesh C
vignesh21@gmail.com
In reply to: Bharath Rupireddy (#8)
1 attachment(s)
Re: Added missing tab completion for alter subscription set option

On Wed, May 19, 2021 at 2:03 PM Bharath Rupireddy <
bharath.rupireddyforpostgres@gmail.com> wrote:

On Tue, May 18, 2021 at 9:21 PM Alvaro Herrera <alvherre@alvh.no-ip.org>

wrote:

On 2021-May-14, vignesh C wrote:

While I was reviewing one of the logical decoding features, I found
Streaming and binary options were missing in tab completion for the
alter subscription set option, the attached patch has the changes for
the same.
Thoughts?

I wish we didn't have to keep knowledge in the psql source on which
option names are to be used for each command. If we had some function
SELECT pg_completion_options('alter subscription set');
that returned the list of options usable for each command, we wouldn't
have to ... psql would just retrieve the list of options for the current
command.

Maintaining such a list does not seem hard -- for example we could just
have a function alongside parse_subscription_option() that returns the
names that are recognized by that one. If we drive the implementation
of both off a single struct, it would never be outdated.

Yeah, having something similar to table_storage_parameters works better.

While on this, I found that all the options are not listed for CREATE
SUBSCRIPTION command in tab-complete.c, missing ones are binary and
streaming:
else if (HeadMatches("CREATE", "SUBSCRIPTION") && TailMatches("WITH",

"("))

COMPLETE_WITH("copy_data", "connect", "create_slot", "enabled",
"slot_name", "synchronous_commit");

Modified.

Similarly, CREATE and ALTER PUBLICATION don't have
publish_via_partition_root option:
else if (HeadMatches("CREATE", "PUBLICATION") && TailMatches("WITH",

"("))

COMPLETE_WITH("publish");

Modified.

I think having some structures like below in subscriptioncmds.h,
publicationcmds.h and using them in tab-complete.c would make more
sense.

This approach has few disadvantages that Tom Lane has pointed out in [1]/messages/by-id/3690759.1621527026@sss.pgh.pa.us,
Let's use the existing way of adding options directly for tab completion.

Thanks for the comments, Attached v4 patch has the fixes for the same.
[1]: /messages/by-id/3690759.1621527026@sss.pgh.pa.us
/messages/by-id/3690759.1621527026@sss.pgh.pa.us

Regards,
Vignesh

Attachments:

v4-0001-Add-missing-tab-completion-for-missing-options-in.patchtext/x-patch; charset=US-ASCII; name=v4-0001-Add-missing-tab-completion-for-missing-options-in.patchDownload
From f5bb987ff172f65680605af5e9df895a49310e0e Mon Sep 17 00:00:00 2001
From: vignesh <vignesh21@gmail.com>
Date: Fri, 14 May 2021 11:37:05 +0530
Subject: [PATCH v4] Add tab completion for missing options in
 PUBLICATION and SUBSCRIPTION commands.

Tab completion for the options streaming and binary were missing in case of
"CREATE SUBSCRIPTION WITH" and "ALTER SUBSCRIPTION SET" commands.

Tab completion for the option publish_via_partition_root was missing in case
of "CREATE PUBLICATION WITH" and "ALTER PUBLICATION SET" commands.

This patch fixes them.
---
 src/bin/psql/tab-complete.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 6598c5369a..8314dfa226 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1646,7 +1646,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH("(", "TABLE");
 	/* ALTER PUBLICATION <name> SET ( */
 	else if (HeadMatches("ALTER", "PUBLICATION", MatchAny) && TailMatches("SET", "("))
-		COMPLETE_WITH("publish");
+		COMPLETE_WITH("publish", "publish_via_partition_root");
 	/* ALTER SUBSCRIPTION <name> */
 	else if (Matches("ALTER", "SUBSCRIPTION", MatchAny))
 		COMPLETE_WITH("CONNECTION", "ENABLE", "DISABLE", "OWNER TO",
@@ -1665,7 +1665,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH("(", "PUBLICATION");
 	/* ALTER SUBSCRIPTION <name> SET ( */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "("))
-		COMPLETE_WITH("slot_name", "synchronous_commit");
+		COMPLETE_WITH("binary", "slot_name", "streaming", "synchronous_commit");
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION */
 	else if (HeadMatches("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches("SET", "PUBLICATION"))
 	{
@@ -2638,7 +2638,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
 	/* Complete "CREATE PUBLICATION <name> [...] WITH" */
 	else if (HeadMatches("CREATE", "PUBLICATION") && TailMatches("WITH", "("))
-		COMPLETE_WITH("publish");
+		COMPLETE_WITH("publish", "publish_via_partition_root");
 
 /* CREATE RULE */
 	/* Complete "CREATE [ OR REPLACE ] RULE <sth>" with "AS ON" */
@@ -2758,8 +2758,9 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH("WITH (");
 	/* Complete "CREATE SUBSCRIPTION <name> ...  WITH ( <opt>" */
 	else if (HeadMatches("CREATE", "SUBSCRIPTION") && TailMatches("WITH", "("))
-		COMPLETE_WITH("copy_data", "connect", "create_slot", "enabled",
-					  "slot_name", "synchronous_commit");
+		COMPLETE_WITH("binary", "copy_data", "connect", "create_slot",
+					  "enabled", "slot_name", "streaming",
+					  "synchronous_commit");
 
 /* CREATE TRIGGER --- is allowed inside CREATE SCHEMA, so use TailMatches */
 
-- 
2.25.1

#14Michael Paquier
michael@paquier.xyz
In reply to: vignesh C (#13)
Re: Added missing tab completion for alter subscription set option

On Sun, May 23, 2021 at 04:24:59PM +0530, vignesh C wrote:

/* Complete "CREATE SUBSCRIPTION <name> ...  WITH ( <opt>" */
else if (HeadMatches("CREATE", "SUBSCRIPTION") && TailMatches("WITH", "("))
-		COMPLETE_WITH("copy_data", "connect", "create_slot", "enabled",
-					  "slot_name", "synchronous_commit");
+		COMPLETE_WITH("binary", "copy_data", "connect", "create_slot",
+					  "enabled", "slot_name", "streaming",
+					  "synchronous_commit");

"copy_data" and "connect" need to be reversed. Applied.
--
Michael

#15vignesh C
vignesh21@gmail.com
In reply to: Michael Paquier (#14)
Re: Added missing tab completion for alter subscription set option

On Fri, Jun 11, 2021 at 12:27 PM Michael Paquier <michael@paquier.xyz> wrote:

On Sun, May 23, 2021 at 04:24:59PM +0530, vignesh C wrote:

/* Complete "CREATE SUBSCRIPTION <name> ...  WITH ( <opt>" */
else if (HeadMatches("CREATE", "SUBSCRIPTION") && TailMatches("WITH", "("))
-             COMPLETE_WITH("copy_data", "connect", "create_slot", "enabled",
-                                       "slot_name", "synchronous_commit");
+             COMPLETE_WITH("binary", "copy_data", "connect", "create_slot",
+                                       "enabled", "slot_name", "streaming",
+                                       "synchronous_commit");

"copy_data" and "connect" need to be reversed. Applied.

Thanks for committing this.

Regards,
Vignesh