- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit19a00ea
committed
In back branches, fix conditions for pullup of FROM-less subqueries.
In branches before commit4be058f, we have to prevent flatteningof subqueries with empty jointrees if the subqueries' outputcolumns might need to be wrapped in PlaceHolderVars. That'sbecause the empty jointree would result in empty phrels for thePlaceHolderVars, meaning we'd be unable to figure out where toevaluate them. However, we've failed to keep is_simple_subquery'scheck for this hazard in sync with what pull_up_simple_subqueryactually does. The former is checking "lowest_outer_join != NULL",whereas the conditions pull_up_simple_subquery actually uses areif (lowest_nulling_outer_join != NULL)if (containing_appendrel != NULL)if (parse->groupingSets)So the outer-join test is overly conservative, while we missed outchecking for appendrels and groupingSets. The appendrel omissionis harmless, because in that case we also check is_safe_append_memberwhich will also reject such subqueries. The groupingSets omissionis a bug though, leading to assertion failures or planner errorssuch as "variable not found in subplan target lists".is_simple_subquery has access to none of the three variables usedin the correct tests, but its callers do, so I chose to have thempass down a bool corresponding to the OR of these conditions.(The need for duplicative conditions would be a maintenancehazard in actively-developed code, but I'm not too concernedabout it in branches that have only ~ 1 year to live.)Per bug #17614 from Wei Wei. Patch v10 and v11 only, since we have abetter answer to this in v12 and later (indeed, the faulty check inis_simple_subquery is gone entirely).Discussion:https://postgr.es/m/17614-8ec20c85bdecaa2a@postgresql.org1 parentd4adff0 commit19a00ea
File tree
3 files changed
+80
-20
lines changed- src
- backend/optimizer/prep
- test/regress
- expected
- sql
3 files changed
+80
-20
lines changedLines changed: 29 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
83 | 83 |
| |
84 | 84 |
| |
85 | 85 |
| |
| 86 | + | |
86 | 87 |
| |
87 | 88 |
| |
88 | 89 |
| |
| |||
691 | 692 |
| |
692 | 693 |
| |
693 | 694 |
| |
694 |
| - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
695 | 700 |
| |
696 | 701 |
| |
697 | 702 |
| |
| |||
955 | 960 |
| |
956 | 961 |
| |
957 | 962 |
| |
958 |
| - | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
959 | 968 |
| |
960 | 969 |
| |
961 | 970 |
| |
| |||
1023 | 1032 |
| |
1024 | 1033 |
| |
1025 | 1034 |
| |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
1026 | 1043 |
| |
1027 | 1044 |
| |
1028 | 1045 |
| |
| |||
1433 | 1450 |
| |
1434 | 1451 |
| |
1435 | 1452 |
| |
| 1453 | + | |
| 1454 | + | |
1436 | 1455 |
| |
1437 | 1456 |
| |
1438 | 1457 |
| |
1439 | 1458 |
| |
1440 | 1459 |
| |
| 1460 | + | |
1441 | 1461 |
| |
1442 | 1462 |
| |
1443 | 1463 |
| |
| |||
1489 | 1509 |
| |
1490 | 1510 |
| |
1491 | 1511 |
| |
1492 |
| - | |
| 1512 | + | |
1493 | 1513 |
| |
1494 | 1514 |
| |
1495 | 1515 |
| |
| |||
1504 | 1524 |
| |
1505 | 1525 |
| |
1506 | 1526 |
| |
1507 |
| - | |
1508 |
| - | |
1509 |
| - | |
| 1527 | + | |
| 1528 | + | |
1510 | 1529 |
| |
1511 | 1530 |
| |
1512 | 1531 |
| |
1513 | 1532 |
| |
1514 | 1533 |
| |
1515 | 1534 |
| |
1516 | 1535 |
| |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
1517 | 1539 |
| |
1518 | 1540 |
| |
1519 | 1541 |
| |
| |||
1522 | 1544 |
| |
1523 | 1545 |
| |
1524 | 1546 |
| |
1525 |
| - | |
| 1547 | + | |
1526 | 1548 |
| |
1527 | 1549 |
| |
1528 | 1550 |
| |
|
Lines changed: 44 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1677 | 1677 |
| |
1678 | 1678 |
| |
1679 | 1679 |
| |
1680 |
| - | |
1681 |
| - | |
1682 |
| - | |
1683 |
| - | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
1684 | 1684 |
| |
1685 |
| - | |
1686 |
| - | |
1687 |
| - | |
1688 |
| - | |
1689 |
| - | |
1690 |
| - | |
1691 | 1685 |
| |
1692 |
| - | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
1693 | 1691 |
| |
1694 |
| - | |
| 1692 | + | |
1695 | 1693 |
| |
1696 | 1694 |
| |
1697 | 1695 |
| |
1698 | 1696 |
| |
1699 |
| - | |
1700 | 1697 |
| |
| 1698 | + | |
1701 | 1699 |
| |
1702 | 1700 |
| |
1703 | 1701 |
| |
| |||
1723 | 1721 |
| |
1724 | 1722 |
| |
1725 | 1723 |
| |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
1726 | 1757 |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
477 | 477 |
| |
478 | 478 |
| |
479 | 479 |
| |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
480 | 487 |
|
0 commit comments
Comments
(0)