Commit a1e47ce8 authored by unknown's avatar unknown

SCRUM

common parts of libmysql.c and sql/mini_client.cc moved to sql-common/client.c
names of functions now are same in both cases


libmysql/libmysql.c:
  many parts moved to sql-common/client.c
libmysqld/Makefile.am:
  superfluous files removed
sql/mini_client.cc:
  most of the file moved to sql-common/client.c
sql/mini_client.h:
  mc_ prefixes were deleted
sql/repl_failsafe.cc:
  mc_ prefixes removed
sql/slave.cc:
  _mc prefixes removed
parent 4a506d6e
This diff is collapsed.
...@@ -43,14 +43,14 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \ ...@@ -43,14 +43,14 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \ item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \ item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
item_uniq.cc item_subselect.cc item_row.cc\ item_uniq.cc item_subselect.cc item_row.cc\
key.cc lock.cc log.cc log_event.cc mf_iocache.cc\ key.cc lock.cc log.cc log_event.cc \
mini_client.cc protocol.cc net_serv.cc opt_ft.cc opt_range.cc \ protocol.cc net_serv.cc opt_ft.cc opt_range.cc \
opt_sum.cc procedure.cc records.cc sql_acl.cc \ opt_sum.cc procedure.cc records.cc sql_acl.cc \
repl_failsafe.cc slave.cc sql_load.cc sql_olap.cc \ sql_load.cc sql_olap.cc \
sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \ sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \ sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \
sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc sql_parse.cc \ sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc sql_parse.cc \
sql_prepare.cc sql_derived.cc sql_rename.cc sql_repl.cc \ sql_prepare.cc sql_derived.cc sql_rename.cc \
sql_select.cc sql_do.cc sql_show.cc set_var.cc \ sql_select.cc sql_do.cc sql_show.cc set_var.cc \
sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \ sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \
sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \ sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
......
This diff is collapsed.
This diff is collapsed.
...@@ -17,30 +17,32 @@ ...@@ -17,30 +17,32 @@
#ifndef _MINI_CLIENT_H #ifndef _MINI_CLIENT_H
#define _MINI_CLIENT_H #define _MINI_CLIENT_H
MYSQL *
MYSQL* mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db, const char *passwd, const char *db,
uint port, const char *unix_socket,uint client_flag, uint port, const char *unix_socket,ulong client_flag,
uint net_read_timeout); uint net_read_timeout);
int mc_simple_command(MYSQL *mysql,enum enum_server_command command,
const char *arg, uint length, my_bool skipp_check); my_bool simple_command(MYSQL *mysql,enum enum_server_command command,
void mc_mysql_close(MYSQL *mysql); const char *arg, unsigned long length,
MYSQL *mc_mysql_init(MYSQL *mysql); my_bool skip_check);
void mc_mysql_debug(const char *debug); void mysql_close(MYSQL *mysql);
ulong mc_net_safe_read(MYSQL *mysql); MYSQL *mysql_init(MYSQL *mysql);
char *mc_mysql_error(MYSQL *mysql); void mysql_debug(const char *debug);
int mc_mysql_errno(MYSQL *mysql); ulong net_safe_read(MYSQL *mysql);
my_bool mc_mysql_reconnect(MYSQL* mysql); const char *mysql_error(MYSQL *mysql);
int mc_mysql_send_query(MYSQL* mysql, const char* query, uint length); unsigned int mysql_errno(MYSQL *mysql);
int mc_mysql_read_query_result(MYSQL *mysql); my_bool mysql_reconnect(MYSQL* mysql);
int mc_mysql_query(MYSQL *mysql, const char *query, uint length); int mysql_send_query(MYSQL* mysql, const char* query, uint length);
MYSQL_RES * mc_mysql_store_result(MYSQL *mysql); my_bool mysql_read_query_result(MYSQL *mysql);
void mc_mysql_free_result(MYSQL_RES *result); int mysql_real_query(MYSQL *mysql, const char *q, unsigned long length);
void mc_mysql_data_seek(MYSQL_RES *result, my_ulonglong row); MYSQL_RES * mysql_store_result(MYSQL *mysql);
my_ulonglong mc_mysql_num_rows(MYSQL_RES *res); void mysql_free_result(MYSQL_RES *result);
unsigned int mc_mysql_num_fields(MYSQL_RES *res); void mysql_data_seek(MYSQL_RES *result, my_ulonglong row);
MYSQL_ROW STDCALL mc_mysql_fetch_row(MYSQL_RES *res); my_ulonglong mysql_num_rows(MYSQL_RES *res);
int mc_mysql_select_db(MYSQL *mysql, const char *db); unsigned int mysql_num_fields(MYSQL_RES *res);
void mc_end_server(MYSQL *mysql); MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *res);
int mysql_select_db(MYSQL *mysql, const char *db);
void end_server(MYSQL *mysql);
#endif #endif
...@@ -484,14 +484,15 @@ int update_slave_list(MYSQL* mysql, MASTER_INFO* mi) ...@@ -484,14 +484,15 @@ int update_slave_list(MYSQL* mysql, MASTER_INFO* mi)
int port_ind; int port_ind;
DBUG_ENTER("update_slave_list"); DBUG_ENTER("update_slave_list");
if (mc_mysql_query(mysql,"SHOW SLAVE HOSTS",16) ||
!(res = mc_mysql_store_result(mysql))) if (mysql_real_query(mysql,"SHOW SLAVE HOSTS",16) ||
!(res = mysql_store_result(mysql)))
{ {
error= mc_mysql_error(mysql); error= mysql_error(mysql);
goto err; goto err;
} }
switch (mc_mysql_num_fields(res)) { switch (mysql_num_fields(res)) {
case 5: case 5:
have_auth_info = 0; have_auth_info = 0;
port_ind=2; port_ind=2;
...@@ -508,7 +509,7 @@ HOSTS"; ...@@ -508,7 +509,7 @@ HOSTS";
pthread_mutex_lock(&LOCK_slave_list); pthread_mutex_lock(&LOCK_slave_list);
while ((row= mc_mysql_fetch_row(res))) while ((row= mysql_fetch_row(res)))
{ {
uint32 server_id; uint32 server_id;
SLAVE_INFO* si, *old_si; SLAVE_INFO* si, *old_si;
...@@ -541,7 +542,7 @@ HOSTS"; ...@@ -541,7 +542,7 @@ HOSTS";
err: err:
if (res) if (res)
mc_mysql_free_result(res); mysql_free_result(res);
if (error) if (error)
{ {
sql_print_error("While trying to obtain the list of slaves from the master \ sql_print_error("While trying to obtain the list of slaves from the master \
...@@ -566,7 +567,7 @@ pthread_handler_decl(handle_failsafe_rpl,arg) ...@@ -566,7 +567,7 @@ pthread_handler_decl(handle_failsafe_rpl,arg)
thd->thread_stack = (char*)&thd; thd->thread_stack = (char*)&thd;
MYSQL* recovery_captain = 0; MYSQL* recovery_captain = 0;
pthread_detach_this_thread(); pthread_detach_this_thread();
if (init_failsafe_rpl_thread(thd) || !(recovery_captain=mc_mysql_init(0))) if (init_failsafe_rpl_thread(thd) || !(recovery_captain=mysql_init(0)))
{ {
sql_print_error("Could not initialize failsafe replication thread"); sql_print_error("Could not initialize failsafe replication thread");
goto err; goto err;
...@@ -599,7 +600,7 @@ pthread_handler_decl(handle_failsafe_rpl,arg) ...@@ -599,7 +600,7 @@ pthread_handler_decl(handle_failsafe_rpl,arg)
pthread_mutex_unlock(&LOCK_rpl_status); pthread_mutex_unlock(&LOCK_rpl_status);
err: err:
if (recovery_captain) if (recovery_captain)
mc_mysql_close(recovery_captain); mysql_close(recovery_captain);
delete thd; delete thd;
my_thread_end(); my_thread_end();
pthread_exit(0); pthread_exit(0);
...@@ -668,7 +669,7 @@ int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi) ...@@ -668,7 +669,7 @@ int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
strmov(mysql->net.last_error, "Master is not configured"); strmov(mysql->net.last_error, "Master is not configured");
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (!mc_mysql_connect(mysql, mi->host, mi->user, mi->password, 0, if (!mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0,
mi->port, 0, 0, mi->port, 0, 0,
slave_net_timeout)) slave_net_timeout))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -682,9 +683,9 @@ static inline void cleanup_mysql_results(MYSQL_RES* db_res, ...@@ -682,9 +683,9 @@ static inline void cleanup_mysql_results(MYSQL_RES* db_res,
for (; cur >= start; --cur) for (; cur >= start; --cur)
{ {
if (*cur) if (*cur)
mc_mysql_free_result(*cur); mysql_free_result(*cur);
} }
mc_mysql_free_result(db_res); mysql_free_result(db_res);
} }
...@@ -692,8 +693,8 @@ static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db, ...@@ -692,8 +693,8 @@ static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db,
MYSQL_RES *table_res, MASTER_INFO *mi) MYSQL_RES *table_res, MASTER_INFO *mi)
{ {
MYSQL_ROW row; MYSQL_ROW row;
for (row = mc_mysql_fetch_row(table_res); row; for (row = mysql_fetch_row(table_res); row;
row = mc_mysql_fetch_row(table_res)) row = mysql_fetch_row(table_res))
{ {
TABLE_LIST table; TABLE_LIST table;
const char* table_name= row[0]; const char* table_name= row[0];
...@@ -727,7 +728,7 @@ int load_master_data(THD* thd) ...@@ -727,7 +728,7 @@ int load_master_data(THD* thd)
int error = 0; int error = 0;
const char* errmsg=0; const char* errmsg=0;
int restart_thread_mask; int restart_thread_mask;
mc_mysql_init(&mysql); mysql_init(&mysql);
/* /*
We do not want anyone messing with the slave at all for the entire We do not want anyone messing with the slave at all for the entire
...@@ -749,7 +750,7 @@ int load_master_data(THD* thd) ...@@ -749,7 +750,7 @@ int load_master_data(THD* thd)
if (connect_to_master(thd, &mysql, active_mi)) if (connect_to_master(thd, &mysql, active_mi))
{ {
net_printf(thd, error= ER_CONNECT_TO_MASTER, net_printf(thd, error= ER_CONNECT_TO_MASTER,
mc_mysql_error(&mysql)); mysql_error(&mysql));
goto err; goto err;
} }
...@@ -758,15 +759,15 @@ int load_master_data(THD* thd) ...@@ -758,15 +759,15 @@ int load_master_data(THD* thd)
MYSQL_RES *db_res, **table_res, **table_res_end, **cur_table_res; MYSQL_RES *db_res, **table_res, **table_res_end, **cur_table_res;
uint num_dbs; uint num_dbs;
if (mc_mysql_query(&mysql, "SHOW DATABASES", 14) || if (mysql_real_query(&mysql, "SHOW DATABASES", 14) ||
!(db_res = mc_mysql_store_result(&mysql))) !(db_res = mysql_store_result(&mysql)))
{ {
net_printf(thd, error = ER_QUERY_ON_MASTER, net_printf(thd, error = ER_QUERY_ON_MASTER,
mc_mysql_error(&mysql)); mysql_error(&mysql));
goto err; goto err;
} }
if (!(num_dbs = (uint) mc_mysql_num_rows(db_res))) if (!(num_dbs = (uint) mysql_num_rows(db_res)))
goto err; goto err;
/* /*
In theory, the master could have no databases at all In theory, the master could have no databases at all
...@@ -785,12 +786,12 @@ int load_master_data(THD* thd) ...@@ -785,12 +786,12 @@ int load_master_data(THD* thd)
we wait to issue FLUSH TABLES WITH READ LOCK for as long as we we wait to issue FLUSH TABLES WITH READ LOCK for as long as we
can to minimize the lock time. can to minimize the lock time.
*/ */
if (mc_mysql_query(&mysql, "FLUSH TABLES WITH READ LOCK", 27) || if (mysql_real_query(&mysql, "FLUSH TABLES WITH READ LOCK", 27) ||
mc_mysql_query(&mysql, "SHOW MASTER STATUS",18) || mysql_real_query(&mysql, "SHOW MASTER STATUS",18) ||
!(master_status_res = mc_mysql_store_result(&mysql))) !(master_status_res = mysql_store_result(&mysql)))
{ {
net_printf(thd, error = ER_QUERY_ON_MASTER, net_printf(thd, error = ER_QUERY_ON_MASTER,
mc_mysql_error(&mysql)); mysql_error(&mysql));
goto err; goto err;
} }
...@@ -805,7 +806,7 @@ int load_master_data(THD* thd) ...@@ -805,7 +806,7 @@ int load_master_data(THD* thd)
cur_table_res++) cur_table_res++)
{ {
// since we know how many rows we have, this can never be NULL // since we know how many rows we have, this can never be NULL
MYSQL_ROW row = mc_mysql_fetch_row(db_res); MYSQL_ROW row = mysql_fetch_row(db_res);
char* db = row[0]; char* db = row[0];
/* /*
...@@ -834,12 +835,12 @@ int load_master_data(THD* thd) ...@@ -834,12 +835,12 @@ int load_master_data(THD* thd)
goto err; goto err;
} }
if (mc_mysql_select_db(&mysql, db) || if (mysql_select_db(&mysql, db) ||
mc_mysql_query(&mysql, "SHOW TABLES", 11) || mysql_real_query(&mysql, "SHOW TABLES", 11) ||
!(*cur_table_res = mc_mysql_store_result(&mysql))) !(*cur_table_res = mysql_store_result(&mysql)))
{ {
net_printf(thd, error = ER_QUERY_ON_MASTER, net_printf(thd, error = ER_QUERY_ON_MASTER,
mc_mysql_error(&mysql)); mysql_error(&mysql));
cleanup_mysql_results(db_res, cur_table_res - 1, table_res); cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
goto err; goto err;
} }
...@@ -857,7 +858,7 @@ int load_master_data(THD* thd) ...@@ -857,7 +858,7 @@ int load_master_data(THD* thd)
// adjust position in the master // adjust position in the master
if (master_status_res) if (master_status_res)
{ {
MYSQL_ROW row = mc_mysql_fetch_row(master_status_res); MYSQL_ROW row = mysql_fetch_row(master_status_res);
/* /*
We need this check because the master may not be running with We need this check because the master may not be running with
...@@ -875,13 +876,13 @@ int load_master_data(THD* thd) ...@@ -875,13 +876,13 @@ int load_master_data(THD* thd)
active_mi->master_log_pos = BIN_LOG_HEADER_SIZE; active_mi->master_log_pos = BIN_LOG_HEADER_SIZE;
flush_master_info(active_mi); flush_master_info(active_mi);
} }
mc_mysql_free_result(master_status_res); mysql_free_result(master_status_res);
} }
if (mc_mysql_query(&mysql, "UNLOCK TABLES", 13)) if (mysql_real_query(&mysql, "UNLOCK TABLES", 13))
{ {
net_printf(thd, error = ER_QUERY_ON_MASTER, net_printf(thd, error = ER_QUERY_ON_MASTER,
mc_mysql_error(&mysql)); mysql_error(&mysql));
goto err; goto err;
} }
} }
...@@ -920,7 +921,7 @@ err: ...@@ -920,7 +921,7 @@ err:
UNLOCK_ACTIVE_MI; UNLOCK_ACTIVE_MI;
thd->proc_info = 0; thd->proc_info = 0;
mc_mysql_close(&mysql); // safe to call since we always do mc_mysql_init() mysql_close(&mysql); // safe to call since we always do mysql_init()
if (!error) if (!error)
send_ok(thd); send_ok(thd);
......
This diff is collapsed.
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