Commit 6399187e authored by Sergei Petrunia's avatar Sergei Petrunia

Added comments

parent 426cd232
...@@ -5,6 +5,12 @@ Item_window_func::fix_fields(THD *thd, Item **ref) ...@@ -5,6 +5,12 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
{ {
DBUG_ASSERT(fixed == 0); DBUG_ASSERT(fixed == 0);
/*
TODO: why the last parameter is 'ref' in this call? What if window_func
decides to substitute itself for something else and does *ref=.... ?
This will substitute *this (an Item_window_func object) with Item_sum
object. Is this the intent?
*/
if (window_func->fix_fields(thd, ref)) if (window_func->fix_fields(thd, ref))
return TRUE; return TRUE;
......
...@@ -157,6 +157,24 @@ class Item_window_func : public Item_result_field ...@@ -157,6 +157,24 @@ class Item_window_func : public Item_result_field
enum_field_types field_type() const { return window_func->field_type(); } enum_field_types field_type() const { return window_func->field_type(); }
/*
TODO: Window functions are very special functions, so val_() methods have
special meaning for them:
- Phase#1: we run the join and put its result into temporary table. For
window functions, we write NULL (or some other) values as placeholders.
- Phase#2: executor does the scan in {PARTITION, ORDER BY} order of this
window function. It calls appropriate methods to inform the window
function about rows entering/leaving the window.
It calls window_func->val_int() so that current window function value
can be saved and stored in the temp.table.
- Phase#3: the temporaty table is read and passed to query output. (Do
I understand correctly that Item_window_func::val_XXX won't be called
at all in this phase? Need to check)
*/
double val_real() { return window_func->val_real(); } double val_real() { return window_func->val_real(); }
longlong val_int() { return window_func->val_int(); } longlong val_int() { return window_func->val_int(); }
......
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