- Notifications
You must be signed in to change notification settings - Fork5
Commita1ef01f
committed
Improve pg_dump's dependency-sorting logic to enforce section dump order.
As of 9.2, with the --section option, it is very important that the conceptof "pre data", "data", and "post data" sections of the output be honoredstrictly; else a dump divided into separate sectional files might beunrestorable. However, the dependency-sorting logic knew nothing ofsections and would happily select output orderings that didn't fit thatstructure. Doing so was mostly harmless before 9.2, but now we need to besure it doesn't do that. To fix, create dummy objects representing thesection boundaries and add dependencies between them and all the normalobjects. (This might sound expensive but it seems to only add a percent ortwo to pg_dump's runtime.)This also fixes a problem introduced in 9.1 by the feature that allowsincomplete GROUP BY lists when a primary key is given in GROUP BY.That means that views can depend on primary key constraints. Previously,pg_dump would deal with that by simply emitting the primary key constraintbefore the view definition (and hence before the data section of theoutput). That's bad enough for simple serial restores, where creating anindex before the data is loaded works, but is undesirable for speedreasons. But it could lead to outright failure of parallel restores, asseen in bug #6699 from Joe Van Dyk. That happened because pg_restore wouldswitch into parallel mode as soon as it reached the constraint, and thenvery possibly would try to emit the view definition before the primary keywas committed (as a consequence of another bug that causes the view not tobe correctly marked as depending on the constraint). Adding the sectionboundary constraints forces the dependency-sorting code to break the viewinto separate table and rule declarations, allowing the rule, and hence theprimary key constraint it depends on, to revert to their intended locationin the post-data section. This also somewhat accidentally works around thebogus-dependency-marking problem, because the rule will be correctly shownas depending on the constraint, so parallel pg_restore will now do theright thing. (We will fix the bogus-dependency problem for real in aseparate patch, but that patch is not easily back-portable to 9.1, so thefact that this patch is enough to dodge the only known symptom isfortunate.)Back-patch to 9.1, except for the hunk that adds verification that thefinished archive TOC list is in correct section order; the place whereit was convenient to add that doesn't exist in 9.1.1 parent77ed0c6 commita1ef01f
File tree
4 files changed
+238
-30
lines changed- src/bin/pg_dump
4 files changed
+238
-30
lines changedLines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
247 | 247 |
| |
248 | 248 |
| |
249 | 249 |
| |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
250 | 283 |
| |
251 | 284 |
| |
| 285 | + | |
252 | 286 |
| |
253 | 287 |
| |
254 | 288 |
| |
|
Lines changed: 131 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
210 | 210 |
| |
211 | 211 |
| |
212 | 212 |
| |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
213 | 218 |
| |
214 | 219 |
| |
215 | 220 |
| |
| |||
270 | 275 |
| |
271 | 276 |
| |
272 | 277 |
| |
| 278 | + | |
273 | 279 |
| |
274 | 280 |
| |
275 | 281 |
| |
| |||
691 | 697 |
| |
692 | 698 |
| |
693 | 699 |
| |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
694 | 711 |
| |
695 | 712 |
| |
696 | 713 |
| |
| |||
700 | 717 |
| |
701 | 718 |
| |
702 | 719 |
| |
703 |
| - | |
704 |
| - | |
705 | 720 |
| |
706 | 721 |
| |
707 | 722 |
| |
708 | 723 |
| |
709 | 724 |
| |
710 |
| - | |
| 725 | + | |
| 726 | + | |
711 | 727 |
| |
712 | 728 |
| |
713 | 729 |
| |
| |||
7184 | 7200 |
| |
7185 | 7201 |
| |
7186 | 7202 |
| |
| 7203 | + | |
| 7204 | + | |
| 7205 | + | |
| 7206 | + | |
7187 | 7207 |
| |
7188 | 7208 |
| |
7189 | 7209 |
| |
| |||
11672 | 11692 |
| |
11673 | 11693 |
| |
11674 | 11694 |
| |
11675 |
| - | |
| 11695 | + | |
11676 | 11696 |
| |
11677 | 11697 |
| |
11678 | 11698 |
| |
| |||
14027 | 14047 |
| |
14028 | 14048 |
| |
14029 | 14049 |
| |
| 14050 | + | |
| 14051 | + | |
| 14052 | + | |
| 14053 | + | |
| 14054 | + | |
| 14055 | + | |
| 14056 | + | |
| 14057 | + | |
| 14058 | + | |
| 14059 | + | |
| 14060 | + | |
| 14061 | + | |
| 14062 | + | |
| 14063 | + | |
| 14064 | + | |
| 14065 | + | |
| 14066 | + | |
| 14067 | + | |
| 14068 | + | |
| 14069 | + | |
| 14070 | + | |
| 14071 | + | |
| 14072 | + | |
| 14073 | + | |
| 14074 | + | |
| 14075 | + | |
| 14076 | + | |
| 14077 | + | |
| 14078 | + | |
| 14079 | + | |
| 14080 | + | |
| 14081 | + | |
| 14082 | + | |
| 14083 | + | |
| 14084 | + | |
| 14085 | + | |
| 14086 | + | |
| 14087 | + | |
| 14088 | + | |
| 14089 | + | |
| 14090 | + | |
| 14091 | + | |
| 14092 | + | |
| 14093 | + | |
| 14094 | + | |
| 14095 | + | |
| 14096 | + | |
| 14097 | + | |
| 14098 | + | |
| 14099 | + | |
| 14100 | + | |
| 14101 | + | |
| 14102 | + | |
| 14103 | + | |
| 14104 | + | |
| 14105 | + | |
| 14106 | + | |
| 14107 | + | |
| 14108 | + | |
| 14109 | + | |
| 14110 | + | |
| 14111 | + | |
| 14112 | + | |
| 14113 | + | |
| 14114 | + | |
| 14115 | + | |
| 14116 | + | |
| 14117 | + | |
| 14118 | + | |
| 14119 | + | |
| 14120 | + | |
| 14121 | + | |
| 14122 | + | |
| 14123 | + | |
| 14124 | + | |
| 14125 | + | |
| 14126 | + | |
| 14127 | + | |
| 14128 | + | |
| 14129 | + | |
| 14130 | + | |
| 14131 | + | |
| 14132 | + | |
| 14133 | + | |
| 14134 | + | |
| 14135 | + | |
| 14136 | + | |
| 14137 | + | |
| 14138 | + | |
| 14139 | + | |
| 14140 | + | |
| 14141 | + | |
| 14142 | + | |
| 14143 | + | |
| 14144 | + | |
| 14145 | + | |
| 14146 | + | |
| 14147 | + | |
| 14148 | + | |
| 14149 | + | |
| 14150 | + | |
| 14151 | + | |
| 14152 | + | |
| 14153 | + | |
| 14154 | + | |
| 14155 | + | |
| 14156 | + | |
14030 | 14157 |
| |
14031 | 14158 |
| |
14032 | 14159 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
| 100 | + | |
100 | 101 |
| |
101 | 102 |
| |
102 | 103 |
| |
| |||
118 | 119 |
| |
119 | 120 |
| |
120 | 121 |
| |
121 |
| - | |
| 122 | + | |
| 123 | + | |
122 | 124 |
| |
123 | 125 |
| |
124 | 126 |
| |
| |||
520 | 522 |
| |
521 | 523 |
| |
522 | 524 |
| |
523 |
| - | |
| 525 | + | |
| 526 | + | |
524 | 527 |
| |
525 | 528 |
| |
526 | 529 |
| |
|
0 commit comments
Comments
(0)