diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2016-09-21 16:45:36 +0200 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2016-09-24 15:12:34 +0200 |
commit | 872c0b4225150e909f44805bbbe645188a03aff8 (patch) | |
tree | bfbe79afb528c9e62d10dbb5ac1311bd274cefad /sql | |
parent | 74fa10645e6ea8688cff2b2d41a044f1b4442e47 (diff) | |
download | mariadb-git-872c0b4225150e909f44805bbbe645188a03aff8.tar.gz |
Allow first/last value functions to have frame definitions
Add a test case to check this behavior.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_windowfunc.h | 11 | ||||
-rw-r--r-- | sql/sql_window.cc | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h index ba5955084e2..cf484e3129d 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -657,10 +657,19 @@ public: case Item_sum::PERCENT_RANK_FUNC: case Item_sum::CUME_DIST_FUNC: case Item_sum::NTILE_FUNC: + return true; + default: + return false; + } + } + + bool requires_special_cursors() const + { + switch (window_func()->sum_func()) { case Item_sum::FIRST_VALUE_FUNC: case Item_sum::LAST_VALUE_FUNC: return true; - default: + default: return false; } } diff --git a/sql/sql_window.cc b/sql/sql_window.cc index 92ff71fcf38..8ec2b24d45d 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -2147,7 +2147,8 @@ void get_window_functions_required_cursors( functions can keep the default frame generating code, overwrite it or add to it. */ - if (item_win_func->is_frame_prohibited()) + if (item_win_func->is_frame_prohibited() || + item_win_func->requires_special_cursors()) { add_special_frame_cursors(thd, cursor_manager, item_win_func); cursor_managers->push_back(cursor_manager); |