diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2017-08-07 10:49:08 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2017-08-07 10:49:08 -0400 |
commit | fca17a933b4b3cedcd41f14b0fe4d3fb439ea4a4 (patch) | |
tree | dce3559b39d9fa68ca4819a6bdaf390814c4c736 /src | |
parent | 0e58455dd48ca9cbc9987c47b8297d10f1c307b0 (diff) | |
download | postgresql-fca17a933b4b3cedcd41f14b0fe4d3fb439ea4a4.tar.gz postgresql-fca17a933b4b3cedcd41f14b0fe4d3fb439ea4a4.zip |
Fix local/remote attribute mix-up in logical replication
This would lead to failures if local and remote tables have a different
column order. The tests previously didn't catch that because they only
tested the initial data copy. So add another test that exercises the
apply worker.
Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/replication/logical/worker.c | 3 | ||||
-rw-r--r-- | src/test/subscription/t/001_rep_changes.pl | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 0d48dfa4947..7c2df576457 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -402,7 +402,8 @@ slot_modify_cstrings(TupleTableSlot *slot, LogicalRepRelMapEntry *rel, errarg.attnum = remoteattnum; getTypeInputInfo(att->atttypid, &typinput, &typioparam); - slot->tts_values[i] = OidInputFunctionCall(typinput, values[i], + slot->tts_values[i] = OidInputFunctionCall(typinput, + values[remoteattnum], typioparam, att->atttypmod); slot->tts_isnull[i] = false; diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl index a63c6798484..268808da7da 100644 --- a/src/test/subscription/t/001_rep_changes.pl +++ b/src/test/subscription/t/001_rep_changes.pl @@ -89,6 +89,8 @@ $node_publisher->safe_psql('postgres', $node_publisher->safe_psql('postgres', "DELETE FROM tab_rep WHERE a > 20"); $node_publisher->safe_psql('postgres', "UPDATE tab_rep SET a = -a"); +$node_publisher->safe_psql('postgres', "INSERT INTO tab_mixed VALUES (2, 'bar')"); + $node_publisher->poll_query_until('postgres', $caughtup_query) or die "Timed out while waiting for subscriber to catch up"; @@ -102,7 +104,8 @@ is($result, qq(20|-20|-1), 'check replicated changes on subscriber'); $result = $node_subscriber->safe_psql('postgres', "SELECT c, b, a FROM tab_mixed"); -is($result, qq(|foo|1), 'check replicated changes with different column order'); +is($result, qq(|foo|1 +|bar|2), 'check replicated changes with different column order'); # insert some duplicate rows $node_publisher->safe_psql('postgres', |