From 4ca8cf7de0e575b0175fbc3a5797b75857bd2fab Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Sat, 24 Oct 2020 14:51:18 -0500 Subject: [PATCH] pg_dump: Allow child partitions to be independently restored ..even if the parent doesn't exist, or has missing/incompatible columns This seems to have been intended by commit 33a53130a --- src/bin/pg_dump/pg_dump.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 40844fa1e7..8a783f1d3e 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -15676,6 +15676,13 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) binary_upgrade_set_pg_class_oids(fout, q, tbinfo->dobj.catId.oid, false); + /* + * Use explicit transaction commands so that failure in a + * following command in the same txn doesn't cause ROLLBACK of + * the "CREATE TABLE". + */ + appendPQExpBufferStr(q, "begin;\n"); + appendPQExpBuffer(q, "CREATE %s%s %s", tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED ? "UNLOGGED " : "", @@ -15896,6 +15903,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) } else appendPQExpBufferStr(q, ";\n"); + appendPQExpBufferStr(q, "commit;\n"); /* Materialized views can depend on extensions */ if (tbinfo->relkind == RELKIND_MATVIEW) -- 2.17.0