Hi,all David Rowley <[email protected]> 于2026年1月25日周日 15:05写道: > > On Sun, 25 Jan 2026 at 17:09, Meng Zhang <[email protected]> wrote: > > The deduplication logic won't cause an error when the result of this > > function is only used in `select_active_windows`. > > But when the result is used in `optimize_window_clauses`, it will cause the > > `winref` field of a certain window function to not be modified in the new > > window. > > Thanks for the report. I'll have a look. > > David > > I did some analysis, and I found this issue was introduced by this commit ed1a88d: Allow window functions to adjust their frameOptions
In optimize_window_clauses(), the list wc->winref = 2 was set to NIL, so "window 2" would not be in the activewindow lists. We only have one windowagg node, in ExecEndWindowAgg(), when we process the second "ROW_NUMBER() OVER window2" which its winref was still 2 because in find_window_functions_walker(), it was skipped due to duplicates. The attached patch seems workable. But I have one question. If we implement the attached patch, would it introduce redundant computation? Maybe optimize_window_clauses() would optimize the repeated computation. I don't understand this much. -- Thanks, Tender Wang
