aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r--src/bin/pg_dump/pg_dump.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index ca86ae705fd..61d2345f384 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -16980,6 +16980,15 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
appendPQExpBufferStr(query, "BY DEFAULT");
appendPQExpBuffer(query, " AS IDENTITY (\n SEQUENCE NAME %s\n",
fmtQualifiedDumpable(tbinfo));
+
+ /*
+ * Emit persistence option only if it's different from the owning
+ * table's. This avoids using this new syntax unnecessarily.
+ */
+ if (tbinfo->relpersistence != owning_tab->relpersistence)
+ appendPQExpBuffer(query, " %s\n",
+ tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED ?
+ "UNLOGGED" : "LOGGED");
}
else
{
@@ -17012,15 +17021,7 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo)
cache, (cycled ? "\n CYCLE" : ""));
if (tbinfo->is_identity_sequence)
- {
appendPQExpBufferStr(query, "\n);\n");
- if (tbinfo->relpersistence != owning_tab->relpersistence)
- appendPQExpBuffer(query,
- "ALTER SEQUENCE %s SET %s;\n",
- fmtQualifiedDumpable(tbinfo),
- tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED ?
- "UNLOGGED" : "LOGGED");
- }
else
appendPQExpBufferStr(query, ";\n");