From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
Cc: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Logical Replication - detail message with names of missing columns |
Date: | 2020-09-08 14:49:19 |
Message-ID: | 20200908144919.GA13287@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2020-09-08 14:50:44 | Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ... |
Previous Message | Julien Rouhaud | 2020-09-08 14:45:07 | Re: Collation versioning |