aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/tablesync.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-05-18 14:16:16 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-05-24 19:40:30 -0400
commit073ce405d68355eed36a11b41e558232ecf18201 (patch)
tree3bd3cd34873e57e0d1d147078a479642256d0d03 /src/backend/replication/logical/tablesync.c
parent92ecb148e517704ec945dce513db71fee7790cfd (diff)
downloadpostgresql-073ce405d68355eed36a11b41e558232ecf18201.tar.gz
postgresql-073ce405d68355eed36a11b41e558232ecf18201.zip
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/tablesync.c')
-rw-r--r--src/backend/replication/logical/tablesync.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index d69fc7086d0..fe45fb88203 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -492,25 +492,15 @@ static List *
make_copy_attnamelist(LogicalRepRelMapEntry *rel)
{
List *attnamelist = NIL;
- TupleDesc desc = RelationGetDescr(rel->localrel);
int i;
- for (i = 0; i < desc->natts; i++)
+ for (i = 0; i < rel->remoterel.natts; i++)
{
- int remoteattnum = rel->attrmap[i];
-
- /* Skip dropped attributes. */
- if (desc->attrs[i]->attisdropped)
- continue;
-
- /* Skip attributes that are missing on remote side. */
- if (remoteattnum < 0)
- continue;
-
attnamelist = lappend(attnamelist,
- makeString(rel->remoterel.attnames[remoteattnum]));
+ makeString(rel->remoterel.attnames[i]));
}
+
return attnamelist;
}