diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 5105eb9279d..c33042e11ab 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -449,17 +449,19 @@ public: void update_used_tables() { if (!args[0]->maybe_null) - used_tables_cache=0; /* is always false */ + { + used_tables_cache= 0; /* is always false */ + cached_value= (longlong) 0; + } else { args[0]->update_used_tables(); - used_tables_cache=args[0]->used_tables(); - } - if (!used_tables_cache) - { - /* Remember if the value is always NULL or never NULL */ - args[0]->val(); - cached_value= args[0]->null_value ? (longlong) 1 : (longlong) 0; + if (!(used_tables_cache=args[0]->used_tables())) + { + /* Remember if the value is always NULL or never NULL */ + args[0]->val(); + cached_value= args[0]->null_value ? (longlong) 1 : (longlong) 0; + } } } optimize_type select_optimize() const { return OPTIMIZE_NULL; } diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 457356d4253..6227b1251db 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -58,6 +58,7 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, if ((*param->item)->type() != Item::INT_ITEM || (*param->item)->val() < 0) { + delete pc; net_printf(&thd->net, ER_WRONG_PARAMETERS_TO_PROCEDURE, proc_name); return 0; } @@ -65,6 +66,7 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, param = param->next; if (param->next) // no third parameter possible { + delete pc; net_printf(&thd->net, ER_WRONG_PARAMCOUNT_TO_PROCEDURE, proc_name); return 0; } @@ -72,6 +74,7 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, if ((*param->item)->type() != Item::INT_ITEM || (*param->item)->val() < 0) { + delete pc; net_printf(&thd->net, ER_WRONG_PARAMETERS_TO_PROCEDURE, proc_name); return 0; } @@ -80,6 +83,7 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, else if ((*param->item)->type() != Item::INT_ITEM || (*param->item)->val() < 0) { + delete pc; net_printf(&thd->net, ER_WRONG_PARAMETERS_TO_PROCEDURE, proc_name); return 0; } diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index ce5c0af6a96..c826b69e53c 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -288,13 +288,14 @@ protected: public: uint max_tree_elements, max_treemem; - analyse(select_result *res) :Procedure(res, PROC_NO_SORT), rows(0), - output_str_length(0) {} + analyse(select_result *res) :Procedure(res, PROC_NO_SORT), f_info(0), + rows(0), output_str_length(0) {} ~analyse() - { - for (field_info **f=f_info; f != f_end; f++) - delete (*f); + { + if (f_info) + for (field_info **f=f_info; f != f_end; f++) + delete (*f); } virtual void add() {} virtual bool change_columns(List &fields);