diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 1d79865058..5e2d28b447 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -4292,30 +4292,26 @@ getPublications(Archive *fout) query = createPQExpBuffer(); /* Get the publications. */ + appendPQExpBufferStr(query, "SELECT p.tableoid, p.oid, p.pubname, " + "p.pubowner, " + "puballtables, p.pubinsert, p.pubupdate, p.pubdelete, "); + + if (fout->remoteVersion >= 110000) + appendPQExpBufferStr(query, "p.pubtruncate, "); + else + appendPQExpBufferStr(query, "false AS pubtruncate, "); + + if (fout->remoteVersion >= 130000) + appendPQExpBufferStr(query, "p.pubviaroot, "); + else + appendPQExpBufferStr(query, "false AS pubviaroot, "); + if (fout->remoteVersion >= 180000) - appendPQExpBufferStr(query, - "SELECT p.tableoid, p.oid, p.pubname, " - "p.pubowner, " - "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, p.pubviaroot, p.pubgencols " - "FROM pg_publication p"); - else if (fout->remoteVersion >= 130000) - appendPQExpBufferStr(query, - "SELECT p.tableoid, p.oid, p.pubname, " - "p.pubowner, " - "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, p.pubviaroot, false AS pubgencols " - "FROM pg_publication p"); - else if (fout->remoteVersion >= 110000) - appendPQExpBufferStr(query, - "SELECT p.tableoid, p.oid, p.pubname, " - "p.pubowner, " - "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false AS pubviaroot, false AS pubgencols " - "FROM pg_publication p"); + appendPQExpBufferStr(query, "p.pubgencols "); else - appendPQExpBufferStr(query, - "SELECT p.tableoid, p.oid, p.pubname, " - "p.pubowner, " - "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, false AS pubtruncate, false AS pubviaroot, false AS pubgencols " - "FROM pg_publication p"); + appendPQExpBufferStr(query, "false AS pubgencols "); + + appendPQExpBufferStr(query, "FROM pg_publication p"); res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);