From c27953c59fdfb0a4a4933843d5ec233a84b0ff19 Mon Sep 17 00:00:00 2001
From: Shi Yu <shiy.fnst@fujitsu.com>
Date: Thu, 27 Apr 2023 11:05:40 +0800
Subject: [PATCH v1] Fix a test case in 035_standby_logical_decoding.pl

For the "replaying logical slot from another database fails" check, perform it
on the standby node instead of the primary node.
---
 src/test/recovery/t/035_standby_logical_decoding.pl | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl
index b8f5311fe9..f559cde914 100644
--- a/src/test/recovery/t/035_standby_logical_decoding.pl
+++ b/src/test/recovery/t/035_standby_logical_decoding.pl
@@ -358,12 +358,17 @@ is($stdout_recv, '', 'pg_recvlogical acknowledged changes');
 
 $node_primary->safe_psql('postgres', 'CREATE DATABASE otherdb');
 
-is( $node_primary->psql(
+# Wait for catchup to ensure that the new database is visible to other sessions
+# on the standby.
+$node_primary->wait_for_replay_catchup($node_standby);
+
+($result, $stdout, $stderr) = $node_standby->psql(
         'otherdb',
         "SELECT lsn FROM pg_logical_slot_peek_changes('behaves_ok_activeslot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
-    ),
-    3,
-    'replaying logical slot from another database fails');
+    );
+ok( $stderr =~
+	  m/replication slot "behaves_ok_activeslot" was not created in this database/,
+	"replaying logical slot from another database fails");
 
 ##################################################
 # Recovery conflict: Invalidate conflicting slots, including in-use slots
-- 
2.31.1

