Re: Improve errhint for ALTER SUBSCRIPTION ADD/DROP PUBLICATION

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improve errhint for ALTER SUBSCRIPTION ADD/DROP PUBLICATION
Date: 2022-10-17 08:45:07
Message-ID: CAHut+Psxa5CSgzJCvP_oMMtkUMKnH1i+3x3a_7kn+zDTS+XQYw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 17, 2022 at 6:43 PM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> Hello
>
> On 2022-Oct-17, houzj(dot)fnst(at)fujitsu(dot)com wrote:
>
> > alter subscription sub add publication pub2;
>
> > Because I was executing the ADD PUBLICATION command, I feel the hint should
> > also mention it instead of SET PUBLICATION.
>
> Hmm, ok. But:
>
>
> > @@ -1236,8 +1237,9 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
> > ereport(ERROR,
> > (errcode(ERRCODE_SYNTAX_ERROR),
> > errmsg("ALTER SUBSCRIPTION with refresh and copy_data is not allowed when two_phase is enabled"),
> > - errhint("Use ALTER SUBSCRIPTION ... SET PUBLICATION with refresh = false, or with copy_data = false"
> > - ", or use DROP/CREATE SUBSCRIPTION.")));
> > + errhint("Use ALTER SUBSCRIPTION ... %s PUBLICATION with refresh = false, or with copy_data = false"
> > + ", or use DROP/CREATE SUBSCRIPTION.",
> > + isadd ? "ADD" : "DROP")));
>
> This looks confusing for translators. I propose to move the whole
> command out of the message, not just one piece of it:
>
> + /*- translator: %s is an ALTER DDL command */
> + errhint("Use %s with refresh = false, or with copy_data = false, or use DROP/CREATE SUBSCRIPTION.",
> isadd ? "ALTER SUBSCRIPTION ... ADD PUBLICATION" : ALTER SUBSCRIPTION ... DROP PUBLICATION")
>
> I'm not sure that ERRCODE_SYNTAX_ERROR is the right thing here; sounds
> like ERRCODE_FEATURE_NOT_SUPPORTED might be more appropriate.
>

I thought maybe ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE, which would
make it the same as similar messages in the same function when
incompatible parameters are specified.

------
Kind Regards,
Peter Smith.
Fujitsu Australia.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2022-10-17 09:10:52 Re: Improve errhint for ALTER SUBSCRIPTION ADD/DROP PUBLICATION
Previous Message Nikita Malakhov 2022-10-17 08:37:03 RFC: multi TOAST-tables support