diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2017-05-18 14:16:16 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2017-05-24 19:40:30 -0400 |
commit | 073ce405d68355eed36a11b41e558232ecf18201 (patch) | |
tree | 3bd3cd34873e57e0d1d147078a479642256d0d03 /src/backend/replication/logical/relation.c | |
parent | 92ecb148e517704ec945dce513db71fee7790cfd (diff) |
Fix table syncing with different column order
Logical replication supports replicating between tables with different
column order. But this failed for the initial table sync because of a
logic error in how the column list for the internal COPY command was
composed. Fix that and also add a test.
Also fix a minor omission in the column name mapping cache. When
creating the mapping list, it would not skip locally dropped columns.
So if a remote column had the same name as a locally dropped
column (...pg.dropped...), then the expected error would not occur.
Diffstat (limited to 'src/backend/replication/logical/relation.c')
-rw-r--r-- | src/backend/replication/logical/relation.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c index 41eff8971a5..e65f2865ddb 100644 --- a/src/backend/replication/logical/relation.c +++ b/src/backend/replication/logical/relation.c @@ -277,8 +277,13 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode) found = 0; for (i = 0; i < desc->natts; i++) { - int attnum = logicalrep_rel_att_by_name(remoterel, - NameStr(desc->attrs[i]->attname)); + int attnum; + + if (desc->attrs[i]->attisdropped) + continue; + + attnum = logicalrep_rel_att_by_name(remoterel, + NameStr(desc->attrs[i]->attname)); entry->attrmap[i] = attnum; if (attnum >= 0) |