pg_createsubscriber: Add log message when no publications exist to drop.
authorMasahiko Sawada <msawada@postgresql.org>
Tue, 14 Oct 2025 18:45:29 +0000 (11:45 -0700)
committerMasahiko Sawada <msawada@postgresql.org>
Tue, 14 Oct 2025 18:45:29 +0000 (11:45 -0700)
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 <smithpb2250@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/CAHut+Ptm+WJwbbYXhC0s6FP_98KzZCR=5CPu8F8N5uV8P7BpqA@mail.gmail.com

src/bin/pg_basebackup/pg_createsubscriber.c

index d29407413d96b2207c78aa825ec1a38b3010d692..b33566eabac268d3d563fe251f8a23f6b05448f4 100644 (file)
@@ -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);
    }