Commit 30c9450a authored by Sergei Petrunia's avatar Sergei Petrunia

More comments

parent e64b57a8
...@@ -6,6 +6,13 @@ ...@@ -6,6 +6,13 @@
class Window_spec; class Window_spec;
/*
ROW_NUMBER() OVER (...)
- This is a Window function (not just an aggregate)
- It can be computed by doing one pass over select output, provided
the output is sorted according to the window definition.
*/
class Item_sum_row_number: public Item_sum_int class Item_sum_row_number: public Item_sum_int
{ {
...@@ -31,12 +38,28 @@ class Item_sum_row_number: public Item_sum_int ...@@ -31,12 +38,28 @@ class Item_sum_row_number: public Item_sum_int
}; };
/*
RANK() OVER (...) Windowing function
- This is a Window function (not just an aggregate)
- It can be computed by doing one pass over select output, provided
the output is sorted according to the window definition.
*/
class Item_sum_rank: public Item_sum_int class Item_sum_rank: public Item_sum_int
{ {
longlong rank; longlong rank;
void clear() {} /*TODO: implementation is currently missing */
bool add() { return false; } void clear()
{
// This is called on next partition
}
bool add()
{
return false;
}
void update_field() {} void update_field() {}
public: public:
...@@ -55,10 +78,20 @@ class Item_sum_rank: public Item_sum_int ...@@ -55,10 +78,20 @@ class Item_sum_rank: public Item_sum_int
}; };
/*
RANK() OVER (...) Windowing function
- This is a Window function (not just an aggregate)
- It can be computed by doing one pass over select output, provided
the output is sorted according to the window definition.
*/
class Item_sum_dense_rank: public Item_sum_int class Item_sum_dense_rank: public Item_sum_int
{ {
longlong dense_rank; longlong dense_rank;
/* TODO: implementation is missing */
void clear() {} void clear() {}
bool add() { return false; } bool add() { return false; }
void update_field() {} void update_field() {}
...@@ -164,7 +197,7 @@ class Item_window_func : public Item_result_field ...@@ -164,7 +197,7 @@ class Item_window_func : public Item_result_field
enum Item::Type type() const { return Item::WINDOW_FUNC_ITEM; } enum Item::Type type() const { return Item::WINDOW_FUNC_ITEM; }
/* /*
TODO: Window functions are very special functions, so val_() methods have Window functions are very special functions, so val_() methods have
special meaning for them: special meaning for them:
- Phase#1: we run the join and put its result into temporary table. For - Phase#1: we run the join and put its result into temporary table. For
...@@ -179,6 +212,7 @@ class Item_window_func : public Item_result_field ...@@ -179,6 +212,7 @@ class Item_window_func : public Item_result_field
- Phase#3: the temporary table is read and passed to query output. - Phase#3: the temporary table is read and passed to query output.
However, Item_window_func still remains in the select list, so However, Item_window_func still remains in the select list, so
item_windowfunc->val_int() will be called. item_windowfunc->val_int() will be called.
During Phase#3, read_value_from_result_field= true.
*/ */
private: private:
bool read_value_from_result_field; bool read_value_from_result_field;
......
...@@ -299,7 +299,11 @@ bool JOIN::process_window_functions(List<Item> *curr_fields_list) ...@@ -299,7 +299,11 @@ bool JOIN::process_window_functions(List<Item> *curr_fields_list)
*/ */
item_win->advance_window(); item_win->advance_window();
/* Put the new value into temptable's field */ /*
Put the new value into temptable's field
TODO: Should this use item_win->update_field() call?
Regular aggegate function implementations seem to implement it.
*/
item_win->save_in_field(item_win->result_field, true); item_win->save_in_field(item_win->result_field, true);
err= tbl->file->ha_update_row(tbl->record[1], tbl->record[0]); err= tbl->file->ha_update_row(tbl->record[1], tbl->record[0]);
if (err && err != HA_ERR_RECORD_IS_THE_SAME) if (err && err != HA_ERR_RECORD_IS_THE_SAME)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment