mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
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
This commit is contained in:
parent
9295d7cf50
commit
c0a552921b
@ -7141,8 +7141,8 @@ getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
|
|||||||
TableInfo *tbinfo = &tblinfo[i];
|
TableInfo *tbinfo = &tblinfo[i];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For partitioned tables, foreign keys have no triggers so they
|
* For partitioned tables, foreign keys have no triggers so they must
|
||||||
* must be included anyway in case some foreign keys are defined.
|
* be included anyway in case some foreign keys are defined.
|
||||||
*/
|
*/
|
||||||
if ((!tbinfo->hastriggers &&
|
if ((!tbinfo->hastriggers &&
|
||||||
tbinfo->relkind != RELKIND_PARTITIONED_TABLE) ||
|
tbinfo->relkind != RELKIND_PARTITIONED_TABLE) ||
|
||||||
@ -16220,6 +16220,12 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
|
|||||||
/* Plain secondary index */
|
/* Plain secondary index */
|
||||||
appendPQExpBuffer(q, "%s;\n", indxinfo->indexdef);
|
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 the index is clustered, we need to record that. */
|
||||||
if (indxinfo->indisclustered)
|
if (indxinfo->indisclustered)
|
||||||
{
|
{
|
||||||
@ -16469,6 +16475,12 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
|
|||||||
appendPQExpBufferStr(q, ";\n");
|
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 the index is clustered, we need to record that. */
|
||||||
if (indxinfo->indisclustered)
|
if (indxinfo->indisclustered)
|
||||||
{
|
{
|
||||||
@ -16479,6 +16491,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
|
|||||||
fmtId(indxinfo->dobj.name));
|
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 ",
|
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s ",
|
||||||
fmtQualifiedDumpable(tbinfo));
|
fmtQualifiedDumpable(tbinfo));
|
||||||
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
|
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user