Commit c1508250 authored by unknown's avatar unknown

Simple code cleanup


mysql-test/r/innodb.result:
  Fixed test case after innodb optimize->analyze fix
mysys/mf_pack.c:
  Added comments
sql/log_event.cc:
  Fixed usage of fn_format()
sql/slave.cc:
  Indentation fixes and comments cleanup
sql/sql_repl.cc:
  Comment cleanup
parent 40666537
......@@ -156,7 +156,7 @@ level id parent_id
1 1007 101
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize error The handler for the table doesn't support optimize
test.t1 optimize status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 id A 87 NULL NULL BTREE
......@@ -180,7 +180,7 @@ create table t1 (a int) type=innodb;
insert into t1 values (1), (2);
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize error The handler for the table doesn't support optimize
test.t1 optimize status OK
delete from t1 where a = 1;
select * from t1;
a
......@@ -712,7 +712,7 @@ world 2
hello 1
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize error The handler for the table doesn't support optimize
test.t1 optimize status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 a A 2 NULL NULL BTREE
......@@ -1240,7 +1240,7 @@ t1 range c c 5 NULL 1 Using where
update t1 set c=a;
explain select * from t1 where c between 1 and 10000;
table type possible_keys key key_len ref rows Extra
t1 ALL c NULL NULL NULL 29537 Using where
t1 ALL c NULL NULL NULL 27682 Using where
drop table t1,t2;
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb;
insert into t1 (id) values (null),(null),(null),(null),(null);
......
......@@ -253,15 +253,27 @@ void symdirget(char *dir)
}
#endif /* USE_SYMDIR */
/* Unpacks dirname to name that can be used by open... */
/* Make that last char of to is '/' if from not empty and
from doesn't end in FN_DEVCHAR */
/* Uses cleanup_dirname and changes ~/.. to home_dir/.. */
/* Returns length of new directory */
uint unpack_dirname(my_string to, const char *from)
/*
Fixes a directroy name so that can be used by open()
/* to may be == from */
SYNOPSIS
unpack_dirname()
to Store result here. May be = from
from 'Packed' directory name (may contain ~)
IMPLEMENTATION
Make that last char of to is '/' if from not empty and
from doesn't end in FN_DEVCHAR
Uses cleanup_dirname and changes ~/.. to home_dir/..
Changes a UNIX filename to system filename (replaces / with \ on windows)
RETURN
Length of new directory name (= length of to)
*/
uint unpack_dirname(my_string to, const char *from)
{
uint length,h_length;
char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;
......
......@@ -100,7 +100,7 @@ static void pretty_print_str(String* packet, char* str, int len)
static inline char* slave_load_file_stem(char*buf, uint file_id,
int event_server_id)
{
fn_format(buf,"SQL_LOAD-",slave_load_tmpdir,"",0); /* 4+32); */
fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME);
buf = strend(buf);
buf = int10_to_str(::server_id, buf, 10);
*buf++ = '-';
......@@ -174,16 +174,16 @@ static void cleanup_load_tmpdir()
file=dirp->dir_entry+i;
if (is_prefix(file->name,"SQL_LOAD-"))
{
fn_format(fname,file->name,slave_load_tmpdir,"",0);
fn_format(fname,file->name,slave_load_tmpdir,"",MY_UNPACK_FILENAME);
my_delete(fname, MYF(0));
}
}
my_dirend(dirp);
}
#endif
Log_event::Log_event(const char* buf, bool old_format)
:temp_buf(0), cached_event_len(0), cache_stmt(0)
{
......
......@@ -134,7 +134,7 @@ int init_slave()
goto err;
}
if(init_master_info(active_mi,master_info_file,relay_log_info_file,
if (init_master_info(active_mi,master_info_file,relay_log_info_file,
!master_host))
{
sql_print_error("Failed to initialize the master info structure");
......@@ -1777,18 +1777,17 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
pthread_mutex_lock(&data_lock);
/*
This function will abort when it notices that
some CHANGE MASTER or RESET MASTER has changed
the master info. To catch this, these commands
modify abort_pos_wait ; we just monitor abort_pos_wait
and see if it has changed.
Why do we have this mechanism instead of simply monitoring slave_running in
the loop (we do this too), as CHANGE MASTER/RESET SLAVE require that the
SQL thread be stopped? This is in case
This function will abort when it notices that some CHANGE MASTER or
RESET MASTER has changed the master info.
To catch this, these commands modify abort_pos_wait ; We just monitor
abort_pos_wait and see if it has changed.
Why do we have this mechanism instead of simply monitoring slave_running
in the loop (we do this too), as CHANGE MASTER/RESET SLAVE require that
the SQL thread be stopped?
This is becasue if someones does:
STOP SLAVE;CHANGE MASTER/RESET SLAVE; START SLAVE;
happens very quickly between the moment pthread_cond_wait() wakes up and
the while() is evaluated: in that case slave_running is again 1 when the
while() is evaluated.
the change may happen very quickly and we may not notice that
slave_running briefly switches between 1/0/1.
*/
init_abort_pos_wait= abort_pos_wait;
......@@ -1809,7 +1808,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
error= -2; //means improper arguments
goto err;
}
//p points to '.'
/* p points to '.' */
log_name_extension= strtoul(++p, &p_end, 10);
/*
p_end points to the first invalid character.
......@@ -1822,14 +1821,9 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
goto err;
}
//"compare and wait" main loop
/* The "compare and wait" main loop */
while (!thd->killed &&
init_abort_pos_wait == abort_pos_wait &&
/*
formerly we tested mi->slave_running, but what we care about is
rli->slave_running (because this concerns the SQL thread, while
mi->slave_running concerns the I/O thread).
*/
slave_running)
{
bool pos_reached;
......
......@@ -68,11 +68,6 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
int4store(header + LOG_POS_OFFSET, 0);
packet->append(header, sizeof(header));
/*
An old comment said talked about a need for splitting the int8store below
into 2 int4store because of a problem with cxx; I can't understand that as
we already use int8store in Rotatel_log_event::write_data().
*/
int8store(buf+R_POS_OFFSET,position);
packet->append(buf, ROTATE_HEADER_LEN);
packet->append(p,ident_len);
......
......@@ -1627,6 +1627,9 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field)
key_field->field->table->reginfo.not_exists_optimize=1;
}
#define FT_KEYPART (MAX_REF_PARTS+10)
static void
add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
JOIN_TAB *stat,COND *cond,table_map usable_tables)
......@@ -1685,23 +1688,20 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
}
}
if (!cond_func || cond_func->key == NO_SUCH_KEY)
return;
if (!(usable_tables & cond_func->table->map))
if ((!cond_func || cond_func->key == NO_SUCH_KEY) ||
(!(usable_tables & cond_func->table->map)))
return;
KEYUSE keyuse;
keyuse.table= cond_func->table;
keyuse.val = cond_func;
keyuse.key = cond_func->key;
#define FT_KEYPART (MAX_REF_PARTS+10)
keyuse.keypart=FT_KEYPART;
keyuse.keypart= FT_KEYPART;
keyuse.used_tables=cond_func->key_item()->used_tables();
VOID(insert_dynamic(keyuse_array,(gptr) &keyuse));
}
static int
sort_keyuse(KEYUSE *a,KEYUSE *b)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment