Commit 28e96d95 authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Simple code cleanup

parent a51ea111
...@@ -156,7 +156,7 @@ level id parent_id ...@@ -156,7 +156,7 @@ level id parent_id
1 1007 101 1 1007 101
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text 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; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment 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 t1 0 PRIMARY 1 id A 87 NULL NULL BTREE
...@@ -180,7 +180,7 @@ create table t1 (a int) type=innodb; ...@@ -180,7 +180,7 @@ create table t1 (a int) type=innodb;
insert into t1 values (1), (2); insert into t1 values (1), (2);
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text 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; delete from t1 where a = 1;
select * from t1; select * from t1;
a a
...@@ -712,7 +712,7 @@ world 2 ...@@ -712,7 +712,7 @@ world 2
hello 1 hello 1
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text 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; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment 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 t1 0 PRIMARY 1 a A 2 NULL NULL BTREE
...@@ -1240,7 +1240,7 @@ t1 range c c 5 NULL 1 Using where ...@@ -1240,7 +1240,7 @@ t1 range c c 5 NULL 1 Using where
update t1 set c=a; update t1 set c=a;
explain select * from t1 where c between 1 and 10000; explain select * from t1 where c between 1 and 10000;
table type possible_keys key key_len ref rows Extra 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; drop table t1,t2;
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb; 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); insert into t1 (id) values (null),(null),(null),(null),(null);
......
...@@ -253,15 +253,27 @@ void symdirget(char *dir) ...@@ -253,15 +253,27 @@ void symdirget(char *dir)
} }
#endif /* USE_SYMDIR */ #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()
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/..
/* to may be == from */ 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; uint length,h_length;
char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion; char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;
......
...@@ -100,7 +100,7 @@ static void pretty_print_str(String* packet, char* str, int len) ...@@ -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, static inline char* slave_load_file_stem(char*buf, uint file_id,
int event_server_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 = strend(buf);
buf = int10_to_str(::server_id, buf, 10); buf = int10_to_str(::server_id, buf, 10);
*buf++ = '-'; *buf++ = '-';
...@@ -174,16 +174,16 @@ static void cleanup_load_tmpdir() ...@@ -174,16 +174,16 @@ static void cleanup_load_tmpdir()
file=dirp->dir_entry+i; file=dirp->dir_entry+i;
if (is_prefix(file->name,"SQL_LOAD-")) 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_delete(fname, MYF(0));
} }
} }
my_dirend(dirp); my_dirend(dirp);
} }
#endif #endif
Log_event::Log_event(const char* buf, bool old_format) Log_event::Log_event(const char* buf, bool old_format)
:temp_buf(0), cached_event_len(0), cache_stmt(0) :temp_buf(0), cached_event_len(0), cache_stmt(0)
{ {
......
...@@ -134,7 +134,7 @@ int init_slave() ...@@ -134,7 +134,7 @@ int init_slave()
goto err; 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)) !master_host))
{ {
sql_print_error("Failed to initialize the master info structure"); 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, ...@@ -1777,18 +1777,17 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
pthread_mutex_lock(&data_lock); pthread_mutex_lock(&data_lock);
/* /*
This function will abort when it notices that This function will abort when it notices that some CHANGE MASTER or
some CHANGE MASTER or RESET MASTER has changed RESET MASTER has changed the master info.
the master info. To catch this, these commands To catch this, these commands modify abort_pos_wait ; We just monitor
modify abort_pos_wait ; we just monitor abort_pos_wait abort_pos_wait and see if it has changed.
and see if it has changed. Why do we have this mechanism instead of simply monitoring slave_running
Why do we have this mechanism instead of simply monitoring slave_running in in the loop (we do this too), as CHANGE MASTER/RESET SLAVE require that
the loop (we do this too), as CHANGE MASTER/RESET SLAVE require that the the SQL thread be stopped?
SQL thread be stopped? This is in case This is becasue if someones does:
STOP SLAVE;CHANGE MASTER/RESET SLAVE; START SLAVE; STOP SLAVE;CHANGE MASTER/RESET SLAVE; START SLAVE;
happens very quickly between the moment pthread_cond_wait() wakes up and the change may happen very quickly and we may not notice that
the while() is evaluated: in that case slave_running is again 1 when the slave_running briefly switches between 1/0/1.
while() is evaluated.
*/ */
init_abort_pos_wait= abort_pos_wait; init_abort_pos_wait= abort_pos_wait;
...@@ -1809,7 +1808,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, ...@@ -1809,7 +1808,7 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
error= -2; //means improper arguments error= -2; //means improper arguments
goto err; goto err;
} }
//p points to '.' /* p points to '.' */
log_name_extension= strtoul(++p, &p_end, 10); log_name_extension= strtoul(++p, &p_end, 10);
/* /*
p_end points to the first invalid character. 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, ...@@ -1822,14 +1821,9 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name,
goto err; goto err;
} }
//"compare and wait" main loop /* The "compare and wait" main loop */
while (!thd->killed && while (!thd->killed &&
init_abort_pos_wait == abort_pos_wait && 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) slave_running)
{ {
bool pos_reached; bool pos_reached;
......
...@@ -68,11 +68,6 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, ...@@ -68,11 +68,6 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name,
int4store(header + LOG_POS_OFFSET, 0); int4store(header + LOG_POS_OFFSET, 0);
packet->append(header, sizeof(header)); 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); int8store(buf+R_POS_OFFSET,position);
packet->append(buf, ROTATE_HEADER_LEN); packet->append(buf, ROTATE_HEADER_LEN);
packet->append(p,ident_len); packet->append(p,ident_len);
......
...@@ -1627,6 +1627,9 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field) ...@@ -1627,6 +1627,9 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field)
key_field->field->table->reginfo.not_exists_optimize=1; key_field->field->table->reginfo.not_exists_optimize=1;
} }
#define FT_KEYPART (MAX_REF_PARTS+10)
static void static void
add_ft_keys(DYNAMIC_ARRAY *keyuse_array, add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
JOIN_TAB *stat,COND *cond,table_map usable_tables) JOIN_TAB *stat,COND *cond,table_map usable_tables)
...@@ -1685,23 +1688,20 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array, ...@@ -1685,23 +1688,20 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
} }
} }
if (!cond_func || cond_func->key == NO_SUCH_KEY) if ((!cond_func || cond_func->key == NO_SUCH_KEY) ||
return; (!(usable_tables & cond_func->table->map)))
if (!(usable_tables & cond_func->table->map))
return; return;
KEYUSE keyuse; KEYUSE keyuse;
keyuse.table= cond_func->table; keyuse.table= cond_func->table;
keyuse.val = cond_func; keyuse.val = cond_func;
keyuse.key = cond_func->key; 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(); keyuse.used_tables=cond_func->key_item()->used_tables();
VOID(insert_dynamic(keyuse_array,(gptr) &keyuse)); VOID(insert_dynamic(keyuse_array,(gptr) &keyuse));
} }
static int static int
sort_keyuse(KEYUSE *a,KEYUSE *b) 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