Skip to content

Commit 872c0b4

Browse files
committed
Allow first/last value functions to have frame definitions
Add a test case to check this behavior.
1 parent 74fa106 commit 872c0b4

File tree

3 files changed

+12
-77
lines changed

3 files changed

+12
-77
lines changed

mysql-test/r/win_first_last_value.result

Lines changed: 0 additions & 75 deletions
This file was deleted.

sql/item_windowfunc.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,19 @@ class Item_window_func : public Item_func_or_sum
657657
case Item_sum::PERCENT_RANK_FUNC:
658658
case Item_sum::CUME_DIST_FUNC:
659659
case Item_sum::NTILE_FUNC:
660+
return true;
661+
default:
662+
return false;
663+
}
664+
}
665+
666+
bool requires_special_cursors() const
667+
{
668+
switch (window_func()->sum_func()) {
660669
case Item_sum::FIRST_VALUE_FUNC:
661670
case Item_sum::LAST_VALUE_FUNC:
662671
return true;
663-
default:
672+
default:
664673
return false;
665674
}
666675
}

sql/sql_window.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,8 @@ void get_window_functions_required_cursors(
21472147
functions can keep the default frame generating code, overwrite it or
21482148
add to it.
21492149
*/
2150-
if (item_win_func->is_frame_prohibited())
2150+
if (item_win_func->is_frame_prohibited() ||
2151+
item_win_func->requires_special_cursors())
21512152
{
21522153
add_special_frame_cursors(thd, cursor_manager, item_win_func);
21532154
cursor_managers->push_back(cursor_manager);

0 commit comments

Comments
 (0)