diff options
author | monty@narttu.mysql.fi <> | 2003-03-19 21:23:13 +0200 |
---|---|---|
committer | monty@narttu.mysql.fi <> | 2003-03-19 21:23:13 +0200 |
commit | 48a9c1239c6b2b2ba27f8a1a9a0df98af204d53b (patch) | |
tree | 8bda97a92a625441a765c5282461fd89ee352624 /sql | |
parent | a916a03916eda128d3305e58cc49cf84e73deae6 (diff) | |
download | mariadb-git-48a9c1239c6b2b2ba27f8a1a9a0df98af204d53b.tar.gz |
Added support for ULONG division with DIV
Fixed non fatal memory leak in slave code.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.cc | 5 | ||||
-rw-r--r-- | sql/log_event.cc | 8 | ||||
-rw-r--r-- | sql/slave.cc | 6 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 | ||||
-rw-r--r-- | sql/sql_class.cc | 15 | ||||
-rw-r--r-- | sql/sql_class.h | 1 | ||||
-rw-r--r-- | sql/sql_error.cc | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 13 | ||||
-rw-r--r-- | sql/unireg.h | 7 |
9 files changed, 39 insertions, 22 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 6b932edf00e..81ea91c5c3d 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -499,12 +499,15 @@ longlong Item_func_int_div::val_int() longlong val2=args[1]->val_int(); if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value)) return 0; - return value/val2; + return (unsigned_flag ? + (ulonglong) value / (ulonglong) val2 : + value / val2); } void Item_func_int_div::fix_length_and_dec() { + find_num_type(); max_length=args[0]->max_length - args[0]->decimals; maybe_null=1; } diff --git a/sql/log_event.cc b/sql/log_event.cc index 1f3a09ba93b..b57a691c267 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -875,7 +875,6 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db) int Query_log_event::exec_event(struct st_relay_log_info* rli) { int expected_error,actual_error = 0; - init_sql_alloc(&thd->mem_root, 8192,0); thd->db = rewrite_db((char*)db); /* @@ -1075,6 +1074,7 @@ int Start_log_event::write_data(IO_CACHE* file) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Start_log_event::exec_event(struct st_relay_log_info* rli) { + DBUG_ENTER("Start_log_event::exec_event"); /* All temporary tables was deleted on the master */ close_temporary_tables(thd); /* @@ -1082,7 +1082,7 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli) */ if (!rli->mi->old_format) cleanup_load_tmpdir(); - return Log_event::exec_event(rli); + DBUG_RETURN(Log_event::exec_event(rli)); } #endif @@ -1535,7 +1535,6 @@ void Load_log_event::set_fields(List<Item> &field_list) int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, bool use_rli_only_for_errors) { - init_sql_alloc(&thd->mem_root, 8192,0); thd->db = rewrite_db((char*)db); DBUG_ASSERT(thd->query == 0); thd->query = 0; // Should not be needed @@ -2164,9 +2163,6 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli) double real_val; longlong int_val; - if (type != ROW_RESULT) - init_sql_alloc(&thd->mem_root, 8192,0); - if (is_null) { it= new Item_null(); diff --git a/sql/slave.cc b/sql/slave.cc index 215da63a704..61348722d1e 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2099,7 +2099,6 @@ point. If you are sure that your master is ok, run this query manually on the\ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) { - DBUG_ASSERT(rli->sql_thd==thd); Log_event * ev = next_event(rli); DBUG_ASSERT(rli->sql_thd==thd); if (sql_slave_killed(thd,rli)) @@ -2463,7 +2462,8 @@ slave_begin: #endif thd = new THD; // note that contructor of THD uses DBUG_ ! - THD_CHECK_SENTRY(thd); + thd->thread_stack = (char*)&thd; // remember where our stack is + /* Inform waiting threads that slave has started */ rli->slave_run_id++; @@ -2479,9 +2479,9 @@ slave_begin: sql_print_error("Failed during slave thread initialization"); goto err; } + thd->init_for_queries(); rli->sql_thd= thd; thd->temporary_tables = rli->save_temporary_tables; // restore temp tables - thd->thread_stack = (char*)&thd; // remember where our stack is pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 34884003da3..2063e8b3f08 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1637,6 +1637,8 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db, bool rm_temporary_table(enum db_type base, char *path) { bool error=0; + DBUG_ENTER("rm_temporary_table"); + fn_format(path, path,"",reg_ext,4); unpack_filename(path,path); if (my_delete(path,MYF(0))) @@ -1646,7 +1648,7 @@ bool rm_temporary_table(enum db_type base, char *path) if (file && file->delete_table(path)) error=1; delete file; - return error; + DBUG_RETURN(error); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f67db09ee67..022a31e7b5c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -215,6 +215,21 @@ void THD::init(void) total_warn_count= 0; } + +/* + Init THD for query processing + + This has to be called once before we call mysql_parse() +*/ + +void THD::init_for_queries() +{ + init_sql_alloc(&mem_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC); + init_sql_alloc(&transaction.mem_root, + TRANS_MEM_ROOT_BLOCK_SIZE, TRANS_MEM_ROOT_PREALLOC); +} + + /* Do what's needed when one invokes change user diff --git a/sql/sql_class.h b/sql/sql_class.h index 44082aa897e..af60ea6d466 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -573,6 +573,7 @@ public: void init(void); void change_user(void); + void init_for_queries(); void cleanup(void); bool store_globals(); #ifdef SIGNAL_WITH_VIO_CLOSE diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 00c80a654cb..8d3bb3ca49b 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -60,6 +60,7 @@ This file contains the implementation of error and warnings related void mysql_reset_errors(THD *thd) { + DBUG_ENTER("mysql_reset_errors"); if (thd->query_id != thd->warn_id) { thd->warn_id= thd->query_id; @@ -67,6 +68,7 @@ void mysql_reset_errors(THD *thd) bzero((char*) thd->warn_count, sizeof(thd->warn_count)); thd->warn_list.empty(); } + DBUG_VOID_RETURN; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index eed5e62555b..3b27a65f4e1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -44,11 +44,6 @@ #define MIN_HANDSHAKE_SIZE 6 #endif /* HAVE_OPENSSL */ -#define MEM_ROOT_BLOCK_SIZE 8192 -#define MEM_ROOT_PREALLOC 8192 -#define TRANS_MEM_ROOT_BLOCK_SIZE 4096 -#define TRANS_MEM_ROOT_PREALLOC 4096 - extern int yyparse(void *thd); extern "C" pthread_mutex_t THR_LOCK_keycache; #ifdef SOLARIS @@ -834,9 +829,7 @@ pthread_handler_decl(handle_one_connection,arg) thd->command=COM_SLEEP; thd->version=refresh_version; thd->set_time(); - init_sql_alloc(&thd->mem_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC); - init_sql_alloc(&thd->transaction.mem_root, - TRANS_MEM_ROOT_BLOCK_SIZE, TRANS_MEM_ROOT_PREALLOC); + thd->init_for_queries(); while (!net->error && net->vio != 0 && !thd->killed) { if (do_command(thd)) @@ -907,9 +900,7 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg) thd->priv_user=thd->user=(char*) my_strdup("boot", MYF(MY_WME)); buff= (char*) thd->net.buff; - init_sql_alloc(&thd->mem_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC); - init_sql_alloc(&thd->transaction.mem_root, - TRANS_MEM_ROOT_BLOCK_SIZE, TRANS_MEM_ROOT_PREALLOC); + thd->init_for_queries(); while (fgets(buff, thd->net.max_packet, file)) { uint length=(uint) strlen(buff); diff --git a/sql/unireg.h b/sql/unireg.h index a5cd784a14a..9430329e67a 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -63,6 +63,13 @@ #define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD) #define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD) + +/* Memory allocated when parsing a statement / saving a statement */ +#define MEM_ROOT_BLOCK_SIZE 8192 +#define MEM_ROOT_PREALLOC 8192 +#define TRANS_MEM_ROOT_BLOCK_SIZE 4096 +#define TRANS_MEM_ROOT_PREALLOC 4096 + #define DEFAULT_ERROR_COUNT 64 #define DEFAULT_PREP_STMT_COUNT 64 #define EXTRA_RECORDS 10 /* Extra records in sort */ |