diff --git a/sql/item_func.h b/sql/item_func.h index 6a4a9fa5dae..e774d9c53bd 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1962,6 +1962,7 @@ class Item_func_rand :public Item_real_func bool first_eval; // TRUE if val_real() is called 1st time bool check_arguments() const { return check_argument_types_can_return_int(0, arg_count); } + void seed_random (Item * val); public: Item_func_rand(THD *thd, Item *a): Item_real_func(thd, a), rand(0), first_eval(TRUE) {} @@ -1974,12 +1975,11 @@ public: void cleanup() { first_eval= TRUE; Item_real_func::cleanup(); } bool check_vcol_func_processor(void *arg) { - return mark_unsupported_function(func_name(), "()", arg, VCOL_NON_DETERMINISTIC); + return mark_unsupported_function(func_name(), "()", arg, + VCOL_NON_DETERMINISTIC); } Item *get_copy(THD *thd) { return get_item_copy(thd, this); } -private: - void seed_random (Item * val); }; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 9620b0d0961..ce3bf902931 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -10279,7 +10279,7 @@ bool LEX::sp_proc_stmt_statement_finalize(THD *thd, bool no_lookahead) It is done by transformer. The extracted condition is saved in cond_pushed_into_where of this select. - cond can remain un empty after the extraction of the condition that can be + COND can remain not empty after the extraction of the conditions that can be pushed into WHERE. It is saved in remaining_cond. @note diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 861eb614592..10b71781ce4 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1113,7 +1113,7 @@ public: */ LEX *parent_lex; enum olap_type olap; - /* FROM clause - points to the beginning of the TABLE_LIST::next_local list. */ + /* FROM clause - points to the beginning of the TABLE_LIST::next_local list */ SQL_I_List table_list; /* @@ -1129,8 +1129,8 @@ public: List pre_fix; /* above list before fix_fields */ bool is_item_list_lookup; /* - Usualy it is pointer to ftfunc_list_alloc, but in union used to create fake - select_lex for calling mysql_select under results of union + Usually it is pointer to ftfunc_list_alloc, but in union used to create + fake select_lex for calling mysql_select under results of union */ List *ftfunc_list; List ftfunc_list_alloc; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a18dc0d3d37..a2cc265ec5b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3747,14 +3747,16 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List *table_fields, tab->tmp_table_param->skip_create_table= true; TABLE* table= create_tmp_table(thd, tab->tmp_table_param, *table_fields, table_group, distinct, - save_sum_fields, select_options, table_rows_limit, + save_sum_fields, select_options, + table_rows_limit, &empty_clex_str, true, keep_row_order); if (!table) DBUG_RETURN(true); tmp_table_param.using_outer_summary_function= tab->tmp_table_param->using_outer_summary_function; tab->join= this; - DBUG_ASSERT(tab > tab->join->join_tab || !top_join_tab_count || !tables_list); + DBUG_ASSERT(tab > tab->join->join_tab || !top_join_tab_count || + !tables_list); if (tab > join_tab) (tab - 1)->next_select= sub_select_postjoin_aggr; if (!(tab->aggr= new (thd->mem_root) AGGR_OP(tab))) @@ -4260,8 +4262,9 @@ void JOIN::exec_inner() /* Enable LIMIT ROWS EXAMINED during query execution if: (1) This JOIN is the outermost query (not a subquery or derived table) - This ensures that the limit is enabled when actual execution begins, and - not if a subquery is evaluated during optimization of the outer query. + This ensures that the limit is enabled when actual execution begins, + and not if a subquery is evaluated during optimization of the outer + query. (2) This JOIN is not the result of a UNION. In this case do not apply the limit in order to produce the partial query result stored in the UNION temp table. @@ -14091,7 +14094,7 @@ static void update_depend_map_for_order(JOIN *join, ORDER *order) /** - Remove all constants and check if ORDER only contains simple + Remove all constants from ORDER and check if ORDER only contains simple expressions. We also remove all duplicate expressions, keeping only the first one. @@ -16665,13 +16668,13 @@ static uint reset_nj_counters(JOIN *join, List *join_list) @verbatim IMPLEMENTATION LIMITATIONS ON JOIN ORDER - The nested [outer] joins executioner algorithm imposes these limitations - on join order: + The nested [outer] joins executioner algorithm imposes these + limitations on join order: 1. "Outer tables first" - any "outer" table must be before any corresponding "inner" table. - 2. "No interleaving" - tables inside a nested join must form a continuous - sequence in join order (i.e. the sequence must not be interrupted by - tables that are outside of this nested join). + 2. "No interleaving" - tables inside a nested join must form a + continuous sequence in join order (i.e. the sequence must not be + interrupted by tables that are outside of this nested join). #1 is checked elsewhere, this function checks #2 provided that #1 has been already checked. @@ -16683,34 +16686,36 @@ static uint reset_nj_counters(JOIN *join, List *join_list) The join order "t1 t2 t0 t3" is invalid: - table t0 is outside of the nested join, so WHERE condition for t0 is - attached directly to t0 (without triggers, and it may be used to access - t0). Applying WHERE(t0) to (t2,t0,t3) record is invalid as we may miss - combinations of (t1, t2, t3) that satisfy condition cond1, and produce a - null-complemented (t1, t2.NULLs, t3.NULLs) row, which should not have - been produced. + table t0 is outside of the nested join, so WHERE condition + for t0 is attached directly to t0 (without triggers, and it + may be used to access t0). Applying WHERE(t0) to (t2,t0,t3) + record is invalid as we may miss combinations of (t1, t2, t3) + that satisfy condition cond1, and produce a null-complemented + (t1, t2.NULLs, t3.NULLs) row, which should not have been + produced. If table t0 is not between t2 and t3, the problem doesn't exist: - If t0 is located after (t2,t3), WHERE(t0) is applied after nested join - processing has finished. - If t0 is located before (t2,t3), predicates like WHERE_cond(t0, t2) are - wrapped into condition triggers, which takes care of correct nested - join processing. + If t0 is located after (t2,t3), WHERE(t0) is applied after nested + join processing has finished. + If t0 is located before (t2,t3), predicates like WHERE_cond(t0, t2) + are wrapped into condition triggers, which takes care of correct + nested join processing. HOW IT IS IMPLEMENTED The limitations on join order can be rephrased as follows: for valid join order one must be able to: 1. write down the used tables in the join order on one line. - 2. for each nested join, put one '(' and one ')' on the said line + 2. for each nested join, put one '(' and one ')' on the said line 3. write "LEFT JOIN" and "ON (...)" where appropriate 4. get a query equivalent to the query we're trying to execute. Calls to check_interleaving_with_nj() are equivalent to writing the above described line from left to right. - A single check_interleaving_with_nj(A,B) call is equivalent to writing - table B and appropriate brackets on condition that table A and - appropriate brackets is the last what was written. Graphically the - transition is as follows: + + A single check_interleaving_with_nj(A,B) call is equivalent + to writing table B and appropriate brackets on condition that + table A and appropriate brackets is the last what was + written. Graphically the transition is as follows: +---- current position | @@ -21896,8 +21901,8 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), /* @brief - Perform a GROUP BY operation over a stream of rows ordered by their group. The - result is sent into join->result. + Perform a GROUP BY operation over a stream of rows ordered by their group. + The result is sent into join->result. @detail Also applies HAVING, etc. @@ -22177,7 +22182,9 @@ end: } -/** Like end_update, but this is done with unique constraints instead of keys. */ +/** + Like end_update, but this is done with unique constraints instead of keys. +*/ static enum_nested_loop_state end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),