Re: Logical Replication - detail message with names of missing columns - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Logical Replication - detail message with names of missing columns
Date
Msg-id 20200908144919.GA13287@alvherre.pgsql
Whole thread Raw
In response to Re: Logical Replication - detail message with names of missing columns  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: Logical Replication - detail message with names of missing columns  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: Collation versioning
Next
From: Laurenz Albe
Date:
Subject: Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ...