diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5bb2c4015ad..1aee4e7d553 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1922,7 +1922,7 @@ bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables) if (thd && check_stack_overrun(thd,buff)) return 0; // Fatal error if flag is set! - if (args[0]->fix_fields(thd,tables)) + if (args[0]->fix_fields(thd, tables, args)) return 1; maybe_null=args[0]->maybe_null; binary=args[0]->binary; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index c3a4526e052..7234a7a92ff 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -240,6 +240,7 @@ typedef struct st_select_lex_unit SELECT_LEX_UNIT; /* SELECT_LEX - store information of parsed SELECT_LEX statment */ +class JOIN; class st_select_lex: public st_select_lex_node { public: char *db, *db1, *table1, *db2, *table2; /* For outer join using .. */ @@ -251,12 +252,13 @@ public: List interval_list, use_index, *use_index_ptr, ignore_index, *ignore_index_ptr; List ftfunc_list; + JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */ uint in_sum_expr; bool create_refs, braces, /* SELECT ... UNION (SELECT ... ) <- this braces */ depended, /* depended from outer select subselect */ /* TRUE when having fix field called in processing of this SELECT */ - having_fix_field; + having_fix_field; void init_query(); void init_select(); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8dd611add86..76f78009e84 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -211,6 +211,7 @@ JOIN::prepare(TABLE_LIST *tables_init, proc_param= proc_param_init; tables_list= tables_init; select_lex= select; + select->join= this; union_part= (unit->first_select()->next_select() != 0); /* Check that all tables, fields, conds and order are ok */ @@ -974,6 +975,21 @@ JOIN::cleanup(THD *thd) delete select; delete_dynamic(&keyuse); delete procedure; + for (SELECT_LEX_UNIT *unit= select_lex->first_inner_unit(); + unit != 0; + unit= unit->next_unit()) + for (SELECT_LEX *sl= unit->first_select(); + sl != 0; + sl= sl->next_select()) + { + if (sl->join) + { + int err= sl->join->cleanup(thd); + if (err) + error= err; + sl->join= 0; + } + } return error; }