summaryrefslogtreecommitdiff
path: root/sql/sql_window.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2016-09-22 22:18:45 +0200
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2016-09-24 15:12:34 +0200
commit6e4015727a60c5b98bdc9c4590adc687dacc4876 (patch)
treefbd402e6bdbbdaef80071473577aa7476494676f /sql/sql_window.cc
parent53cf265b3b6be949a19294661cb3e0ce25d9c712 (diff)
downloadmariadb-git-6e4015727a60c5b98bdc9c4590adc687dacc4876.tar.gz
Clean up nth_value
Implement nth_value correctly and add a test case for it.
Diffstat (limited to 'sql/sql_window.cc')
-rw-r--r--sql/sql_window.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 1a111e52c75..a2fada64a83 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -2205,10 +2205,14 @@ void add_special_frame_cursors(THD *thd, Cursor_manager *cursor_manager,
cursor_manager->add_cursor(bottom_bound);
cursor_manager->add_cursor(top_bound);
DBUG_ASSERT(item_sum->fixed);
+ Item *int_item= new (thd->mem_root) Item_int(thd, 1);
+ Item *offset_func= new (thd->mem_root)
+ Item_func_minus(thd, item_sum->get_arg(1),
+ int_item);
+ offset_func->fix_fields(thd, &offset_func);
fc= new Frame_positional_cursor(*top_bound,
*top_bound, *bottom_bound,
- *item_sum->get_arg(1),
- false);
+ *offset_func, false);
fc->add_sum_func(item_sum);
cursor_manager->add_cursor(fc);
break;