Re: Added missing tab completion for alter subscription set option

Поиск
Список
Период
Сортировка
От Bharath Rupireddy
Тема Re: Added missing tab completion for alter subscription set option
Дата
Msg-id CALj2ACWowOTfdVO4a__J75UsBN9NPiNk+Pw2uhxjiQX95j1g0w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Added missing tab completion for alter subscription set option  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Ответы Re: Added missing tab completion for alter subscription set option  (vignesh C <vignesh21@gmail.com>)
Список pgsql-hackers
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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dean Rasheed
Дата:
Сообщение: Re: pgbench test failing on 14beta1 on Debian/i386
Следующее
От: Bharath Rupireddy
Дата:
Сообщение: Refactor "mutually exclusive options" error reporting code in parse_subscription_options