forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1fe5a34
committed
Fix possible crash during WindowAgg evaluation
When short-circuiting WindowAgg node evaluation on the top-levelWindowAgg node using quals on monotonic window functions, because theWindowAgg run condition can mean there's no need to evaluate subsequentwindow function results in the same partition once the run conditionbecomes false, it was possible that the executor would use stale resultsfrom the previous invocation of the window function in some cases.A fix for this was partially done by a5832722, but that commit onlyfixed the issue for non-top-level WindowAgg nodes. I mistakenly thoughtthat the top-level WindowAgg didn't have this issue, but Jayesh's examplecase clearly shows that's incorrect. At the time, I also thought thatthis only affected 32-bit systems as all window functions which thensupported run conditions returned BIGINT, however, that's wrong asExecProject is still called and that could cause evaluation of any otherwindow function belonging to the same WindowAgg node, one of which mayreturn a byref type.The only queries affected by this are WindowAggs with a "Run Condition"which contains at least one window function with a byref result type,such as lead() or lag() on a byref column. The window clause must alsocontain a PARTITION BY clause (without a PARTITION BY, execution of theWindowAgg stops immediately when the run condition becomes false andthere's no risk of using the stale results).Reported-by: Jayesh DehankarDiscussion:https://postgr.es/m/193261e2c4d.3dd3cd7c1842.871636075166132237@zohocorp.comBackpatch-through: 15, where WindowAgg run conditions were added1 parent3f9b962 commit1fe5a34
File tree
3 files changed
+34
-18
lines changed- src
- backend/executor
- test/regress
- expected
- sql
3 files changed
+34
-18
lines changedLines changed: 17 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2353 | 2353 |
| |
2354 | 2354 |
| |
2355 | 2355 |
| |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
2356 | 2373 |
| |
2357 | 2374 |
| |
2358 | 2375 |
| |
| |||
2367 | 2384 |
| |
2368 | 2385 |
| |
2369 | 2386 |
| |
2370 |
| - | |
2371 |
| - | |
2372 |
| - | |
2373 |
| - | |
2374 |
| - | |
2375 |
| - | |
2376 |
| - | |
2377 |
| - | |
2378 |
| - | |
2379 |
| - | |
2380 |
| - | |
2381 |
| - | |
2382 |
| - | |
2383 |
| - | |
2384 |
| - | |
2385 |
| - | |
2386 |
| - | |
2387 |
| - | |
2388 | 2387 |
| |
2389 | 2388 |
| |
2390 | 2389 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4136 | 4136 |
| |
4137 | 4137 |
| |
4138 | 4138 |
| |
| 4139 | + | |
| 4140 | + | |
| 4141 | + | |
| 4142 | + | |
| 4143 | + | |
| 4144 | + | |
| 4145 | + | |
| 4146 | + | |
| 4147 | + | |
| 4148 | + | |
4139 | 4149 |
| |
4140 | 4150 |
| |
4141 | 4151 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1345 | 1345 |
| |
1346 | 1346 |
| |
1347 | 1347 |
| |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
1348 | 1355 |
| |
1349 | 1356 |
| |
1350 | 1357 |
| |
|
0 commit comments
Comments
(0)