summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c3
-rw-r--r--src/bin/pg_dump/pg_dump.h2
-rw-r--r--src/bin/pg_dump/pg_dump_sort.c11
3 files changed, 14 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4f1a5caee4d..662d43a5798 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -5346,6 +5346,9 @@ getTriggers(TableInfo tblinfo[], int numTables)
tginfo = (TriggerInfo *) malloc(ntups * sizeof(TriggerInfo));
+ tbinfo->numTriggers = ntups;
+ tbinfo->triggers = tginfo;
+
for (j = 0; j < ntups; j++)
{
tginfo[j].dobj.objType = DO_TRIGGER;
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 0bd291456b4..d12680e9f05 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -288,6 +288,8 @@ typedef struct _tableInfo
int numParents; /* number of (immediate) parent tables */
struct _tableInfo **parents; /* TableInfos of immediate parents */
struct _tableDataInfo *dataObj; /* TableDataInfo, if dumping its data */
+ int numTriggers; /* number of triggers for table */
+ struct _triggerInfo *triggers; /* array of TriggerInfo structs */
} TableInfo;
typedef struct _attrDefInfo
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index a9d44897c6e..0c5ef4a2702 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -756,16 +756,23 @@ static void
repairViewRuleMultiLoop(DumpableObject *viewobj,
DumpableObject *ruleobj)
{
+ TableInfo *viewinfo = (TableInfo *) viewobj;
+ RuleInfo *ruleinfo = (RuleInfo *) ruleobj;
+ int i;
+
/* remove view's dependency on rule */
removeObjectDependency(viewobj, ruleobj->dumpId);
/* pretend view is a plain table and dump it that way */
- ((TableInfo *) viewobj)->relkind = 'r'; /* RELKIND_RELATION */
+ viewinfo->relkind = 'r'; /* RELKIND_RELATION */
/* mark rule as needing its own dump */
- ((RuleInfo *) ruleobj)->separate = true;
+ ruleinfo->separate = true;
/* put back rule's dependency on view */
addObjectDependency(ruleobj, viewobj->dumpId);
/* now that rule is separate, it must be post-data */
addObjectDependency(ruleobj, postDataBoundId);
+ /* also, any triggers on the view must be dumped after the rule */
+ for (i = 0; i < viewinfo->numTriggers; i++)
+ addObjectDependency(&(viewinfo->triggers[i].dobj), ruleobj->dumpId);
}
/*