Commit c45bf57
committed
Fix planner crash from pfree'ing a partial path that a GatherPath uses.
We mustn't run generate_gather_paths() during add_paths_to_joinrel(),
because that function can be invoked multiple times for the same target
joinrel. Not only is it wasteful to build GatherPaths repeatedly, but
a later add_partial_path() could delete the partial path that a previously
created GatherPath depends on. Instead establish the convention that we
do generate_gather_paths() for a rel only just before set_cheapest().
The code was accidentally not broken for baserels, because as of today there
never is more than one partial path for a baserel. But that assumption
obviously has a pretty short half-life, so move the generate_gather_paths()
calls for those cases as well.
Also add some generic comments explaining how and why this all works.
Per fuzz testing by Andreas Seltenreich.
Report: <871t5pgwdt.fsf@credativ.de>1 parent 17d5db3 commit c45bf57
File tree
5 files changed
+71
-34
lines changed- src/backend/optimizer
- geqo
- path
- util
5 files changed
+71
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
170 | 180 | | |
171 | 181 | | |
172 | 182 | | |
| |||
321 | 331 | | |
322 | 332 | | |
323 | 333 | | |
324 | | - | |
325 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
326 | 337 | | |
327 | 338 | | |
328 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
269 | 272 | | |
270 | 273 | | |
271 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
450 | 460 | | |
451 | 461 | | |
452 | 462 | | |
| |||
643 | 653 | | |
644 | 654 | | |
645 | 655 | | |
646 | | - | |
| 656 | + | |
647 | 657 | | |
648 | 658 | | |
649 | 659 | | |
| |||
653 | 663 | | |
654 | 664 | | |
655 | 665 | | |
656 | | - | |
657 | | - | |
| 666 | + | |
| 667 | + | |
658 | 668 | | |
659 | 669 | | |
660 | | - | |
| 670 | + | |
661 | 671 | | |
662 | 672 | | |
663 | 673 | | |
| |||
712 | 722 | | |
713 | 723 | | |
714 | 724 | | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | 725 | | |
726 | 726 | | |
727 | 727 | | |
| |||
1262 | 1262 | | |
1263 | 1263 | | |
1264 | 1264 | | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | 1265 | | |
1269 | 1266 | | |
1270 | 1267 | | |
| |||
1970 | 1967 | | |
1971 | 1968 | | |
1972 | 1969 | | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
1973 | 1974 | | |
1974 | 1975 | | |
1975 | 1976 | | |
| |||
1983 | 1984 | | |
1984 | 1985 | | |
1985 | 1986 | | |
1986 | | - | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
1987 | 1990 | | |
1988 | 1991 | | |
1989 | 1992 | | |
| |||
2148 | 2151 | | |
2149 | 2152 | | |
2150 | 2153 | | |
2151 | | - | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
2152 | 2159 | | |
2153 | 2160 | | |
2154 | 2161 | | |
2155 | 2162 | | |
2156 | 2163 | | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
2157 | 2167 | | |
2158 | 2168 | | |
2159 | 2169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 226 | + | |
232 | 227 | | |
233 | 228 | | |
234 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
398 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
399 | 405 | | |
400 | 406 | | |
401 | 407 | | |
| |||
711 | 717 | | |
712 | 718 | | |
713 | 719 | | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
714 | 724 | | |
715 | 725 | | |
716 | 726 | | |
| |||
721 | 731 | | |
722 | 732 | | |
723 | 733 | | |
724 | | - | |
725 | | - | |
| 734 | + | |
| 735 | + | |
726 | 736 | | |
727 | 737 | | |
728 | 738 | | |
729 | 739 | | |
730 | 740 | | |
731 | 741 | | |
732 | 742 | | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
733 | 751 | | |
734 | 752 | | |
735 | 753 | | |
| |||
808 | 826 | | |
809 | 827 | | |
810 | 828 | | |
811 | | - | |
| 829 | + | |
812 | 830 | | |
813 | 831 | | |
814 | 832 | | |
| |||
842 | 860 | | |
843 | 861 | | |
844 | 862 | | |
845 | | - | |
| 863 | + | |
846 | 864 | | |
847 | 865 | | |
848 | 866 | | |
| |||
0 commit comments