if (!RecoveryInProgress())
read_upto = GetFlushRecPtr(&currTLI);
else
+ {
+ TimeLineID insertTLI;
+
read_upto = GetXLogReplayRecPtr(&currTLI);
+
+ /*
+ * If the insertion timeline has already been set, use it. See
+ * logical_read_xlog_page() for details.
+ */
+ insertTLI = GetWALInsertionTimeLineIfSet();
+ if (insertTLI != 0)
+ currTLI = insertTLI;
+ }
tli = currTLI;
/*
# Create a logical slot on the cascading standby for this test.
$node_cascading_standby->create_logical_slot_on_standby($node_standby,
'race_slot', 'testdb');
+$node_cascading_standby->create_logical_slot_on_standby($node_standby,
+ 'race_slot_sql', 'testdb');
$node_standby->safe_psql('testdb',
qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(10,13) s;]
$node_standby->safe_psql('testdb', 'CREATE EXTENSION injection_points;');
$node_standby->wait_for_replay_catchup($node_cascading_standby);
+# Open a background psql session BEFORE promotion for the SQL decoding
+# test.
+my $decode_session = $node_cascading_standby->background_psql('testdb');
+
# Attach injection point to pause startup after WAL segment cleanup
# but before RecoveryInProgress() flips to false.
$node_cascading_standby->safe_psql('testdb',
'got expected output from pg_recvlogical during promotion timeline switch'
);
+# Verify SQL decoding.
+my $sql_out = $decode_session->query_safe(
+ "SELECT data FROM pg_logical_slot_peek_changes('race_slot_sql', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1')"
+);
+is($sql_out, $expected,
+ 'pg_logical_slot_peek_changes works during promotion timeline switch');
+
# Resume promotion.
$node_cascading_standby->safe_psql('testdb',
"SELECT injection_points_wakeup('promotion-after-wal-segment-cleanup');");