Ignore publication tables when --no-publications is used
authorMichael Paquier <michael@paquier.xyz>
Tue, 25 Sep 2018 02:05:13 +0000 (11:05 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 25 Sep 2018 02:05:13 +0000 (11:05 +0900)
96e1cb4 has added support for --no-publications in pg_dump, pg_dumpall
and pg_restore, but forgot the fact that publication tables also need to
be ignored when this option is used.

Author: Gilles Darold
Reviewed-by: Michael Paquier
Discussion: https://postgr.es/m/3f48e812-b0fa-388e-2043-9a176bdee27e@dalibo.com
Backpatch-through: 10, where publications have been added.

src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_dump.c

index 36e3383b851a5d164566551923e37573f8e625b6..e4060124fbbc691af3dba57251eb07ef9c19f98e 100644 (file)
@@ -2855,8 +2855,13 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
    if (ropt->no_comments && strcmp(te->desc, "COMMENT") == 0)
        return 0;
 
-   /* If it's a publication, maybe ignore it */
-   if (ropt->no_publications && strcmp(te->desc, "PUBLICATION") == 0)
+   /*
+    * If it's a publication or a table part of a publication, maybe ignore
+    * it.
+    */
+   if (ropt->no_publications &&
+       (strcmp(te->desc, "PUBLICATION") == 0 ||
+        strcmp(te->desc, "PUBLICATION TABLE") == 0))
        return 0;
 
    /* If it's a security label, maybe ignore it */
index e91184ba6ef1cdd5a8f08b9b517c2de92fd9dcea..b2a1e83e11fa56361ce02601ef8fec993cb35ecc 100644 (file)
@@ -3886,6 +3886,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
    PQExpBuffer query;
    PGresult   *res;
    PublicationRelInfo *pubrinfo;
+   DumpOptions *dopt = fout->dopt;
    int         i_tableoid;
    int         i_oid;
    int         i_pubname;
@@ -3893,7 +3894,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
                j,
                ntups;
 
-   if (fout->remoteVersion < 100000)
+   if (dopt->no_publications || fout->remoteVersion < 100000)
        return;
 
    query = createPQExpBuffer();