@@ -549,28 +549,41 @@ class Item_window_func : public Item_func_or_sum
549
549
Window functions are very special functions, so val_() methods have
550
550
special meaning for them:
551
551
552
- - Phase#1: we run the join and put its result into temporary table. For
553
- window functions, we write NULL (or some other) values as placeholders.
552
+ - Phase#1, "Initial" we run the join and put its result into temporary
553
+ table. For window functions, we write the default value (NULL?) as
554
+ a placeholder.
554
555
555
- - Phase#2: executor does the scan in {PARTITION, ORDER BY} order of this
556
- window function. It calls appropriate methods to inform the window
557
- function about rows entering/leaving the window.
558
- It calls window_func()->val_int() so that current window function value
556
+ - Phase#2: "Computation": executor does the scan in {PARTITION, ORDER BY}
557
+ order of this window function. It calls appropriate methods to inform
558
+ the window function about rows entering/leaving the window.
559
+ It calls window_func()->val_int() so that current window function value
559
560
can be saved and stored in the temp.table.
560
561
561
- - Phase#3: the temporary table is read and passed to query output.
562
- However, Item_window_func still remains in the select list, so
563
- item_windowfunc->val_int() will be called.
562
+ - Phase#3: "Retrieval" the temporary table is read and passed to query
563
+ output. However, Item_window_func still remains in the select list,
564
+ so item_windowfunc->val_int() will be called.
564
565
During Phase#3, read_value_from_result_field= true.
565
566
*/
566
- public:
567
- // TODO: how to reset this for subquery re-execution??
568
567
bool force_return_blank;
569
- private:
570
-
571
568
bool read_value_from_result_field;
572
569
573
570
public:
571
+ void set_phase_to_initial ()
572
+ {
573
+ force_return_blank= true ;
574
+ read_value_from_result_field= false ;
575
+ }
576
+ void set_phase_to_computation ()
577
+ {
578
+ force_return_blank= false ;
579
+ read_value_from_result_field= false ;
580
+ }
581
+ void set_phase_to_retrieval ()
582
+ {
583
+ force_return_blank= false ;
584
+ read_value_from_result_field= true ;
585
+ }
586
+
574
587
void set_read_value_from_result_field ()
575
588
{
576
589
read_value_from_result_field= true ;
0 commit comments