Commit a94f51a
committed
Fix unnecessary use of moving-aggregate mode with non-moving frame.
When a plain aggregate is used as a window function, and the window
frame start is specified as UNBOUNDED PRECEDING, the frame's head
cannot move so we do not need to use moving-aggregate mode. The check
for that was put into initialize_peragg(), failing to notice that
ExecInitWindowAgg() calls that function before it's filled in
winstate->frameOptions. Since makeNode() would have zeroed the field,
this didn't provoke uninitialized-value complaints, nor would the
erroneous decision have resulted in more than a little inefficiency.
Still, it's wrong, so move the initialization of
winstate->frameOptions earlier to make it work properly.
While here, also fix a thinko in a comment. Both errors crept in in
commit a9d9acb which introduced the moving-aggregate mode.
Spotted by Vallimaharajan G. Back-patch to all supported branches.
Discussion: https://postgr.es/m/18e7f2a5167.fe36253866818.977923893562469143@zohocorp.com1 parent f5d0e86 commit a94f51a
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2399 | 2399 | | |
2400 | 2400 | | |
2401 | 2401 | | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
2402 | 2405 | | |
2403 | 2406 | | |
2404 | 2407 | | |
| |||
2649 | 2652 | | |
2650 | 2653 | | |
2651 | 2654 | | |
2652 | | - | |
2653 | | - | |
2654 | | - | |
2655 | 2655 | | |
2656 | 2656 | | |
2657 | 2657 | | |
| |||
2802 | 2802 | | |
2803 | 2803 | | |
2804 | 2804 | | |
2805 | | - | |
| 2805 | + | |
2806 | 2806 | | |
2807 | 2807 | | |
2808 | 2808 | | |
| |||
0 commit comments