--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -1066,6 +1066,9 @@ dumpTablespaces(PGconn *conn)
                /* needed for buildACLCommands() */
                fspcname = pg_strdup(fmtId(spcname));

+               appendPQExpBufferStr(buf, "\n-- For binary upgrade, must preserve pg_table
+               appendPQExpBuffer(buf, "SELECT pg_catalog.binary_upgrade_set_next_pg_table

