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

Commit411e2b0

Browse files
committed
In pg_dump, ensure that view triggers are processed after view rules.
If a view is split into CREATE TABLE + CREATE RULE to break a circulardependency, then any triggers on the view must be dumped/reloaded afterthe CREATE RULE; else the backend may reject the CREATE TRIGGER becauseit's the wrong type of trigger for a plain table. This works all rightin plain dump/restore because of pg_dump's sorting heuristic that placestriggers after rules. However, when using parallel restore, the orderingmust be enforced by a dependency --- and we didn't have one.Fixing this is a mere matter of adding an addObjectDependency() call,except that we need to be able to find all the triggers belonging to theview relation, and there was no easy way to do that. Add fields topg_dump's TableInfo struct to remember where the associated TriggerInfostruct(s) are.Per bug report from Dennis Kögel. The failure can be exhibited at leastas far back as 9.1, so back-patch to all supported branches.
1 parentc27fda6 commit411e2b0

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5905,6 +5905,9 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
59055905

59065906
tginfo= (TriggerInfo*)pg_malloc(ntups*sizeof(TriggerInfo));
59075907

5908+
tbinfo->numTriggers=ntups;
5909+
tbinfo->triggers=tginfo;
5910+
59085911
for (j=0;j<ntups;j++)
59095912
{
59105913
tginfo[j].dobj.objType=DO_TRIGGER;

‎src/bin/pg_dump/pg_dump.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ typedef struct _tableInfo
289289
intnumParents;/* number of (immediate) parent tables */
290290
struct_tableInfo**parents;/* TableInfos of immediate parents */
291291
struct_tableDataInfo*dataObj;/* TableDataInfo, if dumping its data */
292+
intnumTriggers;/* number of triggers for table */
293+
struct_triggerInfo*triggers;/* array of TriggerInfo structs */
292294
}TableInfo;
293295

294296
typedefstruct_attrDefInfo

‎src/bin/pg_dump/pg_dump_sort.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ repairViewRuleMultiLoop(DumpableObject *viewobj,
878878
{
879879
TableInfo*viewinfo= (TableInfo*)viewobj;
880880
RuleInfo*ruleinfo= (RuleInfo*)ruleobj;
881+
inti;
881882

882883
/* remove view's dependency on rule */
883884
removeObjectDependency(viewobj,ruleobj->dumpId);
@@ -895,6 +896,9 @@ repairViewRuleMultiLoop(DumpableObject *viewobj,
895896
addObjectDependency(ruleobj,viewobj->dumpId);
896897
/* now that rule is separate, it must be post-data */
897898
addObjectDependency(ruleobj,postDataBoundId);
899+
/* also, any triggers on the view must be dumped after the rule */
900+
for (i=0;i<viewinfo->numTriggers;i++)
901+
addObjectDependency(&(viewinfo->triggers[i].dobj),ruleobj->dumpId);
898902
}
899903

900904
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp