Added support for ULONG division with DIV
Fixed non fatal memory leak in slave code. mysql-test/r/func_test.result: Added test for DIV mysql-test/t/func_test.test: Added test for DIV mysys/my_alloc.c: More DBUG statements sql/item_func.cc: Added support for ULONG division with DIV sql/log_event.cc: Fixed memory leak (Wrong call to init_sql_alloc) sql/slave.cc: Fixed memory leak (Wrong call to init_sql_alloc) sql/sql_base.cc: More DBUG statements sql/sql_class.cc: Added init_for_queries() to fix memory leak in slave code sql/sql_class.h: Added init_for_queries() to fix memory leak in slave code sql/sql_error.cc: More DBUG statements sql/sql_parse.cc: Added init_for_queries() to fix memory leak in slave code sql/unireg.h: Moved memory defaults to include file
This commit is contained in:
parent
aa08887f7b
commit
d7bedeb998
@ -49,6 +49,9 @@ select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
|
||||
select 10 % 7, 10 mod 7, 10 div 3;
|
||||
10 % 7 10 mod 7 10 div 3
|
||||
3 3 3
|
||||
select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
|
||||
(1 << 64)-1 ((1 << 64)-1) DIV 1 ((1 << 64)-1) DIV 2
|
||||
18446744073709551615 18446744073709551615 9223372036854775807
|
||||
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
|
||||
5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1
|
||||
0 1
|
||||
|
@ -18,6 +18,7 @@ select -1.49 or -1.49,0.6 or 0.6;
|
||||
select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
|
||||
select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
|
||||
select 10 % 7, 10 mod 7, 10 div 3;
|
||||
select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
|
||||
|
||||
#
|
||||
# Wrong usage of functions
|
||||
|
@ -25,6 +25,8 @@
|
||||
void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
|
||||
uint pre_alloc_size __attribute__((unused)))
|
||||
{
|
||||
DBUG_ENTER("init_alloc_root");
|
||||
DBUG_PRINT("enter",("root: %lx", mem_root));
|
||||
mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
|
||||
mem_root->min_malloc= 32;
|
||||
mem_root->block_size= block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8;
|
||||
@ -45,24 +47,27 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
|
||||
{
|
||||
#if defined(HAVE_purify) && defined(EXTRA_DEBUG)
|
||||
reg1 USED_MEM *next;
|
||||
Size+=ALIGN_SIZE(sizeof(USED_MEM));
|
||||
DBUG_ENTER("alloc_root");
|
||||
DBUG_PRINT("enter",("root: %lx", mem_root));
|
||||
|
||||
Size+=ALIGN_SIZE(sizeof(USED_MEM));
|
||||
if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME))))
|
||||
{
|
||||
if (mem_root->error_handler)
|
||||
(*mem_root->error_handler)();
|
||||
return((gptr) 0); /* purecov: inspected */
|
||||
DBUG_RETURN((gptr) 0); /* purecov: inspected */
|
||||
}
|
||||
next->next= mem_root->used;
|
||||
next->size= Size;
|
||||
mem_root->used= next;
|
||||
return (gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM)));
|
||||
DBUG_RETURN((gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
|
||||
#else
|
||||
uint get_size, block_size;
|
||||
gptr point;
|
||||
@ -151,8 +156,9 @@ void free_root(MEM_ROOT *root, myf MyFlags)
|
||||
{
|
||||
reg1 USED_MEM *next,*old;
|
||||
DBUG_ENTER("free_root");
|
||||
DBUG_PRINT("enter",("root: %lx flags: %u", root, (uint) MyFlags));
|
||||
|
||||
if (!root)
|
||||
if (!root) /* QQ: Should be deleted */
|
||||
DBUG_VOID_RETURN; /* purecov: inspected */
|
||||
if (MyFlags & MY_MARK_BLOCKS_FREE)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user