|
19 | 19 | #include "pg_backup_utils.h"
|
20 | 20 | #include "pg_dump.h"
|
21 | 21 |
|
| 22 | +#include "catalog/pg_class.h" |
| 23 | + |
22 | 24 | /* translator: this is a module name */
|
23 | 25 | static const char *modulename = gettext_noop("sorter");
|
24 | 26 |
|
@@ -931,19 +933,26 @@ repairViewRuleMultiLoop(DumpableObject *viewobj,
|
931 | 933 | *
|
932 | 934 | * Note that the "next object" is not necessarily the matview itself;
|
933 | 935 | * it could be the matview's rowtype, for example. We may come through here
|
934 |
| - * several times while removing all the pre-data linkages. |
| 936 | + * several times while removing all the pre-data linkages. In particular, |
| 937 | + * if there are other matviews that depend on the one with the circularity |
| 938 | + * problem, we'll come through here for each such matview and mark them all |
| 939 | + * as postponed. (This works because all MVs have pre-data dependencies |
| 940 | + * to begin with, so each of them will get visited.) |
935 | 941 | */
|
936 | 942 | static void
|
937 |
| -repairMatViewBoundaryMultiLoop(DumpableObject *matviewobj, |
938 |
| - DumpableObject *boundaryobj, |
| 943 | +repairMatViewBoundaryMultiLoop(DumpableObject *boundaryobj, |
939 | 944 | DumpableObject *nextobj)
|
940 | 945 | {
|
941 |
| - TableInfo *matviewinfo = (TableInfo *) matviewobj; |
942 |
| - |
943 | 946 | /* remove boundary's dependency on object after it in loop */
|
944 | 947 | removeObjectDependency(boundaryobj, nextobj->dumpId);
|
945 |
| - /* mark matview as postponed into post-data section */ |
946 |
| - matviewinfo->postponed_def = true; |
| 948 | + /* if that object is a matview, mark it as postponed into post-data */ |
| 949 | + if (nextobj->objType == DO_TABLE) |
| 950 | + { |
| 951 | + TableInfo *nextinfo = (TableInfo *) nextobj; |
| 952 | + |
| 953 | + if (nextinfo->relkind == RELKIND_MATVIEW) |
| 954 | + nextinfo->postponed_def = true; |
| 955 | + } |
947 | 956 | }
|
948 | 957 |
|
949 | 958 | /*
|
@@ -1125,8 +1134,7 @@ repairDependencyLoop(DumpableObject **loop,
|
1125 | 1134 | DumpableObject *nextobj;
|
1126 | 1135 |
|
1127 | 1136 | nextobj = (j < nLoop - 1) ? loop[j + 1] : loop[0];
|
1128 |
| - repairMatViewBoundaryMultiLoop(loop[i], loop[j], |
1129 |
| - nextobj); |
| 1137 | + repairMatViewBoundaryMultiLoop(loop[j], nextobj); |
1130 | 1138 | return;
|
1131 | 1139 | }
|
1132 | 1140 | }
|
|
0 commit comments