]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
pg_upgrade: Fix detection of invalid logical replication slots.
authorMasahiko Sawada <msawada@postgresql.org>
Wed, 22 Apr 2026 16:59:46 +0000 (09:59 -0700)
committerMasahiko Sawada <msawada@postgresql.org>
Wed, 22 Apr 2026 16:59:46 +0000 (09:59 -0700)
Commit 7a1f0f8747a optimized the slot verification query but
overlooked cases where all logical replication slots are already
invalidated. In this scenario, the CTE returns no rows, causing the
main query (which used a cross join) to return an empty result even
when invalid slots exist.

This commit fixes this by using a LEFT JOIN with the CTE, ensuring
that slots are properly reported even if the CTE returns no rows.

Author: Lakshmi N <lakshmin.jhs@gmail.com>
Reviewed-by: Shveta Malik <shveta.malik@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CA+3i_M8eT6j8_cBHkYykV-SXCxbmAxpVSKptjDVq+MFtpT-Paw@mail.gmail.com

src/bin/pg_upgrade/info.c

index 8c5679b80976efe79a55b7dfbe8294fe2630d20f..37fff93892f17e73ab18c2fb6495737cc15c8c3f 100644 (file)
@@ -743,7 +743,8 @@ get_old_cluster_logical_slot_infos_query(ClusterInfo *cluster)
                        "  confirmed_flush_lsn > last_pending_wal "
                        "END as caught_up, "
                        "invalidation_reason IS NOT NULL as invalid "
-                       "FROM pg_catalog.pg_replication_slots, check_caught_up "
+                       "FROM pg_catalog.pg_replication_slots "
+                       "LEFT JOIN check_caught_up ON true "
                        "WHERE slot_type = 'logical' AND "
                        "database = current_database() AND "
                        "temporary IS FALSE ";