diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2016-09-20 20:44:49 +0200 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2016-09-24 15:12:34 +0200 |
commit | 9a5930bcdfc72f3b63569332205d8574a586247d (patch) | |
tree | 4150dfb558f0fb7a11bb1c5f01607c99d508ba4c /sql/item_windowfunc.cc | |
parent | e413c6e9e764469bc26ffd978e0fb6c84c4ff896 (diff) | |
download | mariadb-git-9a5930bcdfc72f3b63569332205d8574a586247d.tar.gz |
Implement first_value and last_value as window functions
Currently the implementation doesn't support removal, thus the
computation is performed by running over the window frame again.
Diffstat (limited to 'sql/item_windowfunc.cc')
-rw-r--r-- | sql/item_windowfunc.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc index c8ea979900c..5a7ee522d44 100644 --- a/sql/item_windowfunc.cc +++ b/sql/item_windowfunc.cc @@ -219,3 +219,26 @@ void Item_sum_percent_rank::setup_window_func(THD *thd, Window_spec *window_spec peer_tracker->init(); clear(); } + +bool Item_sum_first_value::add() +{ + if (value_added) + return false; + + /* TODO(cvicentiu) This is done like this due to how Item_sum_hybrid works. + For this usecase we can actually get rid of arg_cache. arg_cache is just + for running a comparison function. */ + value_added= true; + arg_cache->cache_value(); + value->store(arg_cache); + null_value= arg_cache->null_value; + return false; +} + +bool Item_sum_last_value::add() +{ + arg_cache->cache_value(); + value->store(arg_cache); + null_value= arg_cache->null_value; + return false; +} |