aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-07-30 12:35:49 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-07-30 12:35:49 -0400
commitb868c08eb60a1db3d6248d78c47777058b012023 (patch)
tree8427462ac975d636309b3d0cc228a8e2601ffa54
parent72c453d30d565de91c921c7f5e0c984c23e77df5 (diff)
downloadpostgresql-b868c08eb60a1db3d6248d78c47777058b012023.tar.gz
postgresql-b868c08eb60a1db3d6248d78c47777058b012023.zip
Fix pg_dump's failure to dump REPLICA IDENTITY for constraint indexes.
pg_dump knew about printing ALTER TABLE ... REPLICA IDENTITY USING INDEX for indexes declared as indexes, but it failed to print that for indexes declared as unique or primary-key constraints. Per report from Achilleas Mantzios. This has been broken since the feature was introduced, AFAICS. Back-patch to 9.4. Discussion: https://postgr.es/m/1e6cc5ad-b84a-7c07-8c08-a4d0c3cdc938@matrix.gatewaynet.com
-rw-r--r--src/bin/pg_dump/pg_dump.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c4005a4cc3c..837b9f811a8 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -14494,6 +14494,12 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
/* Plain secondary index */
appendPQExpBuffer(q, "%s;\n", indxinfo->indexdef);
+ /*
+ * Append ALTER TABLE commands as needed to set properties that we
+ * only have ALTER TABLE syntax for. Keep this in sync with the
+ * similar code in dumpConstraint!
+ */
+
/* If the index is clustered, we need to record that. */
if (indxinfo->indisclustered)
{
@@ -14625,6 +14631,12 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
appendPQExpBufferStr(q, ";\n");
}
+ /*
+ * Append ALTER TABLE commands as needed to set properties that we
+ * only have ALTER TABLE syntax for. Keep this in sync with the
+ * similar code in dumpIndex!
+ */
+
/* If the index is clustered, we need to record that. */
if (indxinfo->indisclustered)
{
@@ -14635,6 +14647,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
fmtId(indxinfo->dobj.name));
}
+ /* If the index defines identity, we need to record that. */
+ if (indxinfo->indisreplident)
+ {
+ appendPQExpBuffer(q, "\nALTER TABLE ONLY %s REPLICA IDENTITY USING",
+ fmtQualifiedDumpable(tbinfo));
+ /* index name is not qualified in this syntax */
+ appendPQExpBuffer(q, " INDEX %s;\n",
+ fmtId(indxinfo->dobj.name));
+ }
+
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s ",
fmtQualifiedDumpable(tbinfo));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",