forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitbc5a08a

Richard Guo
Avoid NullTest deduction for clone clauses
In commitb262ad4, we introduced an optimization that reduces an ISNOT NULL qual on a column defined as NOT NULL to constant true, and anIS NULL qual on a NOT NULL column to constant false, provided we canprove that the input expression of the NullTest is not nullable by anyouter join. This deduction happens after we have generated multipleclones of the same qual condition to cope with commuted-left-joincases.However, performing the NullTest deduction for clone clauses can beunsafe, because we don't have a reliable way to determine if the inputexpression of a NullTest is non-nullable: nullingrel bits in cloneclauses may not reflect reality, so we dare not draw conclusions fromclones about whether Vars are guaranteed not-null.To fix, we check whether the given RestrictInfo is a clone clause inrestriction_is_always_true and restriction_is_always_false, and avoidperforming any reduction if it is.There are several ensuing plan changes in predicate.out, and we haveto modify the tests to ensure that they continue to test what they areintended to. Additionally, this fix causes the test case added inf00ab1f to no longer trigger the bug that commit fixed, so we alsoremove that test case.Back-patch to v17 where this bug crept in.Reported-by: Ronald Cruz <cruz@rentec.com>Diagnosed-by: Tom Lane <tgl@sss.pgh.pa.us>Author: Richard Guo <guofenglinux@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/f5320d3d-77af-4ce8-b9c3-4715ff33f213@rentec.comBackpatch-through: 171 parentd6dd2a0 commitbc5a08a
File tree
3 files changed
+187
-62
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+187
-62
lines changedLines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2740 | 2740 |
| |
2741 | 2741 |
| |
2742 | 2742 |
| |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
2743 | 2752 |
| |
2744 | 2753 |
| |
2745 | 2754 |
| |
| |||
2789 | 2798 |
| |
2790 | 2799 |
| |
2791 | 2800 |
| |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
2792 | 2810 |
| |
2793 | 2811 |
| |
2794 | 2812 |
| |
|
Lines changed: 123 additions & 52 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
100 |
| - | |
101 |
| - | |
102 |
| - | |
103 |
| - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
104 | 103 |
| |
105 | 104 |
| |
106 | 105 |
| |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
111 |
| - | |
| 106 | + | |
| 107 | + | |
112 | 108 |
| |
113 | 109 |
| |
114 | 110 |
| |
115 | 111 |
| |
116 | 112 |
| |
117 |
| - | |
| 113 | + | |
118 | 114 |
| |
119 | 115 |
| |
120 | 116 |
| |
121 | 117 |
| |
122 | 118 |
| |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
127 | 126 |
| |
128 | 127 |
| |
129 | 128 |
| |
130 |
| - | |
| 129 | + | |
131 | 130 |
| |
132 | 131 |
| |
133 | 132 |
| |
134 | 133 |
| |
135 | 134 |
| |
136 |
| - | |
137 |
| - | |
138 |
| - | |
139 |
| - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
140 | 138 |
| |
| 139 | + | |
141 | 140 |
| |
142 |
| - | |
143 |
| - | |
144 |
| - | |
145 |
| - | |
146 |
| - | |
147 |
| - | |
148 |
| - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
149 | 144 |
| |
150 | 145 |
| |
151 | 146 |
| |
| |||
172 | 167 |
| |
173 | 168 |
| |
174 | 169 |
| |
175 |
| - | |
176 |
| - | |
177 |
| - | |
178 |
| - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
179 | 173 |
| |
180 | 174 |
| |
181 | 175 |
| |
182 |
| - | |
183 |
| - | |
184 |
| - | |
185 |
| - | |
186 |
| - | |
| 176 | + | |
| 177 | + | |
187 | 178 |
| |
188 | 179 |
| |
189 | 180 |
| |
190 | 181 |
| |
191 | 182 |
| |
192 |
| - | |
| 183 | + | |
193 | 184 |
| |
194 | 185 |
| |
195 | 186 |
| |
196 | 187 |
| |
197 | 188 |
| |
198 |
| - | |
199 |
| - | |
200 |
| - | |
201 |
| - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
202 | 196 |
| |
203 | 197 |
| |
204 | 198 |
| |
205 |
| - | |
| 199 | + | |
206 | 200 |
| |
207 | 201 |
| |
208 | 202 |
| |
209 | 203 |
| |
210 | 204 |
| |
211 |
| - | |
212 |
| - | |
213 |
| - | |
214 |
| - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
215 | 208 |
| |
| 209 | + | |
216 | 210 |
| |
217 |
| - | |
218 |
| - | |
219 |
| - | |
220 |
| - | |
221 |
| - | |
222 |
| - | |
223 |
| - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
224 | 214 |
| |
225 | 215 |
| |
226 | 216 |
| |
| |||
290 | 280 |
| |
291 | 281 |
| |
292 | 282 |
| |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + |
Lines changed: 46 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
64 | 64 |
| |
65 | 65 |
| |
66 | 66 |
| |
67 |
| - | |
68 |
| - | |
| 67 | + | |
69 | 68 |
| |
70 | 69 |
| |
71 | 70 |
| |
72 | 71 |
| |
73 | 72 |
| |
74 |
| - | |
| 73 | + | |
75 | 74 |
| |
76 | 75 |
| |
77 | 76 |
| |
78 | 77 |
| |
79 | 78 |
| |
80 | 79 |
| |
81 |
| - | |
82 |
| - | |
| 80 | + | |
83 | 81 |
| |
84 | 82 |
| |
85 | 83 |
| |
| |||
95 | 93 |
| |
96 | 94 |
| |
97 | 95 |
| |
98 |
| - | |
99 |
| - | |
| 96 | + | |
100 | 97 |
| |
101 | 98 |
| |
102 | 99 |
| |
103 | 100 |
| |
104 | 101 |
| |
105 |
| - | |
| 102 | + | |
106 | 103 |
| |
107 | 104 |
| |
108 | 105 |
| |
109 | 106 |
| |
110 | 107 |
| |
111 | 108 |
| |
112 |
| - | |
113 |
| - | |
| 109 | + | |
114 | 110 |
| |
115 | 111 |
| |
116 | 112 |
| |
| |||
147 | 143 |
| |
148 | 144 |
| |
149 | 145 |
| |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + |
0 commit comments
Comments
(0)