- Notifications
You must be signed in to change notification settings - Fork28
Commit7ad6498
committed
Avoid crash in partitionwise join planning under GEQO.
While trying to plan a partitionwise join, we may be faced with caseswhere one or both input partitions for a particular segment of the joinhave been pruned away. In HEAD and v11, this is problematic becauseearlier processing didn't bother to make a pruned RelOptInfo fullyvalid. With an upcoming patch to make partition pruning more efficient,this'll be even more problematic because said RelOptInfo won't exist atall.The existing code attempts to deal with this by retroactively making theRelOptInfo fully valid, but that causes crashes under GEQO because joinplanning is done in a short-lived memory context. In v11 we couldprobably have fixed this by switching to the planner's main contextwhile fixing up the RelOptInfo, but that idea doesn't scale well to theupcoming patch. It would be better not to mess with the base-relationdata structures during join planning, anyway --- that's just a recipefor order-of-operations bugs.In many cases, though, we don't actually need the child RelOptInfo,because if the input is certainly empty then the join segment's resultis certainly empty, so we can skip making a join plan altogether. (Theexisting code ultimately arrives at the same conclusion, but only afterdoing a lot more work.) This approach works except when the pruned-awaypartition is on the nullable side of a LEFT, ANTI, or FULL join, and theother side isn't pruned. But in those cases the existing code leaves alot to be desired anyway --- the correct output is just the result ofthe unpruned side of the join, but we were emitting a useless outer joinagainst a dummy Result. Pending somebody writing code to handle thatmore nicely, let's just abandon the partitionwise-join optimization insuch cases.When the modified code skips making a join plan, it doesn't make ajoin RelOptInfo either; this requires some upper-level code tocope with nulls in part_rels[] arrays. We would have had to havethat anyway after the upcoming patch.Back-patch to v11 since the crash is demonstrable there.Discussion:https://postgr.es/m/8305.1553884377@sss.pgh.pa.us1 parentef6576f commit7ad6498
File tree
7 files changed
+157
-165
lines changed- src
- backend/optimizer
- path
- plan
- test/regress
- expected
- sql
7 files changed
+157
-165
lines changedLines changed: 8 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1112 | 1112 |
| |
1113 | 1113 |
| |
1114 | 1114 |
| |
1115 |
| - | |
1116 |
| - | |
1117 |
| - | |
1118 |
| - | |
1119 |
| - | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1120 | 1120 |
| |
1121 | 1121 |
| |
1122 | 1122 |
| |
| |||
3564 | 3564 |
| |
3565 | 3565 |
| |
3566 | 3566 |
| |
3567 |
| - | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
3568 | 3570 |
| |
3569 | 3571 |
| |
3570 | 3572 |
| |
|
Lines changed: 56 additions & 33 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 |
| - | |
19 | 18 |
| |
20 |
| - | |
21 | 19 |
| |
22 | 20 |
| |
23 | 21 |
| |
| |||
44 | 42 |
| |
45 | 43 |
| |
46 | 44 |
| |
47 |
| - | |
48 |
| - | |
49 | 45 |
| |
50 | 46 |
| |
51 | 47 |
| |
| |||
1405 | 1401 |
| |
1406 | 1402 |
| |
1407 | 1403 |
| |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
1408 | 1408 |
| |
1409 | 1409 |
| |
1410 | 1410 |
| |
| |||
1413 | 1413 |
| |
1414 | 1414 |
| |
1415 | 1415 |
| |
1416 |
| - | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
1417 | 1462 |
| |
1418 |
| - | |
1419 |
| - | |
| 1463 | + | |
| 1464 | + | |
1420 | 1465 |
| |
1421 | 1466 |
| |
1422 | 1467 |
| |
1423 | 1468 |
| |
1424 | 1469 |
| |
1425 |
| - | |
1426 |
| - | |
| 1470 | + | |
| 1471 | + | |
1427 | 1472 |
| |
1428 | 1473 |
| |
1429 | 1474 |
| |
1430 | 1475 |
| |
1431 | 1476 |
| |
1432 |
| - | |
1433 |
| - | |
| 1477 | + | |
| 1478 | + | |
1434 | 1479 |
| |
1435 | 1480 |
| |
1436 | 1481 |
| |
| |||
1474 | 1519 |
| |
1475 | 1520 |
| |
1476 | 1521 |
| |
1477 |
| - | |
1478 |
| - | |
1479 |
| - | |
1480 |
| - | |
1481 |
| - | |
1482 |
| - | |
1483 |
| - | |
1484 |
| - | |
1485 |
| - | |
1486 |
| - | |
1487 |
| - | |
1488 |
| - | |
1489 |
| - | |
1490 |
| - | |
1491 |
| - | |
1492 |
| - | |
1493 |
| - | |
1494 |
| - | |
1495 |
| - | |
1496 |
| - | |
1497 |
| - | |
1498 |
| - | |
1499 | 1522 |
| |
1500 | 1523 |
| |
1501 | 1524 |
| |
|
Lines changed: 7 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6993 | 6993 |
| |
6994 | 6994 |
| |
6995 | 6995 |
| |
| 6996 | + | |
| 6997 | + | |
| 6998 | + | |
| 6999 | + | |
6996 | 7000 |
| |
6997 | 7001 |
| |
6998 | 7002 |
| |
| |||
7093 | 7097 |
| |
7094 | 7098 |
| |
7095 | 7099 |
| |
7096 |
| - | |
7097 |
| - | |
| 7100 | + | |
| 7101 | + | |
| 7102 | + | |
7098 | 7103 |
| |
7099 | 7104 |
| |
7100 | 7105 |
| |
| |||
7136 | 7141 |
| |
7137 | 7142 |
| |
7138 | 7143 |
| |
7139 |
| - | |
7140 |
| - | |
7141 |
| - | |
7142 |
| - | |
7143 |
| - | |
7144 |
| - | |
7145 |
| - | |
7146 |
| - | |
7147 | 7144 |
| |
7148 | 7145 |
| |
7149 | 7146 |
| |
|
Lines changed: 39 additions & 59 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
716 | 716 |
| |
717 | 717 |
| |
718 | 718 |
| |
719 |
| - | |
| 719 | + | |
720 | 720 |
| |
721 |
| - | |
| 721 | + | |
| 722 | + | |
722 | 723 |
| |
723 | 724 |
| |
724 |
| - | |
725 |
| - | |
| 725 | + | |
| 726 | + | |
726 | 727 |
| |
727 |
| - | |
728 |
| - | |
729 |
| - | |
730 |
| - | |
731 |
| - | |
732 |
| - | |
733 |
| - | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
734 | 735 |
| |
735 | 736 |
| |
736 |
| - | |
737 |
| - | |
738 |
| - | |
739 |
| - | |
740 |
| - | |
741 |
| - | |
742 |
| - | |
743 |
| - | |
744 | 737 |
| |
745 | 738 |
| |
746 |
| - | |
| 739 | + | |
| 740 | + | |
747 | 741 |
| |
748 | 742 |
| |
749 |
| - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
750 | 746 |
| |
751 | 747 |
| |
752 | 748 |
| |
| |||
760 | 756 |
| |
761 | 757 |
| |
762 | 758 |
| |
763 |
| - | |
| 759 | + | |
764 | 760 |
| |
765 |
| - | |
| 761 | + | |
| 762 | + | |
766 | 763 |
| |
767 | 764 |
| |
768 |
| - | |
769 |
| - | |
770 |
| - | |
771 |
| - | |
772 |
| - | |
773 |
| - | |
774 |
| - | |
775 |
| - | |
776 |
| - | |
777 |
| - | |
778 |
| - | |
779 |
| - | |
780 |
| - | |
781 |
| - | |
782 |
| - | |
783 |
| - | |
784 |
| - | |
785 |
| - | |
786 |
| - | |
787 |
| - | |
788 |
| - | |
789 |
| - | |
790 |
| - | |
791 |
| - | |
792 |
| - | |
793 |
| - | |
794 |
| - | |
795 |
| - | |
796 |
| - | |
797 |
| - | |
798 |
| - | |
799 |
| - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
800 | 783 |
| |
801 | 784 |
| |
802 |
| - | |
803 |
| - | |
804 |
| - | |
805 |
| - | |
| 785 | + | |
806 | 786 |
| |
807 | 787 |
| |
808 | 788 |
| |
|
0 commit comments
Comments
(0)