From 74ac377d75135e02064fc4427bec401277b4f60c Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Tue, 14 Oct 2025 11:45:29 -0700 Subject: [PATCH] pg_createsubscriber: Add log message when no publications exist to drop. When specifying --clean=publication to pg_createsubscriber, it drops all existing publications with a log message "dropping all existing publications in database "testdb"". Add a new log message "no publications found" when there are no publications to drop, making the progress more transparent to users. Author: Peter Smith Reviewed-by: Masahiko Sawada Discussion: https://postgr.es/m/CAHut+Ptm+WJwbbYXhC0s6FP_98KzZCR=5CPu8F8N5uV8P7BpqA@mail.gmail.com --- src/bin/pg_basebackup/pg_createsubscriber.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index d29407413d9..b33566eabac 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -1755,10 +1755,15 @@ check_and_drop_publications(PGconn *conn, struct LogicalRepInfo *dbinfo) disconnect_database(conn, true); } - /* Drop each publication */ - for (int i = 0; i < PQntuples(res); i++) - drop_publication(conn, PQgetvalue(res, i, 0), dbinfo->dbname, - &dbinfo->made_publication); + if (PQntuples(res) > 0) + { + /* Drop each publication */ + for (int i = 0; i < PQntuples(res); i++) + drop_publication(conn, PQgetvalue(res, i, 0), dbinfo->dbname, + &dbinfo->made_publication); + } + else + pg_log_info("no publications found"); PQclear(res); }