aboutsummaryrefslogtreecommitdiff
path: root/src
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
commitc0a552921b0f5f22ac982b5ad24f1df4fd8ca1b1 (patch)
tree5674a6cdf31283420ab236faf74e5fd17d55b3c7 /src
parent9295d7cf50fbcf1f2be19f835c9b2b1f0186fd9b (diff)
downloadpostgresql-c0a552921b0f5f22ac982b5ad24f1df4fd8ca1b1.tar.gz
postgresql-c0a552921b0f5f22ac982b5ad24f1df4fd8ca1b1.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
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 86524d65980..31ebd8b1019 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -7141,8 +7141,8 @@ getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
TableInfo *tbinfo = &tblinfo[i];
/*
- * For partitioned tables, foreign keys have no triggers so they
- * must be included anyway in case some foreign keys are defined.
+ * For partitioned tables, foreign keys have no triggers so they must
+ * be included anyway in case some foreign keys are defined.
*/
if ((!tbinfo->hastriggers &&
tbinfo->relkind != RELKIND_PARTITIONED_TABLE) ||
@@ -16220,6 +16220,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)
{
@@ -16469,6 +16475,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)
{
@@ -16479,6 +16491,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",