diff options
author | unknown <monty@mysql.com> | 2003-11-20 22:06:25 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2003-11-20 22:06:25 +0200 |
commit | 35da5e43fbd3653c39358669365e2c329e1e555c (patch) | |
tree | 685b3a2a60fc00121d338cb0b5f84b4cd028bfe1 /sql | |
parent | f25cbdd9141004e6e9f0a7313d763c1cc1de36ec (diff) | |
download | mariadb-git-35da5e43fbd3653c39358669365e2c329e1e555c.tar.gz |
Merge key cache structures to one
Fixed compiler warnings (IRIX C compiler and VC++)
VC++Files/client/mysqlclient.dsp:
Add missing file to project
VC++Files/libmysql/libmysql.dsp:
Add missing file to project
VC++Files/myisam/myisam.dsp:
Add missing file to project
VC++Files/mysys/mysys.dsp:
Add missing file to project
heap/hp_test1.c:
Fixed wrong call to heap_rkey()
heap/hp_test2.c:
Fixed wrong call to heap_rkey()
include/hash.h:
Move not used (internal) struct to hash.c
include/my_pthread.h:
Made some structs 'const char*' to avoid warnings
include/my_sys.h:
Moved key cache structs and functions to keycache.h
include/myisam.h:
Merge key cache structures to one
include/mysql.h:
Remove STDCALL from internal functions
include/sql_common.h:
Remove STDCALL from internal functions
include/violite.h:
Fixed compiler warning
isam/_locking.c:
Merge key cache structures to one
isam/_page.c:
Merge key cache structures to one
isam/close.c:
Merge key cache structures to one
isam/extra.c:
Merge key cache structures to one
isam/isamchk.c:
Merge key cache structures to one
isam/isamdef.h:
Merge key cache structures to one
isam/isamlog.c:
Merge key cache structures to one
isam/panic.c:
Merge key cache structures to one
isam/test2.c:
Merge key cache structures to one
isam/test3.c:
Merge key cache structures to one
libmysql/client_settings.h:
Remove STDCALL from internal functions
libmysql/libmysql.c:
Remove STDCALL from internal functions
myisam/ft_boolean_search.c:
Fixed compiler warning
myisam/ft_dump.c:
Fixed compiler warnings (%qx is not portable)
myisam/ft_update.c:
Fixed compiler warnings
myisam/mi_check.c:
Merge key cache structures to one
myisam/mi_close.c:
Merge key cache structures to one
myisam/mi_delete_all.c:
Merge key cache structures to one
myisam/mi_extra.c:
Merge key cache structures to one
myisam/mi_keycache.c:
Merge key cache structures to one
myisam/mi_locking.c:
Merge key cache structures to one
myisam/mi_page.c:
Merge key cache structures to one
myisam/mi_panic.c:
Merge key cache structures to one
myisam/mi_preload.c:
Merge key cache structures to one
myisam/mi_test1.c:
Merge key cache structures to one
myisam/mi_test2.c:
Merge key cache structures to one
myisam/mi_test3.c:
Merge key cache structures to one
myisam/myisamchk.c:
Merge key cache structures to one
myisam/myisamdef.h:
Merge key cache structures to one
myisam/myisamlog.c:
Merge key cache structures to one
Removed not used option
myisam/sort.c:
Fixed compiler warnings
myisam/sp_test.c:
Fixed compiler warnings
mysql-test/r/case.result:
Updated results after fix of correct NULL detection in WHEN
mysql-test/r/date_formats.result:
Updated results after fixing date handling
mysql-test/r/symlink.result:
Updated results after adding DEFAULT CHARSET
mysql-test/t/case.test:
New test
mysql-test/t/symlink.test:
Updated error numbers
mysys/hash.c:
Made HASH_LINK struct local
mysys/mf_keycache.c:
Merge key cache structures to one
Fixed key_cache_read() and key_cache_write() to be resize-safe.
mysys/mf_keycaches.c:
Merge key cache structures to one
mysys/thr_mutex.c:
Added test if mutex is initalized
sql-common/client.c:
Remove STDCALL from internal functions
sql/derror.cc:
Added comment
sql/field.cc:
Removed not used variables
sql/ha_innodb.cc:
Fixed compiler warnings (removed not used variables)
sql/ha_myisam.cc:
Merge key cache structures to one
sql/ha_myisammrg.cc:
Removed not used variables
sql/handler.cc:
Merge key cache structures to one
sql/handler.h:
Merge key cache structures to one
sql/item.cc:
Fixed compiler warning
sql/item_cmpfunc.cc:
Remove not used variables
sql/item_func.cc:
Remove not used variables
sql/item_strfunc.cc:
Removed not used variables
sql/item_sum.cc:
Removed not used variables
Moved setting of item_thd to fix_fields()
sql/item_timefunc.cc:
Removed not used variables
sql/mysql_priv.h:
Merge key cache structures to one
sql/mysqld.cc:
Merge key cache structures to one
init_thread_environment() is not called before mysql_init_variables(). This fixes a case where a mutex was not initialized before it was used
sql/opt_sum.cc:
Remove not used variables
sql/protocol.cc:
Don't send errors after ok has been sent
sql/protocol_cursor.cc:
Remove not used variable
Simple optimization
sql/repl_failsafe.cc:
Remove not used variables
sql/set_var.cc:
Merge key cache structures to one
sql/set_var.h:
Merge key cache structures to one
sql/sql_acl.cc:
Remove not used variables
sql/sql_base.cc:
Remove not used function
sql/sql_db.cc:
Remove not used variables
sql/sql_handler.cc:
Remove not used variables
sql/sql_insert.cc:
More DBUG statements
Simple code cleanup
sql/sql_lex.cc:
Remove not used variables
sql/sql_parse.cc:
Remove not used variables
sql/sql_prepare.cc:
Remove not used variables
sql/sql_repl.cc:
Remove not used variables
sql/sql_select.cc:
Remove not used variables
sql/sql_show.cc:
Remove not used variables
sql/sql_table.cc:
Merge key cache structures to one
Removed not used variables
sql/sql_test.cc:
Merge key cache structures to one
sql/strfunc.cc:
Fixed that find_type() returns correct value for partly matched words.
(This fixed the error found by date_formats.test)
sql/time.cc:
Remove not used variables
strings/my_strtoll10.c:
Fixed compiler warnings
Diffstat (limited to 'sql')
-rw-r--r-- | sql/derror.cc | 1 | ||||
-rw-r--r-- | sql/field.cc | 3 | ||||
-rw-r--r-- | sql/ha_innodb.cc | 4 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 3 | ||||
-rw-r--r-- | sql/ha_myisammrg.cc | 5 | ||||
-rw-r--r-- | sql/handler.cc | 53 | ||||
-rw-r--r-- | sql/handler.h | 16 | ||||
-rw-r--r-- | sql/item.cc | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 13 | ||||
-rw-r--r-- | sql/item_func.cc | 3 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 5 | ||||
-rw-r--r-- | sql/item_sum.cc | 6 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 7 | ||||
-rw-r--r-- | sql/mysql_priv.h | 9 | ||||
-rw-r--r-- | sql/mysqld.cc | 43 | ||||
-rw-r--r-- | sql/opt_sum.cc | 1 | ||||
-rw-r--r-- | sql/protocol.cc | 2 | ||||
-rw-r--r-- | sql/protocol_cursor.cc | 6 | ||||
-rw-r--r-- | sql/repl_failsafe.cc | 1 | ||||
-rw-r--r-- | sql/set_var.cc | 59 | ||||
-rw-r--r-- | sql/set_var.h | 12 | ||||
-rw-r--r-- | sql/sql_acl.cc | 6 | ||||
-rw-r--r-- | sql/sql_base.cc | 1 | ||||
-rw-r--r-- | sql/sql_db.cc | 1 | ||||
-rw-r--r-- | sql/sql_handler.cc | 1 | ||||
-rw-r--r-- | sql/sql_insert.cc | 24 | ||||
-rw-r--r-- | sql/sql_lex.cc | 6 | ||||
-rw-r--r-- | sql/sql_parse.cc | 3 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 2 | ||||
-rw-r--r-- | sql/sql_repl.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/sql_show.cc | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 10 | ||||
-rw-r--r-- | sql/sql_test.cc | 14 | ||||
-rw-r--r-- | sql/strfunc.cc | 2 | ||||
-rw-r--r-- | sql/time.cc | 1 |
36 files changed, 156 insertions, 177 deletions
diff --git a/sql/derror.cc b/sql/derror.cc index ad7432f7675..53d0dc5b7e5 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -75,6 +75,7 @@ Please install the latest version of this file.",name); goto err1; } + /* TODO: Convert the character set to server system character set */ if (!(cset= get_charset(head[30],MYF(MY_WME)))) { sql_print_error("Character set #%d is not supported for messagefile '%s'", diff --git a/sql/field.cc b/sql/field.cc index befa9993b05..70b8ce6c080 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2850,7 +2850,7 @@ String *Field_timestamp::val_str(String *val_buffer, struct tm tm_tmp; val_buffer->alloc(field_length+1); - char *to=(char*) val_buffer->ptr(),*end=to+field_length; + char *to= (char*) val_buffer->ptr(); val_buffer->length(field_length); #ifdef WORDS_BIGENDIAN @@ -3987,7 +3987,6 @@ longlong Field_string::val_int(void) String *Field_string::val_str(String *val_buffer __attribute__((unused)), String *val_ptr) { - char *end=ptr+field_length; uint length= field_charset->cset->lengthsp(field_charset, ptr, field_length); val_ptr->set((const char*) ptr, length, field_charset); return val_ptr; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 7f8c99f7c15..f79c5b55927 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -546,7 +546,6 @@ innobase_query_caching_of_table_permitted( { ibool is_autocommit; trx_t* trx; - char* ptr; char norm_name[1000]; ut_a(full_name_len < 999); @@ -606,7 +605,7 @@ innobase_query_caching_of_table_permitted( #ifdef __WIN__ /* Put to lower case */ - ptr = norm_name; + char* ptr = norm_name; while (*ptr != '\0') { *ptr = tolower(*ptr); @@ -1391,7 +1390,6 @@ ha_innobase::open( uint test_if_locked) /* in: not used */ { dict_table_t* ib_table; - int error = 0; char norm_name[1000]; DBUG_ENTER("ha_innobase::open"); diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 0f22a83a2b4..3cdd923d085 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -226,7 +226,6 @@ err: int ha_myisam::open(const char *name, int mode, uint test_if_locked) { - KEY_CACHE_VAR *key_cache; if (!(file=mi_open(name, mode, test_if_locked))) return (my_errno ? my_errno : -1); @@ -698,7 +697,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) { - KEY_CACHE_VAR *new_key_cache= check_opt->key_cache; + KEY_CACHE *new_key_cache= check_opt->key_cache; const char *errmsg= 0; int error= HA_ADMIN_OK; ulonglong map= ~(ulonglong) 0; diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index a834ace7032..3cd5d96d5f3 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -39,7 +39,6 @@ const char **ha_myisammrg::bas_ext() const int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) { char name_buff[FN_REFLEN]; - KEY_CACHE_VAR *key_cache; DBUG_PRINT("info", ("ha_myisammrg::open")); if (!(file=myrg_open(fn_format(name_buff,name,"","",2 | 4), mode, @@ -312,11 +311,11 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd, static void split_file_name(const char *file_name, LEX_STRING *db, LEX_STRING *name) { - uint name_length, dir_length, prefix_length; + uint dir_length, prefix_length; char buff[FN_REFLEN]; db->length= 0; - name_length= (uint) (strmake(buff, file_name, sizeof(buff)-1) - buff); + strmake(buff, file_name, sizeof(buff)-1); dir_length= dirname_length(buff); if (dir_length > 1) { diff --git a/sql/handler.cc b/sql/handler.cc index 56db355f45e..5267ddc8986 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1132,20 +1132,22 @@ void st_ha_check_opt::init() /* Init a key cache if it has not been initied before */ -int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache) +int ha_init_key_cache(const char *name, KEY_CACHE *key_cache) { DBUG_ENTER("ha_init_key_cache"); - if (!key_cache->cache) + if (!key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->buff_size; - long tmp_block_size= (long) key_cache->block_size; + long tmp_buff_size= (long) key_cache->param_buff_size; + long tmp_block_size= (long) key_cache->param_block_size; + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; pthread_mutex_unlock(&LOCK_global_system_variables); - DBUG_RETURN(!init_key_cache(&key_cache->cache, + DBUG_RETURN(!init_key_cache(key_cache, tmp_block_size, tmp_buff_size, - key_cache)); + division_limit, age_threshold)); } DBUG_RETURN(0); } @@ -1153,18 +1155,21 @@ int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache) /* Resize key cache */ -int ha_resize_key_cache(KEY_CACHE_VAR *key_cache) +int ha_resize_key_cache(KEY_CACHE *key_cache) { DBUG_ENTER("ha_resize_key_cache"); - if (key_cache->cache) + if (key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->buff_size; - long tmp_block_size= (long) key_cache->block_size; + long tmp_buff_size= (long) key_cache->param_buff_size; + long tmp_block_size= (long) key_cache->param_block_size; + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; pthread_mutex_unlock(&LOCK_global_system_variables); - DBUG_RETURN(!resize_key_cache(&key_cache->cache, tmp_block_size, - tmp_buff_size)); + DBUG_RETURN(!resize_key_cache(key_cache, tmp_block_size, + tmp_buff_size, + division_limit, age_threshold)); } DBUG_RETURN(0); } @@ -1172,29 +1177,31 @@ int ha_resize_key_cache(KEY_CACHE_VAR *key_cache) /* Change parameters for key cache (like size) */ -int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache) +int ha_change_key_cache_param(KEY_CACHE *key_cache) { - if (key_cache->cache) - change_key_cache_param(key_cache->cache); + if (key_cache->key_cache_inited) + { + pthread_mutex_lock(&LOCK_global_system_variables); + uint division_limit= key_cache->param_division_limit; + uint age_threshold= key_cache->param_age_threshold; + pthread_mutex_unlock(&LOCK_global_system_variables); + change_key_cache_param(key_cache, division_limit, age_threshold); + } return 0; } /* Free memory allocated by a key cache */ -int ha_end_key_cache(KEY_CACHE_VAR *key_cache) +int ha_end_key_cache(KEY_CACHE *key_cache) { - if (key_cache->cache) - { - end_key_cache(key_cache->cache, 1); // Can never fail - key_cache->cache= 0; - } + end_key_cache(key_cache, 1); // Can never fail return 0; } /* Move all tables from one key cache to another one */ -int ha_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache) +int ha_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache) { mi_change_key_cache(old_key_cache, new_key_cache); return 0; diff --git a/sql/handler.h b/sql/handler.h index 40773c67605..9089db60d77 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -22,6 +22,7 @@ #endif #include <ft_global.h> +#include <keycache.h> #ifndef NO_HASH #define NO_HASH /* Not yet implemented */ @@ -181,14 +182,13 @@ typedef struct st_ha_create_information struct st_table; typedef struct st_table TABLE; -typedef struct st_key_cache_asmt KEY_CACHE_ASMT; typedef struct st_ha_check_opt { ulong sort_buffer_size; uint flags; /* isam layer flags (e.g. for myisamchk) */ uint sql_flags; /* sql layer flags - for something myisamchk cannot do */ - KEY_CACHE_VAR *key_cache; /* new key cache when changing key cache */ + KEY_CACHE *key_cache; /* new key cache when changing key cache */ void init(); } HA_CHECK_OPT; @@ -394,10 +394,10 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, bool update_create_info); int ha_delete_table(enum db_type db_type, const char *path); void ha_drop_database(char* path); -int ha_init_key_cache(const char *name, KEY_CACHE_VAR *key_cache); -int ha_resize_key_cache(KEY_CACHE_VAR *key_cache); -int ha_change_key_cache_param(KEY_CACHE_VAR *key_cache); -int ha_end_key_cache(KEY_CACHE_VAR *key_cache); +int ha_init_key_cache(const char *name, KEY_CACHE *key_cache); +int ha_resize_key_cache(KEY_CACHE *key_cache); +int ha_change_key_cache_param(KEY_CACHE *key_cache); +int ha_end_key_cache(KEY_CACHE *key_cache); int ha_start_stmt(THD *thd); int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name, my_off_t end_offset); @@ -411,5 +411,5 @@ int ha_autocommit_or_rollback(THD *thd, int error); void ha_set_spin_retries(uint retries); bool ha_flush_logs(void); int ha_recovery_logging(THD *thd, bool on); -int ha_change_key_cache(KEY_CACHE_VAR *old_key_cache, - KEY_CACHE_VAR *new_key_cache); +int ha_change_key_cache(KEY_CACHE *old_key_cache, + KEY_CACHE *new_key_cache); diff --git a/sql/item.cc b/sql/item.cc index d76ab529db5..f41cb720f12 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1347,7 +1347,7 @@ bool Item::send(Protocol *protocol, String *buffer) case MYSQL_TYPE_FLOAT: { float nr; - nr= val(); + nr= (float) val(); if (!null_value) result= protocol->store(nr, decimals, buffer); break; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 64d6b5fa7cf..792f99a686b 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -397,13 +397,12 @@ int Arg_comparator::compare_row() int Arg_comparator::compare_e_row() { - int res= 0; (*a)->bring_value(); (*b)->bring_value(); uint n= (*a)->cols(); for (uint i= 0; i<n; i++) { - if ((res= !comparators[i].compare())) + if (!comparators[i].compare()) return 0; } return 1; @@ -1096,8 +1095,10 @@ void Item_func_case::fix_length_and_dec() return; - // Aggregate first expression and all THEN expression types - // and collations when string comparison + /* + Aggregate first expression and all THEN expression types + and collations when string comparison + */ if (first_expr_num != -1) { agg[0]= args[first_expr_num]; @@ -1110,7 +1111,7 @@ void Item_func_case::fix_length_and_dec() return; } - if (!else_expr_num != -1 || args[else_expr_num]->maybe_null) + if (else_expr_num == -1 || args[else_expr_num]->maybe_null) maybe_null=1; max_length=0; @@ -1127,6 +1128,7 @@ void Item_func_case::fix_length_and_dec() } } + /* TODO: Fix this so that it prints the whole CASE expression */ void Item_func_case::print(String *str) @@ -1538,7 +1540,6 @@ void Item_func_in::fix_length_and_dec() { switch (cmp_type) { case STRING_RESULT: - uint i; array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in, cmp_collation.collation); break; diff --git a/sql/item_func.cc b/sql/item_func.cc index c42019a9fbb..2a07341d97a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2321,9 +2321,7 @@ String *user_var_entry::val_str(my_bool *null_value, String *str, bool Item_func_set_user_var::check() { - bool res; DBUG_ENTER("Item_func_set_user_var::check"); - LINT_INIT(res); switch (cached_result_type) { case REAL_RESULT: @@ -3013,7 +3011,6 @@ longlong Item_func_is_free_lock::val_int() String *res=args[0]->val_str(&value); THD *thd=current_thd; ULL *ull; - int error=0; null_value=0; if (!res || !res->length()) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index dfaf3001a19..f40d38dd4a8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -324,7 +324,6 @@ null: void Item_func_concat::fix_length_and_dec() { - bool first_coll= 1; max_length=0; if (agg_arg_collations(collation, args, arg_count)) @@ -2018,7 +2017,7 @@ void Item_func_lpad::fix_length_and_dec() String *Item_func_lpad::val_str(String *str) { - uint32 res_byte_length,res_char_length,pad_byte_length,pad_char_length; + uint32 res_char_length,pad_char_length; ulong count= (long) args[1]->val_int(), byte_count; String a1,a3; String *res= args[0]->val_str(&a1); @@ -2028,7 +2027,6 @@ String *Item_func_lpad::val_str(String *str) goto err; null_value=0; - res_byte_length= res->length(); res_char_length= res->numchars(); if (count <= res_char_length) @@ -2037,7 +2035,6 @@ String *Item_func_lpad::val_str(String *str) return res; } - pad_byte_length= pad->length(); pad_char_length= pad->numchars(); byte_count= count * collation.collation->mbmaxlen; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 74dd95bf0ab..a3d67e9f7fa 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1642,10 +1642,8 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct, original= 0; quick_group= 0; mark_as_sum_func(); - item_thd= current_thd; - SELECT_LEX *select_lex= item_thd->lex.current_select; order= 0; - group_concat_max_len= item_thd->variables.group_concat_max_len; + group_concat_max_len= current_thd->variables.group_concat_max_len; arg_show_fields= arg_count_field= is_select->elements; @@ -1791,6 +1789,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) thd->allow_sum_func= 0; maybe_null= 0; + item_thd= thd; for (i= 0 ; i < arg_count ; i++) { if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1)) @@ -1969,6 +1968,7 @@ String* Item_func_group_concat::val_str(String* str) return &result; } + void Item_func_group_concat::print(String *str) { str->append("group_concat(", 13); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index bcb7ddb1054..e73ecc99ffe 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -137,14 +137,12 @@ static bool make_datetime(date_time_format_types format, TIME *ltime, static bool extract_date_time(DATE_TIME_FORMAT *format, const char *val, uint length, TIME *l_time) { - int weekday= 0, yearday= 0, daypart= 0, len; + int weekday= 0, yearday= 0, daypart= 0; int week_number= -1; CHARSET_INFO *cs= &my_charset_bin; int error= 0; bool usa_time= 0; bool sunday_first= 0; - uint part_len= 0; - const char *val_ptr= val; const char *val_end= val + length; const char *ptr= format->format.str; const char *end= ptr+ format->format.length; @@ -1385,7 +1383,6 @@ String *Item_func_from_unixtime::val_str(String *str) { struct tm tm_tmp,*start; time_t tmp=(time_t) args[0]->val_int(); - CHARSET_INFO *cs= &my_charset_bin; TIME ltime; if ((null_value=args[0]->null_value)) @@ -1759,6 +1756,7 @@ bool Item_extract::eq(const Item *item, bool binary_cmp) const return 1; } + void Item_typecast::print(String *str) { str->append("cast(", 5); @@ -1768,6 +1766,7 @@ void Item_typecast::print(String *str) str->append(')'); } + void Item_char_typecast::print(String *str) { str->append("cast(", 5); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 9bc32581f32..b9032381c45 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -432,8 +432,6 @@ bool check_stack_overrun(THD *thd,char *dummy); void table_cache_init(void); void table_cache_free(void); uint cached_tables(void); -void reassign_key_cache(KEY_CACHE_ASMT *key_cache_asmt, - KEY_CACHE_VAR *new_key_cache); void kill_mysql(void); void close_connection(THD *thd, uint errcode, bool lock); bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, @@ -466,8 +464,8 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* table_list, int mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, LEX_STRING *key_cache_name); int mysql_preload_keys(THD* thd, TABLE_LIST* table_list); -int reassign_keycache_tables(THD* thd, KEY_CACHE_VAR *src_cache, - KEY_CACHE_VAR *dst_cache); +int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, + KEY_CACHE *dst_cache); bool check_simple_select(); @@ -870,8 +868,7 @@ extern SHOW_COMP_OPTION have_berkeley_db; extern struct system_variables global_system_variables; extern struct system_variables max_system_variables; extern struct rand_struct sql_rand; -extern KEY_CACHE_VAR *sql_key_cache; -extern KEY_CACHE_HANDLE sql_key_cache_handle; +extern KEY_CACHE *sql_key_cache; extern const char *opt_date_time_formats[]; extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f26f18418a8..a0b5d910986 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -355,7 +355,7 @@ struct system_variables max_system_variables; MY_TMPDIR mysql_tmpdir_list; MY_BITMAP temp_pool; -KEY_CACHE_VAR *sql_key_cache; +KEY_CACHE *sql_key_cache; CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *national_charset_info, *table_alias_charset; @@ -1565,14 +1565,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\ the problem, but since we have already crashed, something is definitely wrong\n\ and this may fail.\n\n"); fprintf(stderr, "key_buffer_size=%lu\n", - (ulong) sql_key_cache->buff_size); + (ulong) sql_key_cache->key_cache_mem_size); fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size); fprintf(stderr, "max_used_connections=%ld\n", max_used_connections); fprintf(stderr, "max_connections=%ld\n", max_connections); fprintf(stderr, "threads_connected=%d\n", thread_count); fprintf(stderr, "It is possible that mysqld could use up to \n\ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\ -bytes of memory\n", ((ulong) sql_key_cache->buff_size + +bytes of memory\n", ((ulong) sql_key_cache->key_cache_mem_size + (global_system_variables.read_buff_size + global_system_variables.sortbuff_size) * max_connections)/ 1024); @@ -2037,7 +2037,6 @@ bool init_global_datetime_format(timestamp_type format_type, { /* Get command line option */ const char *str= opt_date_time_formats[format_type]; - DATE_TIME_FORMAT *format; if (!str) // No specified format { @@ -2068,6 +2067,8 @@ static int init_common_variables(const char *conf_file_name, int argc, max_system_variables.pseudo_thread_id= (ulong)~0; start_time=time((time_t*) 0); + if (init_thread_environment()) + return 1; mysql_init_variables(); #ifdef OS2 @@ -2111,8 +2112,6 @@ static int init_common_variables(const char *conf_file_name, int argc, load_defaults(conf_file_name, groups, &argc, &argv); defaults_argv=argv; get_options(argc,argv); - if (init_thread_environment()) - return 1; if (opt_log || opt_update_log || opt_slow_log || opt_bin_log) strcat(server_version,"-log"); DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname, @@ -2326,7 +2325,7 @@ Now disabling --log-slave-updates."); /* call ha_init_key_cache() on all key caches to init them */ process_key_caches(&ha_init_key_cache); /* We must set dflt_key_cache in case we are using ISAM tables */ - dflt_keycache= &sql_key_cache->cache; + dflt_key_cache= sql_key_cache; #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) if (locked_in_memory && !geteuid()) @@ -4316,26 +4315,26 @@ replicating a LOAD DATA INFILE command.", IO_SIZE, 0}, {"key_buffer_size", OPT_KEY_BUFFER_SIZE, "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", - (gptr*) &dflt_key_cache_var.buff_size, + (gptr*) &dflt_key_cache_var.param_buff_size, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "The default size of key cache blocks", - (gptr*) &dflt_key_cache_var.block_size, + (gptr*) &dflt_key_cache_var.param_block_size, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, "The minimum percentage of warm blocks in key cache", - (gptr*) &dflt_key_cache_var.division_limit, + (gptr*) &dflt_key_cache_var.param_division_limit, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 1, 100, 0, 1, 0}, {"key_cache_division_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", - (gptr*) &dflt_key_cache_var.age_threshold, + (gptr*) &dflt_key_cache_var.param_age_threshold, (gptr*) 0, 0, (enum get_opt_var_type) (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 300, 100, ~0L, 0, 100, 0}, @@ -4757,17 +4756,17 @@ struct show_var_st status_vars[]= { {"Handler_rollback", (char*) &ha_rollback_count, SHOW_LONG}, {"Handler_update", (char*) &ha_update_count, SHOW_LONG}, {"Handler_write", (char*) &ha_write_count, SHOW_LONG}, - {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.blocks_changed, + {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG}, - {"Key_blocks_used", (char*) &dflt_key_cache_var.blocks_used, + {"Key_blocks_used", (char*) &dflt_key_cache_var.global_blocks_used, SHOW_KEY_CACHE_LONG}, - {"Key_read_requests", (char*) &dflt_key_cache_var.cache_r_requests, + {"Key_read_requests", (char*) &dflt_key_cache_var.global_cache_r_requests, SHOW_KEY_CACHE_LONG}, - {"Key_reads", (char*) &dflt_key_cache_var.cache_read, + {"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONG}, - {"Key_write_requests", (char*) &dflt_key_cache_var.cache_w_requests, + {"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONG}, - {"Key_writes", (char*) &dflt_key_cache_var.cache_write, + {"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONG}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_CONST}, @@ -5608,18 +5607,18 @@ mysql_getopt_value(const char *keyname, uint key_length, case OPT_KEY_CACHE_DIVISION_LIMIT: case OPT_KEY_CACHE_AGE_THRESHOLD: { - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; if (!(key_cache= get_or_create_key_cache(keyname, key_length))) exit(1); switch (option->id) { case OPT_KEY_BUFFER_SIZE: - return (gptr*) &key_cache->buff_size; + return (gptr*) &key_cache->param_buff_size; case OPT_KEY_CACHE_BLOCK_SIZE: - return (gptr*) &key_cache->block_size; + return (gptr*) &key_cache->param_block_size; case OPT_KEY_CACHE_DIVISION_LIMIT: - return (gptr*) &key_cache->division_limit; + return (gptr*) &key_cache->param_division_limit; case OPT_KEY_CACHE_AGE_THRESHOLD: - return (gptr*) &key_cache->age_threshold; + return (gptr*) &key_cache->param_age_threshold; } } } diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 932aceebdbb..4fdcd093132 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -83,7 +83,6 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) table_map removed_tables= 0, outer_tables= 0, used_tables= 0; table_map where_tables= 0; Item *item; - COND *org_conds= conds; int error; if (conds) diff --git a/sql/protocol.cc b/sql/protocol.cc index 884569d334a..e1347ff3c6f 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -302,6 +302,8 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos=net_store_data((char*) pos, message, strlen(message)); VOID(my_net_write(net,buff,(uint) (pos-buff))); VOID(net_flush(net)); + /* We can't anymore send an error to the client */ + thd->net.report_error= 0; DBUG_VOID_RETURN; } diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 19e3bb06d74..563a2d41019 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -30,7 +30,7 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flag) { List_iterator_fast<Item> it(*list); Item *item; - MYSQL_FIELD *field, *client_field; + MYSQL_FIELD *client_field; DBUG_ENTER("send_fields"); if (prepare_for_send(list)) @@ -71,9 +71,9 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flag) String tmp(buff, sizeof(buff), default_charset_info), *res; if (!(res=item->val_str(&tmp))) - client_field->def= strdup_root(alloc, ""); + client_field->def= (char*) ""; else - client_field->def= strdup_root(alloc, tmp.ptr()); + client_field->def= strmake_root(alloc, res->ptr(), res->length()); } else client_field->def=0; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index aba887be070..776262be500 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -623,7 +623,6 @@ err: int show_slave_hosts(THD* thd) { List<Item> field_list; - NET* net = &thd->net; Protocol *protocol= thd->protocol; DBUG_ENTER("show_slave_hosts"); diff --git a/sql/set_var.cc b/sql/set_var.cc index 9a4543ada00..a7d077d8fc2 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -92,7 +92,7 @@ static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type); static void fix_max_relay_log_size(THD *thd, enum_var_type type); static void fix_max_connections(THD *thd, enum_var_type type); -static KEY_CACHE_VAR *create_key_cache(const char *name, uint length); +static KEY_CACHE *create_key_cache(const char *name, uint length); void fix_sql_mode_var(THD *thd, enum_var_type type); static byte *get_error_count(THD *thd); static byte *get_warning_count(THD *thd); @@ -144,14 +144,14 @@ sys_var_thd_ulong sys_join_buffer_size("join_buffer_size", &SV::join_buff_size); sys_var_key_buffer_size sys_key_buffer_size("key_buffer_size"); sys_var_key_cache_long sys_key_cache_block_size("key_cache_block_size", - offsetof(KEY_CACHE_VAR, - block_size)); + offsetof(KEY_CACHE, + param_block_size)); sys_var_key_cache_long sys_key_cache_division_limit("key_cache_division_limit", - offsetof(KEY_CACHE_VAR, - division_limit)); + offsetof(KEY_CACHE, + param_division_limit)); sys_var_key_cache_long sys_key_cache_age_threshold("key_cache_age_threshold", - offsetof(KEY_CACHE_VAR, - age_threshold)); + offsetof(KEY_CACHE, + param_age_threshold)); sys_var_bool_ptr sys_local_infile("local_infile", &opt_local_infile); sys_var_thd_bool sys_log_warnings("log_warnings", &SV::log_warnings); @@ -1778,15 +1778,14 @@ void sys_var_collation_server::set_default(THD *thd, enum_var_type type) LEX_STRING default_key_cache_base= {(char *) "default", 7 }; -static KEY_CACHE_VAR zero_key_cache= - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static KEY_CACHE zero_key_cache; -KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name) +KEY_CACHE *get_key_cache(LEX_STRING *cache_name) { safe_mutex_assert_owner(&LOCK_global_system_variables); if (!cache_name || ! cache_name->length) cache_name= &default_key_cache_base; - return ((KEY_CACHE_VAR*) find_named(&key_caches, + return ((KEY_CACHE*) find_named(&key_caches, cache_name->str, cache_name->length, 0)); } @@ -1794,7 +1793,7 @@ KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name) byte *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - KEY_CACHE_VAR *key_cache= get_key_cache(base); + KEY_CACHE *key_cache= get_key_cache(base); if (!key_cache) key_cache= &zero_key_cache; return (byte*) key_cache + offset ; @@ -1805,7 +1804,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) { ulonglong tmp= var->save_result.ulonglong_value; LEX_STRING *base_name= &var->base; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; bool error= 0; /* If no basename, assume it's for the key cache named 'default' */ @@ -1840,14 +1839,14 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) if (key_cache == sql_key_cache) goto end; // Ignore default key cache - if (key_cache->cache) // If initied + if (key_cache->key_cache_inited) // If initied { /* Move tables using this key cache to the default key cache and clear the old key cache. */ NAMED_LIST *list; - key_cache= (KEY_CACHE_VAR *) find_named(&key_caches, base_name->str, + key_cache= (KEY_CACHE *) find_named(&key_caches, base_name->str, base_name->length, &list); key_cache->in_init= 1; pthread_mutex_unlock(&LOCK_global_system_variables); @@ -1862,13 +1861,14 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) goto end; } - key_cache->buff_size= (ulonglong) getopt_ull_limit_value(tmp, option_limits); + key_cache->param_buff_size= + (ulonglong) getopt_ull_limit_value(tmp, option_limits); /* If key cache didn't existed initialize it, else resize it */ key_cache->in_init= 1; pthread_mutex_unlock(&LOCK_global_system_variables); - if (!key_cache->cache) + if (!key_cache->key_cache_inited) error= (bool) (ha_init_key_cache("", key_cache)); else error= (bool)(ha_resize_key_cache(key_cache)); @@ -1892,7 +1892,7 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var) base_name= &default_key_cache_base; pthread_mutex_lock(&LOCK_global_system_variables); - KEY_CACHE_VAR *key_cache= get_key_cache(base_name); + KEY_CACHE *key_cache= get_key_cache(base_name); if (!key_cache && !(key_cache= create_key_cache(base_name->str, base_name->length))) @@ -2413,7 +2413,6 @@ byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type, ulong val; char buff[256]; String tmp(buff, sizeof(buff), &my_charset_latin1); - my_bool found= 0; tmp.length(0); val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : @@ -2543,13 +2542,13 @@ void delete_elements(I_List<NAMED_LIST> *list, /* Key cache functions */ -static KEY_CACHE_VAR *create_key_cache(const char *name, uint length) +static KEY_CACHE *create_key_cache(const char *name, uint length) { - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; DBUG_ENTER("create_key_cache"); DBUG_PRINT("enter",("name: %.*s", length, name)); - if ((key_cache= (KEY_CACHE_VAR*) my_malloc(sizeof(KEY_CACHE_VAR), + if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE), MYF(MY_ZEROFILL | MY_WME)))) { if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache)) @@ -2565,19 +2564,19 @@ static KEY_CACHE_VAR *create_key_cache(const char *name, uint length) We don't set 'buff_size' as this is used to enable the key cache */ - key_cache->block_size= dflt_key_cache_var.block_size; - key_cache->division_limit= dflt_key_cache_var.division_limit; - key_cache->age_threshold= dflt_key_cache_var.age_threshold; + key_cache->param_block_size= dflt_key_cache_var.param_block_size; + key_cache->param_division_limit= dflt_key_cache_var.param_division_limit; + key_cache->param_age_threshold= dflt_key_cache_var.param_age_threshold; } } DBUG_RETURN(key_cache); } -KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length) +KEY_CACHE *get_or_create_key_cache(const char *name, uint length) { LEX_STRING key_cache_name; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; key_cache_name.str= (char *) name; key_cache_name.length= length; @@ -2589,21 +2588,21 @@ KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length) } -void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache) +void free_key_cache(const char *name, KEY_CACHE *key_cache) { ha_end_key_cache(key_cache); my_free((char*) key_cache, MYF(0)); } -bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *)) +bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)) { I_List_iterator<NAMED_LIST> it(key_caches); NAMED_LIST *element; while ((element= it++)) { - KEY_CACHE_VAR *key_cache= (KEY_CACHE_VAR *) element->data; + KEY_CACHE *key_cache= (KEY_CACHE *) element->data; func(element->name, key_cache); } return 0; diff --git a/sql/set_var.h b/sql/set_var.h index 666575a75e4..58ae53190e0 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -560,7 +560,7 @@ class sys_var_key_buffer_size :public sys_var_key_cache_param { public: sys_var_key_buffer_size(const char *name_arg) - :sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE_VAR, buff_size)) + :sys_var_key_cache_param(name_arg, offsetof(KEY_CACHE, param_buff_size)) {} bool update(THD *thd, set_var *var); SHOW_TYPE type() { return SHOW_LONGLONG; } @@ -755,7 +755,7 @@ public: my_free((char*) name, MYF(0)); } friend bool process_key_caches(int (* func) (const char *name, - KEY_CACHE_VAR *)); + KEY_CACHE *)); friend void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(const char*, gptr)); }; @@ -788,9 +788,9 @@ gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length, NAMED_LIST **found); /* key_cache functions */ -KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name); -KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length); -void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache); -bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *)); +KEY_CACHE *get_key_cache(LEX_STRING *cache_name); +KEY_CACHE *get_or_create_key_cache(const char *name, uint length); +void free_key_cache(const char *name, KEY_CACHE *key_cache); +bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)); void delete_elements(I_List<NAMED_LIST> *list, void (*free_element)(const char*, gptr)); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b54e6a95bc5..bcfa9c6dec5 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -632,8 +632,8 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, if (acl_user) { /* OK. User found and password checked continue validation */ - Vio *vio=thd->net.vio; #ifdef HAVE_OPENSSL + Vio *vio=thd->net.vio; SSL *ssl= (SSL*) vio->ssl_arg; #endif @@ -3457,7 +3457,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) { uint counter; int result; - ACL_USER *acl_user; ACL_DB *acl_db; + ACL_DB *acl_db; TABLE_LIST tables[4]; DBUG_ENTER("mysql_revoke_all"); @@ -3471,7 +3471,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) List_iterator <LEX_USER> user_list(list); while ((lex_user=user_list++)) { - if (!(acl_user= check_acl_user(lex_user, &counter))) + if (!check_acl_user(lex_user, &counter)) { sql_print_error("REVOKE ALL PRIVILEGES, GRANT: User '%s'@'%s' not exists", lex_user->user.str, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9fe61ae19e1..7a657841845 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -35,7 +35,6 @@ HASH assign_cache; static int open_unireg_entry(THD *thd,TABLE *entry,const char *db, const char *name, const char *alias); static void free_cache_entry(TABLE *entry); -static void free_assign_entry(KEY_CACHE_ASMT *key_cache_asmt); static void mysql_rm_tmp_tables(void); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 63bf5f061e9..5481b1b266f 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -265,7 +265,6 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) char path[FN_REFLEN+16]; long result=1; int error = 0; - uint create_options = create_info ? create_info->options : 0; DBUG_ENTER("mysql_alter_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 78e8c877c45..88fedaad380 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -253,7 +253,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, continue; if (num_rows >= offset_limit) { - String *packet = &thd->packet; Item *item; protocol->prepare_for_resend(); it.rewind(); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9077d4c6a2d..4484cdbe248 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1488,6 +1488,8 @@ void select_insert::send_error(uint errcode,const char *err) bool select_insert::send_eof() { int error,error2; + DBUG_ENTER("select_insert::send_eof"); + if (!(error=table->file->extra(HA_EXTRA_NO_CACHE))) error=table->file->activate_all_index(thd); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); @@ -1521,20 +1523,18 @@ bool select_insert::send_eof() table->file->print_error(error,MYF(0)); //TODO error should be sent at the query processing end ::send_error(thd); - return 1; + DBUG_RETURN(1); } + + char buff[160]; + if (info.handle_duplicates == DUP_IGNORE) + sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, + (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); else - { - char buff[160]; - if (info.handle_duplicates == DUP_IGNORE) - sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); - else - sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) info.deleted, (ulong) thd->cuted_fields); - ::send_ok(thd,info.copied+info.deleted,last_insert_id,buff); - return 0; - } + sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, + (ulong) info.deleted, (ulong) thd->cuted_fields); + ::send_ok(thd,info.copied+info.deleted,last_insert_id,buff); + DBUG_RETURN(0); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index bc87f6aaabc..981e5e1e026 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -432,7 +432,7 @@ int yylex(void *arg, void *yythd) reg1 uchar c; int tokval, result_state; uint length; - enum my_lex_states state,prev_state; + enum my_lex_states state; LEX *lex= &(((THD *)yythd)->lex); YYSTYPE *yylval=(YYSTYPE*) arg; CHARSET_INFO *cs= ((THD *) yythd)->charset(); @@ -441,7 +441,7 @@ int yylex(void *arg, void *yythd) lex->yylval=yylval; // The global state lex->tok_start=lex->tok_end=lex->ptr; - prev_state=state=lex->next_state; + state=lex->next_state; lex->next_state=MY_LEX_OPERATOR_OR_IDENT; LINT_INIT(c); for (;;) @@ -1175,7 +1175,7 @@ void st_select_lex_unit::exclude_level() */ void st_select_lex_unit::exclude_tree() { - SELECT_LEX_UNIT *units= 0, **units_last= &units; + SELECT_LEX_UNIT *units= 0; for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) { // unlink current level from global SELECTs list diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 017ef065012..9f4b10682ba 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -128,7 +128,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, USER_RESOURCES *mqh) { int return_val=0; - uint temp_len, user_len, host_len; + uint temp_len, user_len; char temp_user[USERNAME_LENGTH+HOSTNAME_LENGTH+2]; struct user_conn *uc; @@ -136,7 +136,6 @@ static int get_or_create_user_conn(THD *thd, const char *user, DBUG_ASSERT(host != 0); user_len=strlen(user); - host_len=strlen(host); temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1; (void) pthread_mutex_lock(&LOCK_user_conn); if (!(uc = (struct user_conn *) hash_search(&hash_user_connections, diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2fa08e2d649..85b82d3b488 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1059,7 +1059,7 @@ void mysql_stmt_free(THD *thd, char *packet) PREP_STMT *stmt; DBUG_ENTER("mysql_stmt_free"); - if (!(stmt=find_prepared_statement(thd, stmt_id, "close"))) + if (!find_prepared_statement(thd, stmt_id, "close")) { send_error(thd); // Not seen by the client DBUG_VOID_RETURN; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ecad84ba0cb..80bcb7d569c 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1291,9 +1291,7 @@ int show_binlogs(THD* thd) { IO_CACHE *index_file; char fname[FN_REFLEN]; - NET* net = &thd->net; List<Item> field_list; - String *packet = &thd->packet; uint length; Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlogs"); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 745f19d0bcf..44b403c0bb1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7228,7 +7228,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having) entry->file->info(HA_STATUS_VARIABLE); if (entry->db_type == DB_TYPE_HEAP || (!entry->blob_fields && - ((ALIGN_SIZE(reclength) +sizeof(HASH_LINK)) * entry->file->records < + ((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->records < thd->variables.sortbuff_size))) error=remove_dup_with_hash_index(join->thd, entry, field_count, first_field, @@ -7738,8 +7738,6 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, Item *itemptr=*order->item; if (itemptr->type() == Item::INT_ITEM) { /* Order by position */ - Item *item=0; - uint count= (uint) ((Item_int*)itemptr)->value; if (!count || count > fields.elements) { diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c2ebdeab5c2..e24102a5094 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -702,7 +702,6 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, restore_record(table,default_values); // Get empty record Field **ptr,*field; - String *packet= &thd->packet; for (ptr=table->field; (field= *ptr) ; ptr++) { if (!wild || !wild[0] || @@ -892,7 +891,6 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) if (protocol->send_fields(&field_list,1)) DBUG_RETURN(1); - String *packet= &thd->packet; KEY *key_info=table->key_info; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); for (uint i=0 ; i < table->keys ; i++,key_info++) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b1d23de06b0..ea14249e907 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1637,7 +1637,7 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, LEX_STRING *key_cache_name) { HA_CHECK_OPT check_opt; - KEY_CACHE_VAR *key_cache; + KEY_CACHE *key_cache; DBUG_ENTER("mysql_assign_to_keycache"); check_opt.init(); @@ -1682,14 +1682,14 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, 0 ok */ -int reassign_keycache_tables(THD *thd, KEY_CACHE_VAR *src_cache, - KEY_CACHE_VAR *dst_cache) +int reassign_keycache_tables(THD *thd, KEY_CACHE *src_cache, + KEY_CACHE *dst_cache) { DBUG_ENTER("reassign_keycache_tables"); DBUG_ASSERT(src_cache != dst_cache); DBUG_ASSERT(src_cache->in_init); - src_cache->buff_size= 0; // Free key cache + src_cache->param_buff_size= 0; // Free key cache ha_resize_key_cache(src_cache); ha_change_key_cache(src_cache, dst_cache); DBUG_RETURN(0); @@ -1955,7 +1955,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ulonglong next_insert_id; uint save_time_stamp,db_create_options, used_fields; enum db_type old_db_type,new_db_type; - thr_lock_type lock_type; DBUG_ENTER("mysql_alter_table"); thd->proc_info="init"; @@ -2798,7 +2797,6 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) for (table= tables; table; table= table->next) { char table_name[NAME_LEN*2+2]; - bool fatal_error= 0; TABLE *t; strxmov(table_name, table->db ,".", table->real_name, NullS); diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 449c43c24d1..6763181ce4a 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -303,9 +303,9 @@ end: } -static int print_key_cache_status(const char *name, KEY_CACHE_VAR *key_cache) +static int print_key_cache_status(const char *name, KEY_CACHE *key_cache) { - if (!key_cache->cache) + if (!key_cache->key_cache_inited) { printf("%s: Not in use\n", name); } @@ -323,11 +323,11 @@ writes: %10lu\n\ r_requests: %10lu\n\ reads: %10lu\n\n", name, - (ulong) key_cache->buff_size, key_cache->block_size, - key_cache->division_limit, key_cache->age_threshold, - key_cache->blocks_used,key_cache->blocks_changed, - key_cache->cache_w_requests,key_cache->cache_write, - key_cache->cache_r_requests,key_cache->cache_read); + (ulong) key_cache->param_buff_size, key_cache->param_block_size, + key_cache->param_division_limit, key_cache->param_age_threshold, + key_cache->global_blocks_used,key_cache->global_blocks_changed, + key_cache->global_cache_w_requests,key_cache->global_cache_write, + key_cache->global_cache_r_requests,key_cache->global_cache_read); } return 0; } diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 1db2124bcee..d00e57df5a1 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -112,7 +112,7 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match) found_pos= pos; } } - return(found_count == 1 && part_match ? found_count : 0); + return(found_count == 1 && part_match ? found_pos : 0); } diff --git a/sql/time.cc b/sql/time.cc index e696918dee3..fe22b80d59d 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -357,7 +357,6 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags) const char *end=str+length; const uchar *format_position; bool found_delimitier= 0, found_space= 0; - DATE_TIME_FORMAT *format; DBUG_ENTER("str_to_TIME"); DBUG_PRINT("ENTER",("str: %.*s",length,str)); |