Re: Added missing tab completion for alter subscription set option

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Added missing tab completion for alter subscription set option
Date: 2021-05-19 08:33:19
Message-ID: CALj2ACWowOTfdVO4a__J75UsBN9NPiNk+Pw2uhxjiQX95j1g0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 18, 2021 at 9:21 PM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-05-19 08:38:38 Refactor "mutually exclusive options" error reporting code in parse_subscription_options
Previous Message Dean Rasheed 2021-05-19 08:32:36 Re: pgbench test failing on 14beta1 on Debian/i386