forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc198048
Prevent join removal from removing the query's result relation.
This was not something that required consideration before MERGEwas invented; but MERGE builds a join tree that left-joins to theresult relation, meaning that remove_useless_joins will considerremoving it. That should generally be stopped by the query's useof output variables from the result relation. However, if theresult relation is inherited (e.g. a partitioned table) thenwe don't add any row identity variables to the query untilexpand_inherited_rtentry, which happens after join removal.This was exposed as of commit3c56904, which made it possibleto deduce that a partitioned table could contain at most one rowmatching a join key, enabling removal of the not-yet-expandedresult relation. Ooops.To fix, let's just teach join_is_removable that the query resultrel is never removable. It's a cheap enough test in any case,and it'll save some cycles that we'd otherwise expend in provingthat it's not removable, even in the cases we got right.Back-patch to v15 where MERGE was added. Although I think thecase cannot be reached in v15, this seems like cheap insurance.Per investigation of a report from Alexander Lakhin.Discussion:https://postgr.es/m/36bee393-b351-16ac-93b2-d46d83637e45@gmail.com1 parent658cbde commitc198048
File tree
3 files changed
+63
-0
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+63
-0
lines changedLines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
183 | 183 |
| |
184 | 184 |
| |
185 | 185 |
| |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
186 | 194 |
| |
187 | 195 |
| |
188 | 196 |
| |
|
Lines changed: 35 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1771 | 1771 |
| |
1772 | 1772 |
| |
1773 | 1773 |
| |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
1774 | 1809 |
| |
1775 | 1810 |
| |
1776 | 1811 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1116 | 1116 |
| |
1117 | 1117 |
| |
1118 | 1118 |
| |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
1119 | 1139 |
| |
1120 | 1140 |
| |
1121 | 1141 |
| |
|
0 commit comments
Comments
(0)