From 76bf7d2224287b40ecfd2bac62b2dd45561affb1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Nov 2003 12:18:13 +0200 Subject: Added missing SSL library (Should be in source distribution) Fixed compiler warnings (a lot of hidden variables detected by the Forte compiler) Added a lot of 'version_xxx' strings to 'show variables' Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) Fixed problem with printing sub selects to debug log Docs/mysqld_error.txt: Updated error messages Makefile.am: Added missing SSL library (Should be in source distribution) configure.in: Added missing SSL library include/sql_common.h: Move duplicated prototypes innobase/os/os0file.c: Added comment for line that could be removed innobase/srv/srv0srv.c: Added comment for line that could be removed innobase/srv/srv0start.c: Added comment for line that could be removed innobase/trx/trx0sys.c: Added cast to remove compiler warning isam/isamchk.c: Fixed compiler warning libmysql/conf_to_src.c: Include files in proper order myisam/mi_check.c: Removed else part that caused compiler warning myisam/mi_delete.c: Added cast myisam/mi_page.c: Added cast myisam/mi_preload.c: Added cast myisam/mi_write.c: Added cast myisam/myisampack.c: changed 'byte' to 'current_byte' to avoid compiler warnings mysql-test/mysql-test-run.sh: Removed start-from as test '<' is not portable and this can easily be done from command line mysys/hash.c: Added cast mysys/mf_wcomp.c: Removed not reached line mysys/my_append.c: Fixed include file order to get this more portable mysys/my_copy.c: Fixed include file order to get this more portable mysys/my_redel.c: Fixed include file order to get this more portable sql-common/client.c: More DBUG_PRINT sql-common/pack.c: Added casts becasue Fortre compiler apparently compares (ulonglong) < (longlong) as signed sql/ha_heap.cc: Changed variable names to not cause hidden variables sql/ha_innodb.cc: Changed variable names to not cause hidden variables sql/item.cc: Changed variable names to not cause hidden variables sql/item.h: Changed variable names to not cause hidden variables sql/item_cmpfunc.h: Changed variable names to not cause hidden variables sql/item_func.cc: Changed variable names to not cause hidden variables sql/item_subselect.cc: Changed variable names to not cause hidden variables sql/item_subselect.h: Changed variable names to not cause hidden variables sql/item_sum.cc: Changed variable names to not cause hidden variables sql/item_timefunc.cc: Changed variable names to not cause hidden variables sql/log.cc: Changed variable names to not cause hidden variables sql/protocol.cc: Changed variable names to not cause hidden variables sql/protocol.h: Changed variable names to not cause hidden variables Remove function not declared in protocol.cc sql/protocol_cursor.cc: Changed variable names to not cause hidden variables sql/set_var.cc: Added a lot of 'version_xxx' strings Changed 'bdb_version' to 'version_bdb' sql/sql_class.cc: Changed variable names to not cause hidden variables Add TMP_TABLE_PARAM::init() to allow one to initialize structure several times sql/sql_class.h: Prevent copying of TMP_TABLE_PARAM (This caused core dump bug on Solaris) sql/sql_derived.cc: Avoid copying TMP_TABLE_PARAM (Use class version instead) sql/sql_error.cc: More DBUG sql/sql_help.cc: Fixed compiler warning sql/sql_lex.cc: Changed variable names to not cause hidden variables sql/sql_list.h: Changed variable names to not cause hidden variables sql/sql_parse.cc: Changed variable names to not cause hidden variables sql/sql_select.cc: Changed variable names to not cause hidden variables Ensure that you don't send NULL to printf() for %s Fixed problem with printing sub selects to debug log sql/sql_select.h: Changed variable names to not cause hidden variables sql/sql_union.cc: Changed variable names to not cause hidden variables Don't use local copy of TMP_TABLE_PARAM (Caused core dump on Solaris) sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Remove warning strings/conf_to_src.c: Fixed include file order --- sql/ha_heap.cc | 29 +++++---- sql/ha_innodb.cc | 8 +-- sql/item.cc | 10 ++-- sql/item.h | 10 ++-- sql/item_cmpfunc.h | 16 ++--- sql/item_func.cc | 8 +-- sql/item_subselect.cc | 81 ++++++++++++------------- sql/item_subselect.h | 6 +- sql/item_sum.cc | 6 +- sql/item_timefunc.cc | 6 +- sql/log.cc | 4 +- sql/protocol.cc | 18 ++++-- sql/protocol.h | 11 ++-- sql/protocol_cursor.cc | 10 ++-- sql/set_var.cc | 6 +- sql/sql_class.cc | 15 ++++- sql/sql_class.h | 8 ++- sql/sql_derived.cc | 13 ++-- sql/sql_error.cc | 3 +- sql/sql_help.cc | 2 +- sql/sql_lex.cc | 31 +++++----- sql/sql_list.h | 4 +- sql/sql_parse.cc | 16 ++--- sql/sql_select.cc | 157 +++++++++++++++++++++++++------------------------ sql/sql_select.h | 14 ++--- sql/sql_union.cc | 55 +++++++++-------- sql/sql_update.cc | 3 +- sql/sql_yacc.yy | 2 +- 28 files changed, 295 insertions(+), 257 deletions(-) (limited to 'sql') diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index fb4061b31e0..ae0267b98f3 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -248,7 +248,8 @@ ha_rows ha_heap::records_in_range(int inx, } } -int ha_heap::create(const char *name, TABLE *table, + +int ha_heap::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { uint key, parts, mem_per_row= 0; @@ -259,17 +260,17 @@ int ha_heap::create(const char *name, TABLE *table, char buff[FN_REFLEN]; int error; - for (key= parts= 0; key < table->keys; key++) - parts+= table->key_info[key].key_parts; + for (key= parts= 0; key < table_arg->keys; key++) + parts+= table_arg->key_info[key].key_parts; - if (!(keydef= (HP_KEYDEF*) my_malloc(table->keys * sizeof(HP_KEYDEF) + + if (!(keydef= (HP_KEYDEF*) my_malloc(table_arg->keys * sizeof(HP_KEYDEF) + parts * sizeof(HA_KEYSEG), MYF(MY_WME)))) return my_errno; - seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + table->keys); - for (key= 0; key < table->keys; key++) + seg= my_reinterpret_cast(HA_KEYSEG*) (keydef + table_arg->keys); + for (key= 0; key < table_arg->keys; key++) { - KEY *pos= table->key_info+key; + KEY *pos= table_arg->key_info+key; KEY_PART_INFO *key_part= pos->key_part; KEY_PART_INFO *key_part_end= key_part + pos->key_parts; @@ -303,7 +304,7 @@ int ha_heap::create(const char *name, TABLE *table, if (field->null_ptr) { seg->null_bit= field->null_bit; - seg->null_pos= (uint) (field->null_ptr - (uchar*) table->record[0]); + seg->null_pos= (uint) (field->null_ptr - (uchar*) table_arg->record[0]); } else { @@ -317,7 +318,7 @@ int ha_heap::create(const char *name, TABLE *table, } } } - mem_per_row+= MY_ALIGN(table->reclength + 1, sizeof(char*)); + mem_per_row+= MY_ALIGN(table_arg->reclength + 1, sizeof(char*)); max_rows = (ha_rows) (current_thd->variables.max_heap_table_size / mem_per_row); HP_CREATE_INFO hp_create_info; @@ -326,10 +327,11 @@ int ha_heap::create(const char *name, TABLE *table, hp_create_info.auto_increment= (create_info->auto_increment_value ? create_info->auto_increment_value - 1 : 0); error= heap_create(fn_format(buff,name,"","",4+2), - table->keys,keydef, table->reclength, - (ulong) ((table->max_rows < max_rows && table->max_rows) ? - table->max_rows : max_rows), - (ulong) table->min_rows, &hp_create_info); + table_arg->keys,keydef, table_arg->reclength, + (ulong) ((table_arg->max_rows < max_rows && + table_arg->max_rows) ? + table_arg->max_rows : max_rows), + (ulong) table_arg->min_rows, &hp_create_info); my_free((gptr) keydef, MYF(0)); if (file) info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE); @@ -337,6 +339,7 @@ int ha_heap::create(const char *name, TABLE *table, return (error); } + void ha_heap::update_create_info(HA_CREATE_INFO *create_info) { table->file->info(HA_STATUS_AUTO); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 11870e4cc29..7fc0664445d 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -3640,7 +3640,7 @@ ha_innobase::discard_or_import_tablespace( my_bool discard) /* in: TRUE if discard, else import */ { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; - dict_table_t* table; + dict_table_t* dict_table; trx_t* trx; int err; @@ -3650,13 +3650,13 @@ ha_innobase::discard_or_import_tablespace( ut_a(prebuilt->trx == (trx_t*) current_thd->transaction.all.innobase_tid); - table = prebuilt->table; + dict_table = prebuilt->table; trx = prebuilt->trx; if (discard) { - err = row_discard_tablespace_for_mysql(table->name, trx); + err = row_discard_tablespace_for_mysql(dict_table->name, trx); } else { - err = row_import_tablespace_for_mysql(table->name, trx); + err = row_import_tablespace_for_mysql(dict_table->name, trx); } if (err == DB_SUCCESS) { diff --git a/sql/item.cc b/sql/item.cc index 97ef19d089b..1d49671ff4c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1667,7 +1667,9 @@ bool Item_insert_value::eq(const Item *item, bool binary_cmp) const } -bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, Item **items) +bool Item_insert_value::fix_fields(THD *thd, + struct st_table_list *table_list, + Item **items) { bool res= arg->fix_fields(thd, table_list, items); if (res) @@ -1698,10 +1700,10 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, I } else { - Field *field=field_arg->field; + Field *tmp_field= field_arg->field; /* charset doesn't matter here, it's to avoid sigsegv only */ - set_field(new Field_null(0,0,Field::NONE,field->field_name,field->table, - &my_charset_bin)); + set_field(new Field_null(0, 0, Field::NONE, tmp_field->field_name, + tmp_field->table, &my_charset_bin)); } return 0; } diff --git a/sql/item.h b/sql/item.h index 23b0cf018e1..a94a7a77597 100644 --- a/sql/item.h +++ b/sql/item.h @@ -830,14 +830,14 @@ public: bool fix_fields(THD *, struct st_table_list *, Item **); void print(String *str); virtual bool basic_const_item() const { return true; } - int save_in_field(Field *field, bool no_conversions) + int save_in_field(Field *field_arg, bool no_conversions) { if (!arg) { - field->set_default(); + field_arg->set_default(); return 0; } - return Item_field::save_in_field(field, no_conversions); + return Item_field::save_in_field(field_arg, no_conversions); } table_map used_tables() const { return (table_map)0L; } @@ -858,9 +858,9 @@ public: bool fix_fields(THD *, struct st_table_list *, Item **); void print(String *str); virtual bool basic_const_item() const { return true; } - int save_in_field(Field *field, bool no_conversions) + int save_in_field(Field *field_arg, bool no_conversions) { - return Item_field::save_in_field(field, no_conversions); + return Item_field::save_in_field(field_arg, no_conversions); } table_map used_tables() const { return (table_map)0L; } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 51c53e6c136..dc017cef73c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -41,24 +41,24 @@ public: Arg_comparator(Item **a1, Item **a2): a(a1), b(a2) {}; int set_compare_func(Item_bool_func2 *owner, Item_result type); - inline int set_compare_func(Item_bool_func2 *owner) + inline int set_compare_func(Item_bool_func2 *owner_arg) { - return set_compare_func(owner, item_cmp_type((*a)->result_type(), - (*b)->result_type())); + return set_compare_func(owner_arg, item_cmp_type((*a)->result_type(), + (*b)->result_type())); } - inline int set_cmp_func(Item_bool_func2 *owner, + inline int set_cmp_func(Item_bool_func2 *owner_arg, Item **a1, Item **a2, Item_result type) { a= a1; b= a2; - return set_compare_func(owner, type); + return set_compare_func(owner_arg, type); } - inline int set_cmp_func(Item_bool_func2 *owner, + inline int set_cmp_func(Item_bool_func2 *owner_arg, Item **a1, Item **a2) { - return set_cmp_func(owner, a1, a2, item_cmp_type((*a1)->result_type(), - (*a2)->result_type())); + return set_cmp_func(owner_arg, a1, a2, item_cmp_type((*a1)->result_type(), + (*a2)->result_type())); } inline int compare() { return (this->*func)(); } diff --git a/sql/item_func.cc b/sql/item_func.cc index 97454a6fce7..0ccc7febd0a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1624,7 +1624,7 @@ bool udf_handler::get_arguments() String *udf_handler::val_str(String *str,String *save_str) { - uchar is_null=0; + uchar is_null_tmp=0; ulong res_length; if (get_arguments()) @@ -1641,9 +1641,9 @@ String *udf_handler::val_str(String *str,String *save_str) return 0; } } - char *res=func(&initid, &f_args, (char*) str->ptr(), &res_length, &is_null, - &error); - if (is_null || !res || error) // The !res is for safety + char *res=func(&initid, &f_args, (char*) str->ptr(), &res_length, + &is_null_tmp, &error); + if (is_null_tmp || !res || error) // The !res is for safety { return 0; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 367400d6b0b..7b401b50d4c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -306,8 +306,7 @@ void Item_singlerow_subselect::fix_length_and_dec() } else { - THD *thd= current_thd; - if (!(row= (Item_cache**)thd->alloc(sizeof(Item_cache*)*max_columns))) + if (!(row= (Item_cache**) sql_alloc(sizeof(Item_cache*)*max_columns))) return; engine->fix_length_and_dec(row); value= *row; @@ -550,8 +549,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, SELECT_LEX *select_lex= join->select_lex; - THD *thd= join->thd; - thd->where= "scalar IN/ALL/ANY subquery"; + THD *thd_tmp= join->thd; + thd_tmp->where= "scalar IN/ALL/ANY subquery"; if (select_lex->item_list.elements > 1) { @@ -595,7 +594,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, select_lex->item_list.empty(); select_lex->item_list.push_back(item); - if (item->fix_fields(thd, join->tables_list, &item)) + if (item->fix_fields(thd_tmp, join->tables_list, &item)) { DBUG_RETURN(RES_ERROR); } @@ -609,14 +608,14 @@ Item_in_subselect::single_value_transformer(JOIN *join, subs= new Item_maxmin_subselect(this, select_lex, func->l_op()); } // left expression belong to outer select - SELECT_LEX *current= thd->lex.current_select, *up; - thd->lex.current_select= up= current->return_after_parsing(); - if (left_expr->fix_fields(thd, up->get_table_list(), &left_expr)) + SELECT_LEX *current= thd_tmp->lex.current_select, *up; + thd_tmp->lex.current_select= up= current->return_after_parsing(); + if (left_expr->fix_fields(thd_tmp, up->get_table_list(), &left_expr)) { - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; substitution= func->create(left_expr, subs); DBUG_RETURN(RES_OK); } @@ -627,16 +626,16 @@ Item_in_subselect::single_value_transformer(JOIN *join, SELECT_LEX_UNIT *unit= select_lex->master_unit(); substitution= optimizer= new Item_in_optimizer(left_expr, this); - SELECT_LEX *current= thd->lex.current_select, *up; + SELECT_LEX *current= thd_tmp->lex.current_select, *up; - thd->lex.current_select= up= current->return_after_parsing(); + thd_tmp->lex.current_select= up= current->return_after_parsing(); //optimizer never use Item **ref => we can pass 0 as parameter - if (!optimizer || optimizer->fix_left(thd, up->get_table_list(), 0)) + if (!optimizer || optimizer->fix_left(thd_tmp, up->get_table_list(), 0)) { - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; /* As far as Item_ref_in_optimizer do not substitude itself on fix_fields @@ -664,7 +663,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, this->full_name())); join->having= and_items(join->having, item); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -688,7 +687,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, new Item_cond_and(having, join->having) : having); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, + &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -699,7 +699,7 @@ Item_in_subselect::single_value_transformer(JOIN *join, } item->name= (char *)in_additional_cond; join->conds= and_items(join->conds, item); - if (join->conds->fix_fields(thd, join->tables_list, &join->conds)) + if (join->conds->fix_fields(thd_tmp, join->tables_list, &join->conds)) DBUG_RETURN(RES_ERROR); } else @@ -711,7 +711,8 @@ Item_in_subselect::single_value_transformer(JOIN *join, (char *)"", (char *)"")); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, + &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -725,11 +726,11 @@ Item_in_subselect::single_value_transformer(JOIN *join, // fix_field of item will be done in time of substituting substitution= item; have_to_be_excluded= 1; - if (thd->lex.describe) + if (thd_tmp->lex.describe) { char warn_buff[MYSQL_ERRMSG_SIZE]; sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + push_warning(thd_tmp, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SELECT_REDUCED, warn_buff); } DBUG_RETURN(RES_REDUCE); @@ -739,13 +740,14 @@ Item_in_subselect::single_value_transformer(JOIN *join, DBUG_RETURN(RES_OK); } + Item_subselect::trans_res Item_in_subselect::row_value_transformer(JOIN *join) { DBUG_ENTER("Item_in_subselect::row_value_transformer"); - THD *thd= join->thd; - thd->where= "row IN/ALL/ANY subquery"; + THD *thd_tmp= join->thd; + thd_tmp->where= "row IN/ALL/ANY subquery"; SELECT_LEX *select_lex= join->select_lex; @@ -761,22 +763,22 @@ Item_in_subselect::row_value_transformer(JOIN *join) SELECT_LEX_UNIT *unit= select_lex->master_unit(); substitution= optimizer= new Item_in_optimizer(left_expr, this); - SELECT_LEX *current= thd->lex.current_select, *up; - thd->lex.current_select= up= current->return_after_parsing(); + SELECT_LEX *current= thd_tmp->lex.current_select, *up; + thd_tmp->lex.current_select= up= current->return_after_parsing(); //optimizer never use Item **ref => we can pass 0 as parameter - if (!optimizer || optimizer->fix_left(thd, up->get_table_list(), 0)) + if (!optimizer || optimizer->fix_left(thd_tmp, up->get_table_list(), 0)) { - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; DBUG_RETURN(RES_ERROR); } - thd->lex.current_select= current; + thd_tmp->lex.current_select= current; unit->uncacheable|= UNCACHEABLE_DEPENDENT; } uint n= left_expr->cols(); select_lex->uncacheable|= UNCACHEABLE_DEPENDENT; - select_lex->setup_ref_array(thd, + select_lex->setup_ref_array(thd_tmp, select_lex->order_list.elements + select_lex->group_list.elements); Item *item= 0; @@ -802,7 +804,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) { join->having= and_items(join->having, item); select_lex->having_fix_field= 1; - if (join->having->fix_fields(thd, join->tables_list, &join->having)) + if (join->having->fix_fields(thd_tmp, join->tables_list, &join->having)) { select_lex->having_fix_field= 0; DBUG_RETURN(RES_ERROR); @@ -812,7 +814,7 @@ Item_in_subselect::row_value_transformer(JOIN *join) else { join->conds= and_items(join->conds, item); - if (join->conds->fix_fields(thd, join->tables_list, &join->having)) + if (join->conds->fix_fields(thd_tmp, join->tables_list, &join->having)) DBUG_RETURN(RES_ERROR); } DBUG_RETURN(RES_OK); @@ -880,7 +882,7 @@ subselect_single_select_engine(st_select_lex *select, unit->select_limit_cnt= unit->global_parameters->select_limit+ unit->global_parameters ->offset_limit; if (unit->select_limit_cnt < unit->global_parameters->select_limit) - unit->select_limit_cnt= HA_POS_ERROR; // no limit + unit->select_limit_cnt= HA_POS_ERROR; // no limit if (unit->select_limit_cnt == HA_POS_ERROR) select_lex->options&= ~OPTION_FOUND_ROWS; unit->item= item; @@ -889,17 +891,17 @@ subselect_single_select_engine(st_select_lex *select, subselect_union_engine::subselect_union_engine(st_select_lex_unit *u, - select_subselect *result, - Item_subselect *item) - :subselect_engine(item, result) + select_subselect *result_arg, + Item_subselect *item_arg) + :subselect_engine(item_arg, result_arg) { unit= u; - if (!result) - //out of memory + if (!result_arg) //out of memory current_thd->fatal_error(); - unit->item= item; + unit->item= item_arg; } + int subselect_single_select_engine::prepare() { if (prepared) @@ -907,8 +909,7 @@ int subselect_single_select_engine::prepare() join= new JOIN(thd, select_lex->item_list, select_lex->options, result); if (!join || !result) { - //out of memory - thd->fatal_error(); + thd->fatal_error(); //out of memory return 1; } prepared= 1; diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 3637e025d3c..8444dc7bf66 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -263,7 +263,7 @@ public: virtual ~subselect_engine() {}; // to satisfy compiler // set_thd should be called before prepare() - void set_thd(THD *thd) { this->thd= thd; } + void set_thd(THD *thd_arg) { thd= thd_arg; } THD * get_thd() { return thd; } virtual int prepare()= 0; virtual void fix_length_and_dec(Item_cache** row)= 0; @@ -328,11 +328,11 @@ protected: public: // constructor can assign THD because it will be called after JOIN::prepare - subselect_uniquesubquery_engine(THD *thd, st_join_table *tab_arg, + subselect_uniquesubquery_engine(THD *thd_arg, st_join_table *tab_arg, Item_subselect *subs, Item *where) :subselect_engine(subs, 0), tab(tab_arg), cond(where) { - set_thd(thd); + set_thd(thd_arg); } ~subselect_uniquesubquery_engine(); int prepare(); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a3d67e9f7fa..62782e1f710 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -104,16 +104,16 @@ Item *Item_sum::get_tmp_table_item(THD *thd) Item_sum* sum_item= (Item_sum *) copy_or_same(thd); if (sum_item && sum_item->result_field) // If not a const sum func { - Field *result_field= sum_item->result_field; + Field *result_field_tmp= sum_item->result_field; for (uint i=0 ; i < sum_item->arg_count ; i++) { Item *arg= sum_item->args[i]; if (!arg->const_item()) { if (arg->type() == Item::FIELD_ITEM) - ((Item_field*) arg)->field= result_field++; + ((Item_field*) arg)->field= result_field_tmp++; else - sum_item->args[i]= new Item_field(result_field++); + sum_item->args[i]= new Item_field(result_field_tmp++); } } } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 496ea0ed5c8..a5372a4ae60 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -671,7 +671,7 @@ longlong Item_func_month::val_int() String* Item_func_monthname::val_str(String* str) { - const char *name; + const char *month_name; uint month=(uint) Item_func_month::val_int(); if (!month) // This is also true for NULL @@ -680,8 +680,8 @@ String* Item_func_monthname::val_str(String* str) return (String*) 0; } null_value=0; - name= month_names[month-1]; - str->set(name, strlen(name), system_charset_info); + month_name= month_names[month-1]; + str->set(month_name, strlen(month_name), system_charset_info); return str; } diff --git a/sql/log.cc b/sql/log.cc index c32e37cd86a..936373daf03 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -179,7 +179,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, const char *new_name, const char *index_file_name_arg, enum cache_type io_cache_type_arg, bool no_auto_events_arg, - ulong max_size) + ulong max_size_arg) { char buff[512]; File file= -1, index_file_nr= -1; @@ -190,7 +190,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, last_time=query_start=0; write_error=0; - init(log_type_arg,io_cache_type_arg,no_auto_events_arg,max_size); + init(log_type_arg,io_cache_type_arg,no_auto_events_arg,max_size_arg); if (!(name=my_strdup(log_name,MYF(MY_WME)))) goto err; diff --git a/sql/protocol.cc b/sql/protocol.cc index e1347ff3c6f..0c9fed629b4 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -285,6 +285,12 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos=net_store_length(pos, (ulonglong) id); if (thd->client_capabilities & CLIENT_PROTOCOL_41) { + DBUG_PRINT("info", + ("affected_rows: %lu id: %lu status: %u warning_count: %u", + (ulong) affected_rows, + (ulong) id, + (uint) (thd->server_status & 0xffff), + (uint) thd->total_warn_count)); int2store(pos,thd->server_status); pos+=2; @@ -483,7 +489,7 @@ bool Protocol::send_fields(List *list, uint flag) char buff[80]; String tmp((char*) buff,sizeof(buff),&my_charset_bin); Protocol_simple prot(thd); - String *packet= prot.storage_packet(); + String *local_packet= prot.storage_packet(); CHARSET_INFO *thd_charset= thd->variables.character_set_results; DBUG_ENTER("send_fields"); @@ -520,10 +526,10 @@ bool Protocol::send_fields(List *list, uint flag) cs, thd_charset) || prot.store(field.org_col_name, (uint) strlen(field.org_col_name), cs, thd_charset) || - packet->realloc(packet->length()+12)) + local_packet->realloc(local_packet->length()+12)) goto err; /* Store fixed length fields */ - pos= (char*) packet->ptr()+packet->length(); + pos= (char*) local_packet->ptr()+local_packet->length(); *pos++= 12; // Length of packed fields int2store(pos, field.charsetnr); int4store(pos+2, field.length); @@ -540,9 +546,9 @@ bool Protocol::send_fields(List *list, uint flag) cs, thd_charset) || prot.store(field.col_name, (uint) strlen(field.col_name), cs, thd_charset) || - packet->realloc(packet->length()+10)) + local_packet->realloc(local_packet->length()+10)) goto err; - pos= (char*) packet->ptr()+packet->length(); + pos= (char*) local_packet->ptr()+local_packet->length(); #ifdef TO_BE_DELETED_IN_6 if (!(thd->client_capabilities & CLIENT_LONG_FLAG)) @@ -569,7 +575,7 @@ bool Protocol::send_fields(List *list, uint flag) pos+= 10; } } - packet->length((uint) (pos - packet->ptr())); + local_packet->length((uint) (pos - local_packet->ptr())); if (flag & 2) item->send(&prot, &tmp); // Send default value if (prot.write()) diff --git a/sql/protocol.h b/sql/protocol.h index 94fd303e259..67ae4ed01b4 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -44,9 +44,9 @@ protected: #endif public: Protocol() {} - Protocol(THD *thd) { init(thd); } + Protocol(THD *thd_arg) { init(thd_arg); } virtual ~Protocol() {} - void init(THD* thd); + void init(THD* thd_arg); bool send_fields(List *list, uint flag); bool send_records_num(List *list, ulonglong records); bool store(I_List *str_list); @@ -97,7 +97,7 @@ class Protocol_simple :public Protocol { public: Protocol_simple() {} - Protocol_simple(THD *thd) :Protocol(thd) {} + Protocol_simple(THD *thd_arg) :Protocol(thd_arg) {} virtual void prepare_for_resend(); virtual bool store_null(); virtual bool store_tiny(longlong from); @@ -122,7 +122,7 @@ private: uint bit_fields; public: Protocol_prep() {} - Protocol_prep(THD *thd) :Protocol(thd) {} + Protocol_prep(THD *thd_arg) :Protocol(thd_arg) {} virtual bool prepare_for_send(List *item_list); virtual void prepare_for_resend(); #ifdef EMBEDDED_LIBRARY @@ -155,7 +155,7 @@ public: ulong row_count; Protocol_cursor() {} - Protocol_cursor(THD *thd, MEM_ROOT *ini_alloc) :Protocol_simple(thd), alloc(ini_alloc) {} + Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc) {} bool prepare_for_send(List *item_list) { fields= NULL; @@ -173,7 +173,6 @@ void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, const char *info=0); void send_eof(THD *thd, bool no_flush=0); bool send_old_password_request(THD *thd); -char *net_store_length(char *packet,ulonglong length); char *net_store_length(char *packet,uint length); char *net_store_data(char *to,const char *from, uint length); char *net_store_data(char *to,int32 from); diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 563a2d41019..5f35552c562 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -96,23 +96,23 @@ bool Protocol_cursor::write() MYSQL_FIELD *cur_field= fields; MYSQL_FIELD *fields_end= fields + field_count; MYSQL_ROWS *new_record; - byte **data; + byte **data_tmp; byte *to; new_record= (MYSQL_ROWS *)alloc_root(alloc, sizeof(MYSQL_ROWS) + (field_count + 1)*sizeof(char *) + packet->length()); if (!new_record) goto err; - data= (byte **)(new_record + 1); - new_record->data= (char **)data; + data_tmp= (byte **)(new_record + 1); + new_record->data= (char **)data_tmp; to= (byte *)(fields + field_count + 1); - for (; cur_field < fields_end; ++cur_field, ++data) + for (; cur_field < fields_end; ++cur_field, ++data_tmp) { if ((len=net_field_length((uchar **)&cp))) { - *data= 0; + *data_tmp= 0; } else { diff --git a/sql/set_var.cc b/sql/set_var.cc index 39dc92c5d33..7e576b5a755 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -549,7 +549,6 @@ struct show_var_st init_vars[]= { {"bdb_logdir", (char*) &berkeley_logdir, SHOW_CHAR_PTR}, {"bdb_shared_data", (char*) &berkeley_shared_data, SHOW_BOOL}, {"bdb_tmpdir", (char*) &berkeley_tmpdir, SHOW_CHAR_PTR}, - {"bdb_version", (char*) DB_VERSION_STRING, SHOW_CHAR}, #endif {sys_binlog_cache_size.name,(char*) &sys_binlog_cache_size, SHOW_SYS}, {sys_bulk_insert_buff_size.name,(char*) &sys_bulk_insert_buff_size,SHOW_SYS}, @@ -740,7 +739,12 @@ struct show_var_st init_vars[]= { SHOW_SYS}, {sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS}, {"version", server_version, SHOW_CHAR}, +#ifdef HAVE_BERKELEY_DB + {"version_bdb", (char*) DB_VERSION_STRING, SHOW_CHAR}, +#endif {"version_comment", (char*) MYSQL_COMPILATION_COMMENT, SHOW_CHAR}, + {"version_compile_machine", (char*) MACHINE_TYPE, SHOW_CHAR}, + {"version_compile_os", (char*) SYSTEM_TYPE, SHOW_CHAR}, {sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS}, {NullS, NullS, SHOW_LONG} }; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 1041c21ef30..5dee75a5670 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1036,9 +1036,9 @@ bool select_dump::send_eof() return error; } -select_subselect::select_subselect(Item_subselect *item) +select_subselect::select_subselect(Item_subselect *item_arg) { - this->item=item; + item= item_arg; } bool select_singlerow_subselect::send_data(List &items) @@ -1229,3 +1229,14 @@ bool select_dumpvar::send_eof() return 1; } } + +/**************************************************************************** + TMP_TABLE_PARAM +****************************************************************************/ + +void TMP_TABLE_PARAM::init() +{ + field_count= sum_func_count= func_count= hidden_field_count= 0; + group_parts= group_length= group_null_parts= 0; + quick_group= 1; +} diff --git a/sql/sql_class.h b/sql/sql_class.h index 6be517d42d0..beb2de9c0a9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -895,7 +895,12 @@ public: class TMP_TABLE_PARAM :public Sql_alloc { - public: +private: + /* Prevent use of these (not safe because of lists and copy_field) */ + TMP_TABLE_PARAM(const TMP_TABLE_PARAM &); + void operator=(TMP_TABLE_PARAM &); + +public: List copy_funcs; List save_copy_funcs; List_iterator_fast copy_funcs_it; @@ -920,6 +925,7 @@ class TMP_TABLE_PARAM :public Sql_alloc { cleanup(); } + void init(void); inline void cleanup(void) { if (copy_field) /* Fix for Intel compiler */ diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 20a1f7f0124..8e6f5b27ab0 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -67,7 +67,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, int res; select_union *derived_result; TABLE_LIST *tables= (TABLE_LIST *)first_select->table_list.first; - TMP_TABLE_PARAM tmp_table_param; bool is_union= first_select->next_select() && first_select->next_select()->linkage == UNION_TYPE; bool is_subsel= first_select->first_inner_unit() ? 1: 0; @@ -111,7 +110,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, fix_tables_pointers(unit); } - if(!(derived_result= new select_union(0))) + if (!(derived_result= new select_union(0))) DBUG_RETURN(1); // out of memory // st_select_lex_unit::prepare correctly work for single select @@ -128,13 +127,14 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, cursor->table->clear_query_id= 1; } - bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); - tmp_table_param.field_count= unit->types.elements; + derived_result->tmp_table_param.init(); + derived_result->tmp_table_param.field_count= unit->types.elements; /* Temp table is created so that it hounours if UNION without ALL is to be processed */ - if (!(table= create_tmp_table(thd, &tmp_table_param, unit->types, + if (!(table= create_tmp_table(thd, &derived_result->tmp_table_param, + unit->types, (ORDER*) 0, is_union && !unit->union_option, 1, (first_select->options | thd->options | @@ -146,7 +146,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, goto exit; } derived_result->set_table(table); - derived_result->tmp_table_param=tmp_table_param; unit->offset_limit_cnt= first_select->offset_limit; unit->select_limit_cnt= first_select->select_limit+ @@ -206,7 +205,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, table->file->info(HA_STATUS_VARIABLE); } } - delete derived_result; if (res) free_tmp_table(thd, table); @@ -218,6 +216,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, } exit: + delete derived_result; lex->current_select= save_current_select; close_thread_tables(thd, 0, 1); } diff --git a/sql/sql_error.cc b/sql/sql_error.cc index db0dbe0dedc..81b98358486 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -102,6 +102,7 @@ void mysql_reset_errors(THD *thd) MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code, const char *msg) { + DBUG_ENTER("push_warning"); if (thd->query_id != thd->warn_id) mysql_reset_errors(thd); @@ -122,7 +123,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, } thd->warn_count[(uint) level]++; thd->total_warn_count++; - return err; + DBUG_RETURN(err); } /* diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 6af4ffde0e1..c40133c04a8 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -524,7 +524,7 @@ int send_header_2(Protocol *protocol, bool for_category) same as strcmp */ -int string_ptr_cmp(const void* ptr1, const void* ptr2) +extern "C" int string_ptr_cmp(const void* ptr1, const void* ptr2) { String *str1= *(String**)ptr1; String *str2= *(String**)ptr2; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 9b74073b64e..4257df494bc 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1289,12 +1289,13 @@ bool st_select_lex::test_limit() 0 - OK !0 - error */ -bool st_select_lex_unit::create_total_list(THD *thd, st_lex *lex, - TABLE_LIST **result, +bool st_select_lex_unit::create_total_list(THD *thd_arg, st_lex *lex, + TABLE_LIST **result_arg, bool check_derived) { - *result= 0; - res= create_total_list_n_last_return(thd, lex, &result, check_derived); + *result_arg= 0; + res= create_total_list_n_last_return(thd_arg, lex, &result_arg, + check_derived); return res; } @@ -1318,12 +1319,14 @@ bool st_select_lex_unit::create_total_list(THD *thd, st_lex *lex, 0 - OK !0 - error */ -bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, - TABLE_LIST ***result, - bool check_derived) +bool st_select_lex_unit:: +create_total_list_n_last_return(THD *thd_arg, + st_lex *lex, + TABLE_LIST ***result_arg, + bool check_derived) { TABLE_LIST *slave_list_first=0, **slave_list_last= &slave_list_first; - TABLE_LIST **new_table_list= *result, *aux; + TABLE_LIST **new_table_list= *result_arg, *aux; SELECT_LEX *sl= (SELECT_LEX*)slave; /* @@ -1342,7 +1345,7 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, if (sl->order_list.first && sl->next_select() && !sl->braces && sl->linkage != GLOBAL_OPTIONS_TYPE) { - net_printf(thd,ER_WRONG_USAGE,"UNION","ORDER BY"); + net_printf(thd_arg,ER_WRONG_USAGE,"UNION","ORDER BY"); return 1; } @@ -1360,12 +1363,12 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, if ((aux= (TABLE_LIST*) sl->table_list.first)) { - TABLE_LIST *next; - for (; aux; aux= next) + TABLE_LIST *next_table; + for (; aux; aux= next_table) { TABLE_LIST *cursor; - next= aux->next; - for (cursor= **result; cursor; cursor= cursor->next) + next_table= aux->next; + for (cursor= **result_arg; cursor; cursor= cursor->next) if (!strcmp(cursor->db, aux->db) && !strcmp(cursor->real_name, aux->real_name) && !strcmp(cursor->alias, aux->alias)) @@ -1397,7 +1400,7 @@ end: *new_table_list= slave_list_first; new_table_list= slave_list_last; } - *result= new_table_list; + *result_arg= new_table_list; return 0; } diff --git a/sql/sql_list.h b/sql/sql_list.h index 7200046e6c5..0972d0341f6 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -283,9 +283,9 @@ public: List_iterator_fast(List &a) : base_list_iterator(a) {} inline T* operator++(int) { return (T*) base_list_iterator::next_fast(); } inline void rewind(void) { base_list_iterator::rewind(); } - void sublist(List &list, uint el) + void sublist(List &list_arg, uint el_arg) { - base_list_iterator::sublist(list, el); + base_list_iterator::sublist(list_arg, el_arg); } }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d5a15de422d..d74d06f9439 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4320,8 +4320,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, LEX_STRING *alias, ulong table_options, thr_lock_type lock_type, - List *use_index, - List *ignore_index, + List *use_index_arg, + List *ignore_index_arg, LEX_STRING *option) { register TABLE_LIST *ptr; @@ -4377,12 +4377,12 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX); ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES); ptr->derived= table->sel; - if (use_index) - ptr->use_index=(List *) thd->memdup((gptr) use_index, - sizeof(*use_index)); - if (ignore_index) - ptr->ignore_index=(List *) thd->memdup((gptr) ignore_index, - sizeof(*ignore_index)); + if (use_index_arg) + ptr->use_index=(List *) thd->memdup((gptr) use_index_arg, + sizeof(*use_index_arg)); + if (ignore_index_arg) + ptr->ignore_index=(List *) thd->memdup((gptr) ignore_index_arg, + sizeof(*ignore_index_arg)); ptr->option= option ? option->str : 0; /* check that used name is unique */ if (lock_type != TL_IGNORE) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ba4dd9f856e..3594b53436e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -284,8 +284,8 @@ JOIN::prepare(Item ***rref_pointer_array, uint wild_num, COND *conds_init, uint og_num, ORDER *order_init, ORDER *group_init, Item *having_init, - ORDER *proc_param_init, SELECT_LEX *select, - SELECT_LEX_UNIT *unit) + ORDER *proc_param_init, SELECT_LEX *select_lex_arg, + SELECT_LEX_UNIT *unit_arg) { DBUG_ENTER("JOIN::prepare"); @@ -295,9 +295,9 @@ JOIN::prepare(Item ***rref_pointer_array, having= having_init; proc_param= proc_param_init; tables_list= tables_init; - select_lex= select; + select_lex= select_lex_arg; select_lex->join= this; - union_part= (unit->first_select()->next_select() != 0); + union_part= (unit_arg->first_select()->next_select() != 0); /* Check that all tables, fields, conds and order are ok */ @@ -369,14 +369,14 @@ JOIN::prepare(Item ***rref_pointer_array, DBUG_RETURN(-1); } } - TABLE_LIST *table; - for (table=tables_list ; table ; table=table->next) + TABLE_LIST *table_ptr; + for (table_ptr= tables_list ; table_ptr ; table_ptr= table_ptr->next) tables++; } { /* Caclulate the number of groups */ send_group_parts= 0; - for (ORDER *group= group_list ; group ; group= group->next) + for (ORDER *group_tmp= group_list ; group_tmp ; group_tmp= group_tmp->next) send_group_parts++; } @@ -416,13 +416,13 @@ JOIN::prepare(Item ***rref_pointer_array, ref_pointer_array_size= all_fields.elements*sizeof(Item*); this->group= group_list != 0; row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR : - unit->select_limit_cnt); + unit_arg->select_limit_cnt); /* select_limit is used to decide if we are likely to scan the whole table */ - select_limit= unit->select_limit_cnt; + select_limit= unit_arg->select_limit_cnt; if (having || (select_options & OPTION_FOUND_ROWS)) select_limit= HA_POS_ERROR; - do_send_rows = (unit->select_limit_cnt) ? 1 : 0; - this->unit= unit; + do_send_rows = (unit_arg->select_limit_cnt) ? 1 : 0; + unit= unit_arg; #ifdef RESTRICTED_GROUP if (sum_func_count && !group_list && (func_count || field_count)) @@ -431,7 +431,7 @@ JOIN::prepare(Item ***rref_pointer_array, goto err; } #endif - if (!procedure && result->prepare(fields_list, unit)) + if (!procedure && result->prepare(fields_list, unit_arg)) goto err; /* purecov: inspected */ if (select_lex->olap == ROLLUP_TYPE && rollup_init()) @@ -607,20 +607,20 @@ JOIN::optimize() if (const_tables && !thd->locked_tables && !(select_options & SELECT_NO_UNLOCK)) { - TABLE **table, **end; - for (table=this->table, end=table + const_tables ; - table != end; - table++) + TABLE **curr_table, **end; + for (curr_table= table, end=cur_table + const_tables ; + curr_table != end; + curr_table++) { /* BDB tables require that we call index_end() before doing an unlock */ - if ((*table)->key_read) + if ((*curr_table)->key_read) { - (*table)->key_read=0; - (*table)->file->extra(HA_EXTRA_NO_KEYREAD); + (*curr_table)->key_read=0; + (*curr_table)->file->extra(HA_EXTRA_NO_KEYREAD); } - (*table)->file->index_end(); + (*curr_table)->file->index_end(); } - mysql_unlock_some_tables(thd, this->table, const_tables); + mysql_unlock_some_tables(thd, table, const_tables); } if (!conds && outer_join) { @@ -963,18 +963,18 @@ JOIN::optimize() if (exec_tmp_table1->distinct) { table_map used_tables= thd->used_tables; - JOIN_TAB *join_tab= this->join_tab+tables-1; + JOIN_TAB *last_join_tab= join_tab+tables-1; do { - if (used_tables & join_tab->table->map) + if (used_tables & last_join_tab->table->map) break; - join_tab->not_used_in_distinct=1; - } while (join_tab-- != this->join_tab); + last_join_tab->not_used_in_distinct=1; + } while (last_join_tab-- != join_tab); /* Optimize "select distinct b from t1 order by key_part_1 limit #" */ if (order && skip_sort_order) { /* Should always succeed */ - if (test_if_skip_sort_order(&this->join_tab[const_tables], + if (test_if_skip_sort_order(&join_tab[const_tables], order, unit->select_limit_cnt, 0)) order=0; } @@ -1393,26 +1393,27 @@ JOIN::exec() { // Some tables may have been const curr_join->tmp_having->update_used_tables(); - JOIN_TAB *table= &curr_join->join_tab[curr_join->const_tables]; - table_map used_tables= curr_join->const_table_map | table->table->map; + JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables]; + table_map used_tables= (curr_join->const_table_map | + curr_table->table->map); Item* sort_table_cond= make_cond_for_table(curr_join->tmp_having, used_tables, used_tables); if (sort_table_cond) { - if (!table->select) - if (!(table->select= new SQL_SELECT)) + if (!curr_table->select) + if (!(curr_table->select= new SQL_SELECT)) DBUG_VOID_RETURN; - if (!table->select->cond) - table->select->cond= sort_table_cond; + if (!curr_table->select->cond) + curr_table->select->cond= sort_table_cond; else // This should never happen - if (!(table->select->cond= new Item_cond_and(table->select->cond, - sort_table_cond))) + if (!(curr_table->select->cond= + new Item_cond_and(curr_table->select->cond, sort_table_cond))) DBUG_VOID_RETURN; - table->select_cond=table->select->cond; - table->select_cond->top_level_item(); - DBUG_EXECUTE("where",print_where(table->select->cond, + curr_table->select_cond= cur_table->select->cond; + curr_table->select_cond->top_level_item(); + DBUG_EXECUTE("where",print_where(curr_table->select->cond, "select and having");); curr_join->tmp_having= make_cond_for_table(curr_join->tmp_having, ~ (table_map) 0, @@ -1429,9 +1430,9 @@ JOIN::exec() We can abort sorting after thd->select_limit rows if we there is no WHERE clause for any tables after the sorted one. */ - JOIN_TAB *table= &curr_join->join_tab[curr_join->const_tables+1]; + JOIN_TAB *curr_table= &curr_join->join_tab[curr_join->const_tables+1]; JOIN_TAB *end_table= &curr_join->join_tab[tables]; - for (; table < end_table ; table++) + for (; curr_table < end_table ; curr_table++) { /* table->keyuse is set in the case there was an original WHERE clause @@ -1439,7 +1440,8 @@ JOIN::exec() table->on_expr tells us that it was a LEFT JOIN and there will be at least one row generated from the table. */ - if (table->select_cond || (table->keyuse && !table->on_expr)) + if (curr_table->select_cond || + (curr_table->keyuse && !curr_table->on_expr)) { /* We have to sort all rows */ curr_join->select_limit= HA_POS_ERROR; @@ -1517,11 +1519,11 @@ JOIN::cleanup() 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_UNIT *lex_unit= select_lex->first_inner_unit(); + lex_unit != 0; + lex_unit= lex_unit->next_unit()) { - error|= unit->cleanup(); + error|= lex_unit->cleanup(); } DBUG_RETURN(error); } @@ -4313,10 +4315,11 @@ COND *eliminate_not_funcs(COND *cond) static COND * optimize_cond(COND *conds,Item::cond_result *cond_value) { + DBUG_ENTER("optimize_cond"); if (!conds) { *cond_value= Item::COND_TRUE; - return conds; + DBUG_RETURN(conds); } DBUG_EXECUTE("where",print_where(conds,"original");); /* eliminate NOT operators */ @@ -4331,7 +4334,7 @@ optimize_cond(COND *conds,Item::cond_result *cond_value) DBUG_EXECUTE("where",print_where(conds,"after const change");); conds=remove_eq_conds(conds,cond_value) ; DBUG_EXECUTE("info",print_where(conds,"after remove");); - return conds; + DBUG_RETURN(conds); } @@ -8382,10 +8385,10 @@ bool JOIN::alloc_func_list() } -bool JOIN::make_sum_func_list(List &all_fields, List &send_fields, +bool JOIN::make_sum_func_list(List &field_list, List &send_fields, bool before_group_by) { - List_iterator_fast it(all_fields); + List_iterator_fast it(field_list); Item_sum **func; Item *item; DBUG_ENTER("make_sum_func_list"); @@ -8404,7 +8407,7 @@ bool JOIN::make_sum_func_list(List &all_fields, List &send_fields, if (before_group_by && rollup.state == ROLLUP::STATE_INITED) { rollup.state= ROLLUP::STATE_READY; - if (rollup_make_fields(all_fields, send_fields, &func)) + if (rollup_make_fields(field_list, send_fields, &func)) DBUG_RETURN(TRUE); // Should never happen } else if (rollup.state == ROLLUP::STATE_NONE) @@ -8707,12 +8710,12 @@ bool JOIN::rollup_init() */ for (i= 0 ; i < send_group_parts ; i++) { - List *fields= &rollup.fields[i]; - fields->empty(); + List *rollup_fields= &rollup.fields[i]; + rollup_fields->empty(); rollup.ref_pointer_arrays[i]= ref_array; ref_array+= all_fields.elements; for (j=0 ; j < fields_list.elements ; j++) - fields->push_back(rollup.item_null); + rollup_fields->push_back(rollup.item_null); } return 0; } @@ -8723,8 +8726,8 @@ bool JOIN::rollup_init() SYNOPSIS rollup_make_fields() - all_fields List of all fields (hidden and real ones) - fields Pointer to selected fields + fields_arg List of all fields (hidden and real ones) + sel_fields Pointer to selected fields func Store here a pointer to all fields IMPLEMENTATION: @@ -8736,11 +8739,11 @@ bool JOIN::rollup_init() 1 on error */ -bool JOIN::rollup_make_fields(List &all_fields, List &fields, +bool JOIN::rollup_make_fields(List &fields_arg, List &sel_fields, Item_sum ***func) { - List_iterator_fast it(all_fields); - Item *first_field= fields.head(); + List_iterator_fast it(fields_arg); + Item *first_field= sel_fields.head(); uint level; /* @@ -8775,7 +8778,7 @@ bool JOIN::rollup_make_fields(List &all_fields, List &fields, ORDER *start_group; /* Point to first hidden field */ - Item **ref_array= ref_array_start + all_fields.elements-1; + Item **ref_array= ref_array_start + fields_arg.elements-1; /* Remember where the sum functions ends for the previous level */ sum_funcs_end[pos+1]= *func; @@ -8815,10 +8818,10 @@ bool JOIN::rollup_make_fields(List &all_fields, List &fields, else if (real_fields) { /* Check if this is something that is part of this group by */ - ORDER *group; - for (group= start_group ; group ; group= group->next) + ORDER *group_tmp; + for (group_tmp= start_group ; group_tmp ; group_tmp= group_tmp->next) { - if (*group->item == item) + if (*group_tmp->item == item) { /* This is an element that is used by the GROUP BY and should be @@ -8925,7 +8928,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, DBUG_ENTER("select_describe"); DBUG_PRINT("info", ("Select 0x%lx, type %s, message %s", (ulong)join->select_lex, join->select_lex->type, - message)); + message ? message : "NULL")); /* Don't log this into the slow query log */ select_lex->options&= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED); join->unit->offset_limit_cnt= 0; @@ -9238,8 +9241,8 @@ void st_select_lex::print(THD *thd, String *str) next_on= 0; } - TABLE_LIST *next; - if ((next= table->next)) + TABLE_LIST *next_table; + if ((next_table= table->next)) { if (table->outer_join & JOIN_TYPE_RIGHT) { @@ -9248,9 +9251,9 @@ void st_select_lex::print(THD *thd, String *str) table->on_expr) next_on= table->on_expr; } - else if (next->straight) + else if (next_table->straight) str->append(" straight_join ", 15); - else if (next->outer_join & JOIN_TYPE_LEFT) + else if (next_table->outer_join & JOIN_TYPE_LEFT) str->append(" left join ", 11); else str->append(" join ", 6); @@ -9258,17 +9261,17 @@ void st_select_lex::print(THD *thd, String *str) } } - //where - Item *where= this->where; + // Where + Item *cur_where= where; if (join) - where= join->conds; - if (where) + cur_where= join->conds; + if (cur_where) { str->append(" where ", 7); - where->print(str); + cur_where->print(str); } - //group by & olap + // group by & olap if (group_list.elements) { str->append(" group by ", 10); @@ -9286,15 +9289,15 @@ void st_select_lex::print(THD *thd, String *str) } } - //having - Item *having= this->having; + // having + Item *cur_having= having; if (join) - having= join->having; + cur_having= join->having; - if (having) + if (cur_having) { str->append(" having ", 8); - having->print(str); + cur_having->print(str); } if (order_list.elements) diff --git a/sql/sql_select.h b/sql/sql_select.h index 2e101c78613..7cc71117914 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -207,14 +207,14 @@ class JOIN :public Sql_alloc bool union_part; // this subselect is part of union bool optimized; // flag to avoid double optimization in EXPLAIN - JOIN(THD *thd_arg, List &fields, ulong select_options_arg, + JOIN(THD *thd_arg, List &fields_arg, ulong select_options_arg, select_result *result_arg) - :fields_list(fields) + :fields_list(fields_arg) { - init(thd_arg, fields, select_options_arg, result_arg); + init(thd_arg, fields_arg, select_options_arg, result_arg); } - void init(THD *thd_arg, List &fields, ulong select_options_arg, + void init(THD *thd_arg, List &fields_arg, ulong select_options_arg, select_result *result_arg) { join_tab= join_tab_save= 0; @@ -247,8 +247,8 @@ class JOIN :public Sql_alloc hidden_group_fields= 0; /*safety*/ buffer_result= test(select_options & OPTION_BUFFER_RESULT) && !test(select_options & OPTION_FOUND_ROWS); - all_fields= fields; - fields_list= fields; + all_fields= fields_arg; + fields_list= fields_arg; error= 0; select= 0; ref_pointer_array= items0= items1= items2= items3= 0; @@ -256,7 +256,7 @@ class JOIN :public Sql_alloc zero_result_cause= 0; optimized= 0; - fields_list= fields; + fields_list= fields_arg; bzero((char*) &keyuse,sizeof(keyuse)); tmp_table_param.copy_field=0; tmp_table_param.end_write_records= HA_POS_ERROR; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 56713e42244..f2470a59944 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -106,9 +106,9 @@ bool select_union::flush() } -int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) +int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result) { - SELECT_LEX *lex_select_save= thd->lex.current_select; + SELECT_LEX *lex_select_save= thd_arg->lex.current_select; SELECT_LEX *sl, *first_select; select_result *tmp_result; DBUG_ENTER("st_select_lex_unit::prepare"); @@ -123,10 +123,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) DBUG_RETURN(0); prepared= 1; res= 0; - TMP_TABLE_PARAM tmp_table_param; - bzero((char *)&tmp_table_param,sizeof(TMP_TABLE_PARAM)); - thd->lex.current_select= sl= first_select= first_select_in_union(); + thd_arg->lex.current_select= sl= first_select= first_select_in_union(); found_rows_for_union= first_select->options & OPTION_FOUND_ROWS; /* Global option */ @@ -136,7 +134,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) if (!(tmp_result= union_result= new select_union(0))) goto err; union_result->not_describe= 1; - union_result->tmp_table_param= tmp_table_param; + union_result->tmp_table_param.init(); } else { @@ -147,10 +145,10 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) for (;sl; sl= sl->next_select()) { - JOIN *join= new JOIN(thd, sl->item_list, - sl->options | thd->options | SELECT_NO_UNLOCK, + JOIN *join= new JOIN(thd_arg, sl->item_list, + sl->options | thd_arg->options | SELECT_NO_UNLOCK, tmp_result); - thd->lex.current_select= sl; + thd_arg->lex.current_select= sl; offset_limit_cnt= sl->offset_limit; select_limit_cnt= sl->select_limit+sl->offset_limit; if (select_limit_cnt < sl->select_limit) @@ -169,19 +167,19 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) sl->having, (ORDER*) NULL, sl, this); - if (res || thd->is_fatal_error) + if (res || thd_arg->is_fatal_error) goto err; if (sl == first_select) { types.empty(); List_iterator_fast it(sl->item_list); - Item *item; - while((item= it++)) + Item *item_tmp; + while ((item_tmp= it++)) { - types.push_back(new Item_type_holder(thd, item)); + types.push_back(new Item_type_holder(thd_arg, item_tmp)); } - if (thd->is_fatal_error) + if (thd_arg->is_fatal_error) goto err; // out of memory } else @@ -194,10 +192,10 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) } List_iterator_fast it(sl->item_list); List_iterator_fast tp(types); - Item *type, *item; - while((type= tp++, item= it++)) + Item *type, *item_tmp; + while ((type= tp++, item_tmp= it++)) { - if (((Item_type_holder*)type)->join_types(thd, item)) + if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp)) DBUG_RETURN(-1); } } @@ -205,11 +203,12 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) if (first_select->next_select()) { - tmp_table_param.field_count= types.elements; - if (!(table= create_tmp_table(thd, &tmp_table_param, types, + union_result->tmp_table_param.field_count= types.elements; + if (!(table= create_tmp_table(thd_arg, + &union_result->tmp_table_param, types, (ORDER*) 0, !union_option, 1, (first_select_in_union()->options | - thd->options | + thd_arg->options | TMP_TABLE_ALL_COLUMNS), HA_POS_ERROR, (char*) ""))) goto err; @@ -222,7 +221,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) union_result->set_table(table); item_list.empty(); - thd->lex.current_select= lex_select_save; + thd_arg->lex.current_select= lex_select_save; { Field **field; for (field= table->field; *field; field++) @@ -235,12 +234,12 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result) else first_select->braces= 0; // remove our changes - thd->lex.current_select= lex_select_save; + thd_arg->lex.current_select= lex_select_save; - DBUG_RETURN(res || thd->is_fatal_error ? 1 : 0); + DBUG_RETURN(res || thd_arg->is_fatal_error ? 1 : 0); err: - thd->lex.current_select= lex_select_save; + thd_arg->lex.current_select= lex_select_save; DBUG_RETURN(-1); } @@ -375,7 +374,7 @@ int st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { - ulong options= thd->options; + ulong options_tmp= thd->options; thd->lex.current_select= fake_select_lex; offset_limit_cnt= global_parameters->offset_limit; select_limit_cnt= global_parameters->select_limit + @@ -384,9 +383,9 @@ int st_select_lex_unit::exec() if (select_limit_cnt < global_parameters->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit if (select_limit_cnt == HA_POS_ERROR) - options&= ~OPTION_FOUND_ROWS; + options_tmp&= ~OPTION_FOUND_ROWS; else if (found_rows_for_union && !thd->lex.describe) - options|= OPTION_FOUND_ROWS; + options_tmp|= OPTION_FOUND_ROWS; fake_select_lex->ftfunc_list= &empty_list; fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) @@ -421,7 +420,7 @@ int st_select_lex_unit::exec() global_parameters->order_list.elements, (ORDER*)global_parameters->order_list.first, (ORDER*) NULL, NULL, (ORDER*) NULL, - options | SELECT_NO_UNLOCK, + options_tmp | SELECT_NO_UNLOCK, result, this, fake_select_lex); if (!res) thd->limit_found_rows = (ulonglong)table->file->records + add_rows; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 8b77f6958d0..d623ea66dfb 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -481,7 +481,8 @@ multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list, Connect fields with tables and create list of tables that are updated */ -int multi_update::prepare(List ¬_used_values, SELECT_LEX_UNIT *unit) +int multi_update::prepare(List ¬_used_values, + SELECT_LEX_UNIT *lex_unit) { TABLE_LIST *table_ref; SQL_LIST update; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b944dc3955c..805dc9f1932 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -688,7 +688,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); insert_values update delete truncate rename show describe load alter optimize keycache preload flush reset purge begin commit rollback savepoint - slave master_def master_defs master_file_def + slave master_def master_defs master_file_def slave_until_opts repair restore backup analyze check start checksum field_list field_list_item field_spec kill column_def key_def keycache_list assign_to_keycache preload_list preload_keys -- cgit v1.2.1