Fix logical decoding regression tests to correctly check slot existence.
authorFujii Masao <[email protected]>
Fri, 4 Apr 2025 04:09:06 +0000 (13:09 +0900)
committerFujii Masao <[email protected]>
Fri, 4 Apr 2025 04:09:06 +0000 (13:09 +0900)
The regression tests for logical decoding verify whether a logical slot
exists or has been dropped. Previously, these tests attempted to
retrieve "slot_name" from the result of slot(), but since "slot_name" was
not included in the result, slot()->{'slot_name'} always returned undef,
leading to incorrect behavior.

This commit fixes the issue by checking the "plugin" field in the result
of slot() instead, ensuring the tests properly verify slot existence.

Back-patch to all supported versions.

Author: Hayato Kuroda <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/OSCPR01MB149667EC4E738769CA80B7EA5F5AE2@OSCPR01MB14966.jpnprd01.prod.outlook.com
Backpatch-through: 13

src/test/recovery/t/006_logical_decoding.pl
src/test/recovery/t/010_logical_decoding_timelines.pl

index a5678bc4dc41d1117d4c429a74a8519e38eab8bd..2137c4e5e305f272bb9704775e50c33c1d116b3f 100644 (file)
@@ -161,8 +161,8 @@ SKIP:
    is($node_primary->psql('postgres', 'DROP DATABASE otherdb'),
        3, 'dropping a DB with active logical slots fails');
    $pg_recvlogical->kill_kill;
-   is($node_primary->slot('otherdb_slot')->{'slot_name'},
-       undef, 'logical slot still exists');
+   is($node_primary->slot('otherdb_slot')->{'plugin'},
+       'test_decoding', 'logical slot still exists');
 }
 
 $node_primary->poll_query_until('otherdb',
@@ -171,8 +171,8 @@ $node_primary->poll_query_until('otherdb',
 
 is($node_primary->psql('postgres', 'DROP DATABASE otherdb'),
    0, 'dropping a DB with inactive logical slots succeeds');
-is($node_primary->slot('otherdb_slot')->{'slot_name'},
-   undef, 'logical slot was actually dropped with DB');
+is($node_primary->slot('otherdb_slot')->{'plugin'},
+   '', 'logical slot was actually dropped with DB');
 
 # Test logical slot advancing and its durability.
 # Passing failover=true (last arg) should not have any impact on advancing.
index 08615f1fca87c290a7622a1e71d3fd8954c6c12a..0199ae95abf229754b38238e03aab428d933b6da 100644 (file)
@@ -94,8 +94,8 @@ is( $node_replica->safe_psql(
        'postgres', q[SELECT 1 FROM pg_database WHERE datname = 'dropme']),
    '',
    'dropped DB dropme on standby');
-is($node_primary->slot('dropme_slot')->{'slot_name'},
-   undef, 'logical slot was actually dropped on standby');
+is($node_primary->slot('dropme_slot')->{'plugin'},
+   '', 'logical slot was actually dropped on standby');
 
 # Back to testing failover...
 $node_primary->safe_psql('postgres',