Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fca17a9

Browse files
committed
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>
1 parent 0e58455 commit fca17a9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/backend/replication/logical/worker.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ slot_modify_cstrings(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
402402
errarg.attnum = remoteattnum;
403403

404404
getTypeInputInfo(att->atttypid, &typinput, &typioparam);
405-
slot->tts_values[i] = OidInputFunctionCall(typinput, values[i],
405+
slot->tts_values[i] = OidInputFunctionCall(typinput,
406+
values[remoteattnum],
406407
typioparam,
407408
att->atttypmod);
408409
slot->tts_isnull[i] = false;

src/test/subscription/t/001_rep_changes.pl

+4-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
$node_publisher->safe_psql('postgres', "DELETE FROM tab_rep WHERE a > 20");
9090
$node_publisher->safe_psql('postgres', "UPDATE tab_rep SET a = -a");
9191

92+
$node_publisher->safe_psql('postgres', "INSERT INTO tab_mixed VALUES (2, 'bar')");
93+
9294
$node_publisher->poll_query_until('postgres', $caughtup_query)
9395
or die "Timed out while waiting for subscriber to catch up";
9496

@@ -102,7 +104,8 @@
102104

103105
$result = $node_subscriber->safe_psql('postgres',
104106
"SELECT c, b, a FROM tab_mixed");
105-
is($result, qq(|foo|1), 'check replicated changes with different column order');
107+
is($result, qq(|foo|1
108+
|bar|2), 'check replicated changes with different column order');
106109

107110
# insert some duplicate rows
108111
$node_publisher->safe_psql('postgres',

0 commit comments

Comments
 (0)