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

Commitb99dd71

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 parentb523a5c commitb99dd71

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
@@ -6242,6 +6242,9 @@ getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
62426242

62436243
tginfo= (TriggerInfo*)pg_malloc(ntups*sizeof(TriggerInfo));
62446244

6245+
tbinfo->numTriggers=ntups;
6246+
tbinfo->triggers=tginfo;
6247+
62456248
for (j=0;j<ntups;j++)
62466249
{
62476250
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
@@ -257,6 +257,8 @@ typedef struct _tableInfo
257257
intnumParents;/* number of (immediate) parent tables */
258258
struct_tableInfo**parents;/* TableInfos of immediate parents */
259259
struct_tableDataInfo*dataObj;/* TableDataInfo, if dumping its data */
260+
intnumTriggers;/* number of triggers for table */
261+
struct_triggerInfo*triggers;/* array of TriggerInfo structs */
260262
}TableInfo;
261263

262264
typedefstruct_attrDefInfo

‎src/bin/pg_dump/pg_dump_sort.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ repairViewRuleMultiLoop(DumpableObject *viewobj,
884884
{
885885
TableInfo*viewinfo= (TableInfo*)viewobj;
886886
RuleInfo*ruleinfo= (RuleInfo*)ruleobj;
887+
inti;
887888

888889
/* remove view's dependency on rule */
889890
removeObjectDependency(viewobj,ruleobj->dumpId);
@@ -901,6 +902,9 @@ repairViewRuleMultiLoop(DumpableObject *viewobj,
901902
addObjectDependency(ruleobj,viewobj->dumpId);
902903
/* now that rule is separate, it must be post-data */
903904
addObjectDependency(ruleobj,postDataBoundId);
905+
/* also, any triggers on the view must be dumped after the rule */
906+
for (i=0;i<viewinfo->numTriggers;i++)
907+
addObjectDependency(&(viewinfo->triggers[i].dobj),ruleobj->dumpId);
904908
}
905909

906910
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp