Skip to content

Commit 8c7f64b

Browse files
committed
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
1 parent 9f508a9 commit 8c7f64b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15902,6 +15902,12 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
1590215902
/* Plain secondary index */
1590315903
appendPQExpBuffer(q, "%s;\n", indxinfo->indexdef);
1590415904

15905+
/*
15906+
* Append ALTER TABLE commands as needed to set properties that we
15907+
* only have ALTER TABLE syntax for. Keep this in sync with the
15908+
* similar code in dumpConstraint!
15909+
*/
15910+
1590515911
/* If the index is clustered, we need to record that. */
1590615912
if (indxinfo->indisclustered)
1590715913
{
@@ -16036,6 +16042,12 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
1603616042
appendPQExpBufferStr(q, ";\n");
1603716043
}
1603816044

16045+
/*
16046+
* Append ALTER TABLE commands as needed to set properties that we
16047+
* only have ALTER TABLE syntax for. Keep this in sync with the
16048+
* similar code in dumpIndex!
16049+
*/
16050+
1603916051
/* If the index is clustered, we need to record that. */
1604016052
if (indxinfo->indisclustered)
1604116053
{
@@ -16046,6 +16058,16 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
1604616058
fmtId(indxinfo->dobj.name));
1604716059
}
1604816060

16061+
/* If the index defines identity, we need to record that. */
16062+
if (indxinfo->indisreplident)
16063+
{
16064+
appendPQExpBuffer(q, "\nALTER TABLE ONLY %s REPLICA IDENTITY USING",
16065+
fmtQualifiedDumpable(tbinfo));
16066+
/* index name is not qualified in this syntax */
16067+
appendPQExpBuffer(q, " INDEX %s;\n",
16068+
fmtId(indxinfo->dobj.name));
16069+
}
16070+
1604916071
appendPQExpBuffer(delq, "ALTER TABLE ONLY %s ",
1605016072
fmtQualifiedDumpable(tbinfo));
1605116073
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy