On 2020-Sep-08, Bharath Rupireddy wrote:

> +     /* Find the remote attributes that are missing in the local relation. */
> +     for (i = 0; i < remoterel->natts; i++)
> +     {
> +             if (!bms_is_member(i, localattnums))
> +             {
> +                     if (missingatts->len == 0)
> +                     {
> +                             appendStringInfoChar(missingatts, '"');
> +                             appendStringInfoString(missingatts, 
> remoterel->attnames[i]);
> +                     }
> +                     else if (missingatts->len > 0)
> +                     {
> +                             appendStringInfoChar(missingatts, ',');
> +                             appendStringInfoChar(missingatts, '"');
> +                             appendStringInfo(missingatts, "%s", 
> remoterel->attnames[i]);
> +                     }
> +
> +                     appendStringInfoChar(missingatts, '"');
> +             }

This looks a bit fiddly.  Would it be less cumbersome to use
quote_identifier here instead?


>                       ereport(ERROR,
>                                       
> (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
>                                        errmsg("logical replication target 
> relation \"%s.%s\" is missing "
> -                                                     "some replicated 
> columns",
> -                                                     remoterel->nspname, 
> remoterel->relname)));
> +                                                     "replicated columns:%s",
> +                                                     remoterel->nspname, 
> remoterel->relname,
> +                                                     missingatts.data)));

Please do use errmsg_plural -- have the new function return the number
of missing columns.  Should be pretty straightforward.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Reply via email to