@@ -756,12 +756,11 @@ JOIN::prepare(Item ***rref_pointer_array,
756756 }
757757
758758 table_count= select_lex->leaf_tables.elements;
759-
759+
760760 TABLE_LIST *tbl;
761761 List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
762762 while ((tbl= li++))
763763 {
764- //table_count++; /* Count the number of tables in the join. */
765764 /*
766765 If the query uses implicit grouping where the select list contains both
767766 aggregate functions and non-aggregate fields, any non-aggregated field
@@ -805,8 +804,9 @@ JOIN::prepare(Item ***rref_pointer_array,
805804 thd->lex->allow_sum_func|= (nesting_map)1 << select_lex_arg->nest_level;
806805 select_lex->having_fix_field= 1;
807806 /*
808- Wrap alone field in HAVING clause in case it will be outer field of subquery
809- which need persistent pointer on it, but having could be changed by optimizer
807+ Wrap alone field in HAVING clause in case it will be outer field
808+ of subquery which need persistent pointer on it, but having
809+ could be changed by optimizer
810810 */
811811 if (having->type() == Item::REF_ITEM &&
812812 ((Item_ref *)having)->ref_type() == Item_ref::REF)
@@ -1099,8 +1099,8 @@ JOIN::optimize_inner()
10991099 before 'optimize' from upper query 'optimize' to allow semijoin
11001100 conversion happened (which done in the same way.
11011101 */
1102- if(select_lex->first_cond_optimization &&
1103- conds && conds->walk(&Item::exists2in_processor, 0, (uchar *)thd))
1102+ if (select_lex->first_cond_optimization &&
1103+ conds && conds->walk(&Item::exists2in_processor, 0, (uchar *)thd))
11041104 DBUG_RETURN(1);
11051105 /*
11061106TODO: make view to decide if it is possible to write to WHERE directly or make Semi-Joins able to process ON condition if it is possible
@@ -2536,9 +2536,10 @@ void JOIN::exec_inner()
25362536 }
25372537
25382538 /*
2539- Evaluate all constant expressions with subqueries in the ORDER/GROUP clauses
2540- to make sure that all subqueries return a single row. The evaluation itself
2541- will trigger an error if that is not the case.
2539+ Evaluate all constant expressions with subqueries in the
2540+ ORDER/GROUP clauses to make sure that all subqueries return a
2541+ single row. The evaluation itself will trigger an error if that is
2542+ not the case.
25422543 */
25432544 if (exec_const_order_group_cond.elements &&
25442545 !(select_options & SELECT_DESCRIBE))
@@ -2763,7 +2764,6 @@ void JOIN::exec_inner()
27632764(curr_join->tmp_all_fields1.elements-
27642765 curr_join->tmp_fields_list1.elements);
27652766
2766-
27672767 if (exec_tmp_table2)
27682768curr_tmp_table= exec_tmp_table2;
27692769 else
@@ -2878,7 +2878,6 @@ void JOIN::exec_inner()
28782878 if (curr_tmp_table->distinct)
28792879 curr_join->select_distinct=0; /* Each row is unique */
28802880
2881-
28822881 curr_join->join_free(); /* Free quick selects */
28832882
28842883 if (curr_join->select_distinct && ! curr_join->group_list)
@@ -11880,7 +11879,6 @@ void JOIN::cleanup(bool full)
1188011879 }
1188111880 }
1188211881 cleaned= true;
11883-
1188411882 }
1188511883 else
1188611884 {
@@ -16071,11 +16069,15 @@ void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps)
1607116069 @param param a description used as input to create the table
1607216070 @param fields list of items that will be used to define
1607316071 column types of the table (also see NOTES)
16074- @param group TODO document
16072+ @param group Create an unique key over all group by fields.
16073+ This is used to retrive the row during
16074+ end_write_group() and update them.
1607516075 @param distinct should table rows be distinct
1607616076 @param save_sum_fields see NOTES
16077- @param select_options
16078- @param rows_limit
16077+ @param select_options Optiions for how the select is run.
16078+ See sql_priv.h for a list of options.
16079+ @param rows_limit Maximum number of rows to insert into the
16080+ temporary table
1607916081 @param table_alias possible name of the temporary table that can
1608016082 be used for name resolving; can be "".
1608116083*/
@@ -16375,9 +16377,9 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
1637516377 /*
1637616378 If item->marker == 4 then we force create_tmp_field
1637716379 to create a 64-bit longs for BIT fields because HEAP
16378- tables can't index BIT fields directly. We do the same
16379- for distinct, as we want the distinct index to be
16380- usable in this case too.
16380+ tables can't index BIT fields directly. We do the
16381+ same for distinct, as we want the distinct index
16382+ to be usable in this case too.
1638116383 */
1638216384 item->marker == 4 || param->bit_fields_as_long,
1638316385 force_copy_fields,
@@ -16397,16 +16399,19 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
1639716399 created temporary table is not to be used for subquery
1639816400 materialization.
1639916401
16400- The reason is that for subqueries that require materialization as part
16401- of their plan, we create the 'external' temporary table needed for IN
16402- execution, after the 'internal' temporary table needed for grouping.
16403- Since both the external and the internal temporary tables are created
16404- for the same list of SELECT fields of the subquery, setting
16405- 'result_field' for each invocation of create_tmp_table overrides the
16406- previous value of 'result_field'.
16407-
16408- The condition below prevents the creation of the external temp table
16409- to override the 'result_field' that was set for the internal temp table.
16402+ The reason is that for subqueries that require
16403+ materialization as part of their plan, we create the
16404+ 'external' temporary table needed for IN execution, after
16405+ the 'internal' temporary table needed for grouping. Since
16406+ both the external and the internal temporary tables are
16407+ created for the same list of SELECT fields of the subquery,
16408+ setting 'result_field' for each invocation of
16409+ create_tmp_table overrides the previous value of
16410+ 'result_field'.
16411+
16412+ The condition below prevents the creation of the external
16413+ temp table to override the 'result_field' that was set for
16414+ the internal temp table.
1641016415 */
1641116416 if (!agg_item->result_field || !param->materialized_subquery)
1641216417 agg_item->result_field= new_field;
@@ -17710,6 +17715,7 @@ Next_select_func setup_end_select_func(JOIN *join)
1771017715 @retval
1771117716 -1 if error should be sent
1771217717*/
17718+
1771317719static int
1771417720do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
1771517721{
@@ -17877,12 +17883,14 @@ int rr_sequential_and_unpack(READ_RECORD *info)
1787717883
1787817884
1787917885/*
17880- Fill the join buffer with partial records, retrieve all full matches for them
17886+ Fill the join buffer with partial records, retrieve all full matches for
17887+ them
1788117888
1788217889 SYNOPSIS
1788317890 sub_select_cache()
17884- join pointer to the structure providing all context info for the query
17885- join_tab the first next table of the execution plan to be retrieved
17891+ join pointer to the structure providing all context info for the
17892+ query
17893+ join_tab the first next table of the execution plan to be retrieved
1788617894 end_records true when we need to perform final steps of the retrieval
1788717895
1788817896 DESCRIPTION
@@ -21059,8 +21067,9 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
2105921067 if (join->pre_sort_join_tab)
2106021068 {
2106121069 /*
21062- we've already been in this function, and stashed away the original access
21063- method in join->pre_sort_join_tab, restore it now.
21070+ we've already been in this function, and stashed away the
21071+ original access method in join->pre_sort_join_tab, restore it
21072+ now.
2106421073 */
2106521074
2106621075 /* First, restore state of the handler */
@@ -22795,11 +22804,11 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
2279522804 if (!suv || !new_field)
2279622805 DBUG_RETURN(true); // Fatal error
2279722806 /*
22798- We are replacing the argument of Item_func_set_user_var
22799- after its value has been read. The argument's null_value
22800- should be set by now, so we must set it explicitly for the
22801- replacement argument since the null_value may be read
22802- without any preceding call to val_*().
22807+ We are replacing the argument of Item_func_set_user_var after
22808+ its value has been read. The argument's null_value should be
22809+ set by now, so we must set it explicitly for the replacement
22810+ argument since the null_value may be read without any
22811+ preceeding call to val_*().
2280322812 */
2280422813 new_field->update_null_value();
2280522814 List<Item> list;
0 commit comments