]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Ignore publication tables when --no-publications is used
authorMichael Paquier <michael@paquier.xyz>
Tue, 25 Sep 2018 02:05:29 +0000 (11:05 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 25 Sep 2018 02:05:29 +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 5cbe6658dbee89a63175b560a8326af92327ff34..a2e2f96986a78c67cbb7067a1cfad777294e8095 100644 (file)
@@ -2837,8 +2837,13 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
        if (ropt->aclsSkip && _tocEntryIsACL(te))
                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 security labels, maybe ignore it */
index db19f924d807f910f525235a7f729ee56f1fc918..376b8c7db7811893df2fe88057a541e3f2eb19e7 100644 (file)
@@ -3601,6 +3601,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;
@@ -3608,7 +3609,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
                                j,
                                ntups;
 
-       if (fout->remoteVersion < 100000)
+       if (dopt->no_publications || fout->remoteVersion < 100000)
                return;
 
        query = createPQExpBuffer();