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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy