Commit 9d0fbcc4 authored by Monty's avatar Monty Committed by Sergei Petrunia

Improve comments in the optimizer

parent 6252a281
......@@ -26818,6 +26818,17 @@ change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array,
for (uint i= 0; (item= it++); i++)
{
Field *field;
/*
SUM_FUNC_ITEM will be replaced by the calculated value which is
stored in the temporary table.
The first part of the following test is for items that are expressions
with SUM_FUNC_ITEMS, like 'sum(a)+1'. In this case we keep the original
item, which contain an Item_ref that points to the SUM_FUNC_ITEM that
will be replaced with a pointer to the calculated value.
The second test is for window functions. Window functions contains
only pointers to Item_refs, which will be adjusted to point to the
temporary table.
*/
enum Item::Type item_type= item->type();
if ((item->with_sum_func() && item_type != Item::SUM_FUNC_ITEM) ||
item->with_window_func())
......
......@@ -423,6 +423,16 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd)
#define CMP_GT_C 1 // Greater than and compatible
#define CMP_GT 2 // Greater then
/*
This function is used for sorting ORDER/PARTITION BY clauses of window
functions and so must implement an order relation on ORDER BY clauses"
It is called by a sorting function.
The function return's CMP_EQ (=0) if the values are identical.
If not equal, it returns a stable value < or > than 0.
*/
static
int compare_order_elements(ORDER *ord1, int weight1,
ORDER *ord2, int weight2)
......
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