Skip to content

Commit 8b46acf

Browse files
committed
Add test coverage for "unchanged toast column" replication code path.
It seems pretty unacceptable to have no regression test coverage for this aspect of the logical replication protocol, especially given the bugs we've found in related code. Discussion: https://postgr.es/m/16129-a0c0f48e71741e5f@postgresql.org
1 parent 5d3fcb5 commit 8b46acf

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use warnings;
44
use PostgresNode;
55
use TestLib;
6-
use Test::More tests => 19;
6+
use Test::More tests => 21;
77

88
# Initialize publisher node
99
my $node_publisher = get_new_node('publisher');
@@ -157,9 +157,40 @@
157157
local|2.2|bar|2),
158158
'update works with different column order and subscriber local values');
159159

160+
# check behavior with toasted values
161+
162+
$node_publisher->safe_psql('postgres',
163+
"UPDATE tab_mixed SET b = repeat('xyzzy', 100000) WHERE a = 2");
164+
165+
$node_publisher->poll_query_until('postgres', $caughtup_query)
166+
or die "Timed out while waiting for subscriber to catch up";
167+
168+
$result = $node_subscriber->safe_psql('postgres',
169+
"SELECT a, length(b), c, d FROM tab_mixed ORDER BY a");
170+
is( $result, qq(1|3|1.1|local
171+
2|500000|2.2|local),
172+
'update transmits large column value');
173+
174+
$node_publisher->safe_psql('postgres',
175+
"UPDATE tab_mixed SET c = 3.3 WHERE a = 2");
176+
177+
$node_publisher->poll_query_until('postgres', $caughtup_query)
178+
or die "Timed out while waiting for subscriber to catch up";
179+
180+
$result = $node_subscriber->safe_psql('postgres',
181+
"SELECT a, length(b), c, d FROM tab_mixed ORDER BY a");
182+
is( $result, qq(1|3|1.1|local
183+
2|500000|3.3|local),
184+
'update with non-transmitted large column value');
185+
160186
# check behavior with dropped columns
161187

188+
# this update should get transmitted before the column goes away
189+
$node_publisher->safe_psql('postgres',
190+
"UPDATE tab_mixed SET b = 'bar', c = 2.2 WHERE a = 2");
191+
162192
$node_publisher->safe_psql('postgres', "ALTER TABLE tab_mixed DROP COLUMN b");
193+
163194
$node_publisher->safe_psql('postgres',
164195
"UPDATE tab_mixed SET c = 11.11 WHERE a = 1");
165196

0 commit comments

Comments
 (0)