forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3e9abd2
committed
Teach remove_unused_subquery_outputs about window run conditions
9d9c02c added code to allow the executor to take shortcuts when qualson monotonic window functions guaranteed that once the qual became falseit could never become true again. When possible, baserestrictinfo qualsare converted to become these quals, which we call run conditions.Unfortunately, in9d9c02c, I forgot to updateremove_unused_subquery_outputs to teach it about these run conditions.This could cause a WindowFunc column which was unused in the target listbut referenced by an upper-level WHERE clause to be removed from thesubquery when the qual in the WHERE clause was converted into a window runcondition. Because of this, the entire WindowClause would be removed fromthe query resulting in additional rows making it into the resultset whenthey should have been filtered out by the WHERE clause.Here we fix this by recording which target list items in the subquery haverun conditions. That gets passed along to remove_unused_subquery_outputsto tell it not to remove these items from the target list.Bug: #17495Reported-by: Jeremy EvansReviewed-by: Richard GuoDiscussion:https://postgr.es/m/17495-7ffe2fa0b261b9fa@postgresql.org1 parent2b65de7 commit3e9abd2
File tree
4 files changed
+69
-11
lines changed- src
- backend
- optimizer/path
- parser
- test/regress
- expected
- sql
4 files changed
+69
-11
lines changedLines changed: 39 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
142 | 142 |
| |
143 | 143 |
| |
144 | 144 |
| |
145 |
| - | |
| 145 | + | |
| 146 | + | |
146 | 147 |
| |
147 | 148 |
| |
148 | 149 |
| |
| |||
2177 | 2178 |
| |
2178 | 2179 |
| |
2179 | 2180 |
| |
2180 |
| - | |
| 2181 | + | |
| 2182 | + | |
2181 | 2183 |
| |
2182 | 2184 |
| |
2183 | 2185 |
| |
2184 | 2186 |
| |
2185 | 2187 |
| |
2186 | 2188 |
| |
2187 |
| - | |
| 2189 | + | |
| 2190 | + | |
2188 | 2191 |
| |
2189 | 2192 |
| |
2190 | 2193 |
| |
| |||
2356 | 2359 |
| |
2357 | 2360 |
| |
2358 | 2361 |
| |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
2359 | 2365 |
| |
2360 | 2366 |
| |
2361 | 2367 |
| |
| |||
2369 | 2375 |
| |
2370 | 2376 |
| |
2371 | 2377 |
| |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
2372 | 2382 |
| |
2373 | 2383 |
| |
2374 | 2384 |
| |
2375 | 2385 |
| |
2376 | 2386 |
| |
2377 | 2387 |
| |
2378 |
| - | |
| 2388 | + | |
2379 | 2389 |
| |
2380 | 2390 |
| |
2381 | 2391 |
| |
| |||
2403 | 2413 |
| |
2404 | 2414 |
| |
2405 | 2415 |
| |
2406 |
| - | |
| 2416 | + | |
| 2417 | + | |
2407 | 2418 |
| |
2408 | 2419 |
| |
2409 | 2420 |
| |
| |||
2415 | 2426 |
| |
2416 | 2427 |
| |
2417 | 2428 |
| |
2418 |
| - | |
| 2429 | + | |
| 2430 | + | |
2419 | 2431 |
| |
2420 | 2432 |
| |
2421 | 2433 |
| |
| |||
2444 | 2456 |
| |
2445 | 2457 |
| |
2446 | 2458 |
| |
| 2459 | + | |
2447 | 2460 |
| |
2448 | 2461 |
| |
2449 | 2462 |
| |
| |||
2526 | 2539 |
| |
2527 | 2540 |
| |
2528 | 2541 |
| |
2529 |
| - | |
| 2542 | + | |
| 2543 | + | |
2530 | 2544 |
| |
2531 | 2545 |
| |
2532 | 2546 |
| |
| |||
2545 | 2559 |
| |
2546 | 2560 |
| |
2547 | 2561 |
| |
2548 |
| - | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
2549 | 2565 |
| |
2550 |
| - | |
| 2566 | + | |
2551 | 2567 |
| |
2552 | 2568 |
| |
2553 | 2569 |
| |
| |||
3945 | 3961 |
| |
3946 | 3962 |
| |
3947 | 3963 |
| |
| 3964 | + | |
| 3965 | + | |
| 3966 | + | |
| 3967 | + | |
| 3968 | + | |
3948 | 3969 |
| |
3949 | 3970 |
| |
3950 | 3971 |
| |
3951 | 3972 |
| |
3952 | 3973 |
| |
3953 |
| - | |
| 3974 | + | |
| 3975 | + | |
3954 | 3976 |
| |
3955 |
| - | |
| 3977 | + | |
3956 | 3978 |
| |
3957 | 3979 |
| |
| 3980 | + | |
| 3981 | + | |
| 3982 | + | |
| 3983 | + | |
| 3984 | + | |
| 3985 | + | |
3958 | 3986 |
| |
3959 | 3987 |
| |
3960 | 3988 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2831 | 2831 |
| |
2832 | 2832 |
| |
2833 | 2833 |
| |
| 2834 | + | |
2834 | 2835 |
| |
2835 | 2836 |
| |
2836 | 2837 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3589 | 3589 |
| |
3590 | 3590 |
| |
3591 | 3591 |
| |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
3592 | 3611 |
| |
3593 | 3612 |
| |
3594 | 3613 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1121 | 1121 |
| |
1122 | 1122 |
| |
1123 | 1123 |
| |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
1124 | 1134 |
| |
1125 | 1135 |
| |
1126 | 1136 |
| |
|
0 commit comments
Comments
(0)