Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ef86cd

Browse files
committed
Mark index-constraint comments with correct dependency in pg_dump.
When there's a comment on an index that was created with UNIQUE or PRIMARYKEY constraint syntax, we need to label the comment as depending on theconstraint not the index, since only the constraint object actually appearsin the dump. This incorrect dependency can lead to parallel pg_restoretrying to restore the comment before the index has been created, per bug#8257 from Lloyd Albin.This patch fixes pg_dump to produce the right dependency in dumps madein the future. Usually we also try to hack pg_restore to work aroundbogus dependencies, so that existing (wrong) dumps can still be restored inparallel mode; but that doesn't seem practical here since there's no easyway to relate the constraint dump entry to the comment after the fact.Andres Freund
1 parenta099482 commit9ef86cd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13490,6 +13490,7 @@ static void
1349013490
dumpIndex(Archive*fout,IndxInfo*indxinfo)
1349113491
{
1349213492
TableInfo*tbinfo=indxinfo->indextable;
13493+
boolis_constraint= (indxinfo->indexconstraint!=0);
1349313494
PQExpBufferq;
1349413495
PQExpBufferdelq;
1349513496
PQExpBufferlabelq;
@@ -13507,9 +13508,11 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
1350713508
/*
1350813509
* If there's an associated constraint, don't dump the index per se, but
1350913510
* do dump any comment for it.(This is safe because dependency ordering
13510-
* will have ensured the constraint is emitted first.)
13511+
* will have ensured the constraint is emitted first.) Note that the
13512+
* emitted comment has to be shown as depending on the constraint, not
13513+
* the index, in such cases.
1351113514
*/
13512-
if (indxinfo->indexconstraint==0)
13515+
if (!is_constraint)
1351313516
{
1351413517
if (binary_upgrade)
1351513518
binary_upgrade_set_pg_class_oids(fout,q,
@@ -13551,7 +13554,9 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
1355113554
dumpComment(fout,labelq->data,
1355213555
tbinfo->dobj.namespace->dobj.name,
1355313556
tbinfo->rolname,
13554-
indxinfo->dobj.catId,0,indxinfo->dobj.dumpId);
13557+
indxinfo->dobj.catId,0,
13558+
is_constraint ?indxinfo->indexconstraint :
13559+
indxinfo->dobj.dumpId);
1355513560

1355613561
destroyPQExpBuffer(q);
1355713562
destroyPQExpBuffer(delq);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp