forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitaa8a2c3
committed
Fix generation of MergeAppend plans for optimized min/max on expressions.
Before jamming a desired targetlist into a plan node, one really ought tomake sure the plan node can handle projections, and insert a bufferingResult plan node if not. planagg.c forgot to do this, which is a hangoverfrom the days when it only dealt with IndexScan plan types. MergeAppenddoesn't project though, not to mention that it gets unhappy if you removeits possibly-resjunk sort columns. The code accidentally failed to failfor cases in which the min/max argument was a simple Var, because the newtargetlist would be equivalent to the original "flat" tlist anyway.For any more complex case, it's been broken since 9.1 where we introducedthe ability to optimize min/max using MergeAppend, as reported by RaphaelBauduin. Fix by duplicating the logic from grouping_planner that decideswhether we need a Result node.In 9.2 and 9.1, this requires back-porting the tlist_same_exprs() functionintroduced in commit4387cf9, else we'duselessly add a Result node in cases that worked before. It's rathertempting to back-patch that whole commit so that we can avoid extra Resultnodes in mainline cases too; but I'll refrain, since that code hasn'treally seen all that much field testing yet.1 parent74aea2a commitaa8a2c3
File tree
5 files changed
+124
-1
lines changed- src
- backend/optimizer
- plan
- util
- include/optimizer
- test/regress
- expected
- sql
5 files changed
+124
-1
lines changedLines changed: 22 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
| 41 | + | |
41 | 42 |
| |
42 | 43 |
| |
43 | 44 |
| |
| |||
525 | 526 |
| |
526 | 527 |
| |
527 | 528 |
| |
528 |
| - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
529 | 550 |
| |
530 | 551 |
| |
531 | 552 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
187 | 187 |
| |
188 | 188 |
| |
189 | 189 |
| |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
190 | 227 |
| |
191 | 228 |
| |
192 | 229 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 |
| |
30 | 33 |
| |
31 | 34 |
| |
|
Lines changed: 58 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1216 | 1216 |
| |
1217 | 1217 |
| |
1218 | 1218 |
| |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
1219 | 1241 |
| |
1220 | 1242 |
| |
1221 | 1243 |
| |
| |||
1249 | 1271 |
| |
1250 | 1272 |
| |
1251 | 1273 |
| |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
1252 | 1310 |
| |
1253 | 1311 |
| |
1254 | 1312 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
382 | 382 |
| |
383 | 383 |
| |
384 | 384 |
| |
| 385 | + | |
| 386 | + | |
385 | 387 |
| |
386 | 388 |
| |
387 | 389 |
| |
388 | 390 |
| |
389 | 391 |
| |
| 392 | + | |
| 393 | + | |
390 | 394 |
| |
391 | 395 |
| |
392 | 396 |
| |
|
0 commit comments
Comments
(0)