forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6e2c762
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 parentaad87e3 commit6e2c762
File tree
5 files changed
+123
-1
lines changed- src
- backend/optimizer
- plan
- util
- include/optimizer
- test/regress
- expected
- sql
5 files changed
+123
-1
lines changedLines changed: 22 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
| 40 | + | |
40 | 41 |
| |
41 | 42 |
| |
42 | 43 |
| |
| |||
521 | 522 |
| |
522 | 523 |
| |
523 | 524 |
| |
524 |
| - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
525 | 546 |
| |
526 | 547 |
| |
527 | 548 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
188 | 188 |
| |
189 | 189 |
| |
190 | 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 | + | |
| 227 | + | |
191 | 228 |
| |
192 | 229 |
| |
193 | 230 |
| |
|
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: 57 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1203 | 1203 |
| |
1204 | 1204 |
| |
1205 | 1205 |
| |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
1206 | 1228 |
| |
1207 | 1229 |
| |
1208 | 1230 |
| |
| |||
1236 | 1258 |
| |
1237 | 1259 |
| |
1238 | 1260 |
| |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
1239 | 1296 |
| |
1240 | 1297 |
| |
1241 | 1298 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
398 | 398 |
| |
399 | 399 |
| |
400 | 400 |
| |
| 401 | + | |
| 402 | + | |
401 | 403 |
| |
402 | 404 |
| |
403 | 405 |
| |
404 | 406 |
| |
405 | 407 |
| |
| 408 | + | |
| 409 | + | |
406 | 410 |
| |
407 | 411 |
| |
408 | 412 |
| |
|
0 commit comments
Comments
(0)