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 \
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
item_uniq.cc item_subselect.cc item_row.cc\
key.cc lock.cc log.cc log_event.cc mf_iocache.cc\
mini_client.cc protocol.cc net_serv.cc opt_ft.cc opt_range.cc \
key.cc lock.cc log.cc log_event.cc \
protocol.cc net_serv.cc opt_ft.cc opt_range.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_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_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_string.cc sql_table.cc sql_test.cc sql_udf.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 @@
#ifndef _MINI_CLIENT_H
#define _MINI_CLIENT_H
MYSQL *
mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,ulong client_flag,
uint net_read_timeout);
MYSQL* mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,uint client_flag,
uint net_read_timeout);
int mc_simple_command(MYSQL *mysql,enum enum_server_command command,
const char *arg, uint length, my_bool skipp_check);
void mc_mysql_close(MYSQL *mysql);
MYSQL *mc_mysql_init(MYSQL *mysql);
void mc_mysql_debug(const char *debug);
ulong mc_net_safe_read(MYSQL *mysql);
char *mc_mysql_error(MYSQL *mysql);
int mc_mysql_errno(MYSQL *mysql);
my_bool mc_mysql_reconnect(MYSQL* mysql);
int mc_mysql_send_query(MYSQL* mysql, const char* query, uint length);
int mc_mysql_read_query_result(MYSQL *mysql);
int mc_mysql_query(MYSQL *mysql, const char *query, uint length);
MYSQL_RES * mc_mysql_store_result(MYSQL *mysql);
void mc_mysql_free_result(MYSQL_RES *result);
void mc_mysql_data_seek(MYSQL_RES *result, my_ulonglong row);
my_ulonglong mc_mysql_num_rows(MYSQL_RES *res);
unsigned int mc_mysql_num_fields(MYSQL_RES *res);
MYSQL_ROW STDCALL mc_mysql_fetch_row(MYSQL_RES *res);
int mc_mysql_select_db(MYSQL *mysql, const char *db);
void mc_end_server(MYSQL *mysql);
my_bool simple_command(MYSQL *mysql,enum enum_server_command command,
const char *arg, unsigned long length,
my_bool skip_check);
void mysql_close(MYSQL *mysql);
MYSQL *mysql_init(MYSQL *mysql);
void mysql_debug(const char *debug);
ulong net_safe_read(MYSQL *mysql);
const char *mysql_error(MYSQL *mysql);
unsigned int mysql_errno(MYSQL *mysql);
my_bool mysql_reconnect(MYSQL* mysql);
int mysql_send_query(MYSQL* mysql, const char* query, uint length);
my_bool mysql_read_query_result(MYSQL *mysql);
int mysql_real_query(MYSQL *mysql, const char *q, unsigned long length);
MYSQL_RES * mysql_store_result(MYSQL *mysql);
void mysql_free_result(MYSQL_RES *result);
void mysql_data_seek(MYSQL_RES *result, my_ulonglong row);
my_ulonglong mysql_num_rows(MYSQL_RES *res);
unsigned int mysql_num_fields(MYSQL_RES *res);
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *res);
int mysql_select_db(MYSQL *mysql, const char *db);
void end_server(MYSQL *mysql);
#endif
......@@ -484,14 +484,15 @@ int update_slave_list(MYSQL* mysql, MASTER_INFO* mi)
int port_ind;
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;
}
switch (mc_mysql_num_fields(res)) {
switch (mysql_num_fields(res)) {
case 5:
have_auth_info = 0;
port_ind=2;
......@@ -508,7 +509,7 @@ HOSTS";
pthread_mutex_lock(&LOCK_slave_list);
while ((row= mc_mysql_fetch_row(res)))
while ((row= mysql_fetch_row(res)))
{
uint32 server_id;
SLAVE_INFO* si, *old_si;
......@@ -541,7 +542,7 @@ HOSTS";
err:
if (res)
mc_mysql_free_result(res);
mysql_free_result(res);
if (error)
{
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)
thd->thread_stack = (char*)&thd;
MYSQL* recovery_captain = 0;
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");
goto err;
......@@ -599,7 +600,7 @@ pthread_handler_decl(handle_failsafe_rpl,arg)
pthread_mutex_unlock(&LOCK_rpl_status);
err:
if (recovery_captain)
mc_mysql_close(recovery_captain);
mysql_close(recovery_captain);
delete thd;
my_thread_end();
pthread_exit(0);
......@@ -668,7 +669,7 @@ int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
strmov(mysql->net.last_error, "Master is not configured");
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,
slave_net_timeout))
DBUG_RETURN(1);
......@@ -682,9 +683,9 @@ static inline void cleanup_mysql_results(MYSQL_RES* db_res,
for (; cur >= start; --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,
MYSQL_RES *table_res, MASTER_INFO *mi)
{
MYSQL_ROW row;
for (row = mc_mysql_fetch_row(table_res); row;
row = mc_mysql_fetch_row(table_res))
for (row = mysql_fetch_row(table_res); row;
row = mysql_fetch_row(table_res))
{
TABLE_LIST table;
const char* table_name= row[0];
......@@ -727,7 +728,7 @@ int load_master_data(THD* thd)
int error = 0;
const char* errmsg=0;
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
......@@ -749,7 +750,7 @@ int load_master_data(THD* thd)
if (connect_to_master(thd, &mysql, active_mi))
{
net_printf(thd, error= ER_CONNECT_TO_MASTER,
mc_mysql_error(&mysql));
mysql_error(&mysql));
goto err;
}
......@@ -758,15 +759,15 @@ int load_master_data(THD* thd)
MYSQL_RES *db_res, **table_res, **table_res_end, **cur_table_res;
uint num_dbs;
if (mc_mysql_query(&mysql, "SHOW DATABASES", 14) ||
!(db_res = mc_mysql_store_result(&mysql)))
if (mysql_real_query(&mysql, "SHOW DATABASES", 14) ||
!(db_res = mysql_store_result(&mysql)))
{
net_printf(thd, error = ER_QUERY_ON_MASTER,
mc_mysql_error(&mysql));
mysql_error(&mysql));
goto err;
}
if (!(num_dbs = (uint) mc_mysql_num_rows(db_res)))
if (!(num_dbs = (uint) mysql_num_rows(db_res)))
goto err;
/*
In theory, the master could have no databases at all
......@@ -785,12 +786,12 @@ int load_master_data(THD* thd)
we wait to issue FLUSH TABLES WITH READ LOCK for as long as we
can to minimize the lock time.
*/
if (mc_mysql_query(&mysql, "FLUSH TABLES WITH READ LOCK", 27) ||
mc_mysql_query(&mysql, "SHOW MASTER STATUS",18) ||
!(master_status_res = mc_mysql_store_result(&mysql)))
if (mysql_real_query(&mysql, "FLUSH TABLES WITH READ LOCK", 27) ||
mysql_real_query(&mysql, "SHOW MASTER STATUS",18) ||
!(master_status_res = mysql_store_result(&mysql)))
{
net_printf(thd, error = ER_QUERY_ON_MASTER,
mc_mysql_error(&mysql));
mysql_error(&mysql));
goto err;
}
......@@ -805,7 +806,7 @@ int load_master_data(THD* thd)
cur_table_res++)
{
// 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];
/*
......@@ -834,12 +835,12 @@ int load_master_data(THD* thd)
goto err;
}
if (mc_mysql_select_db(&mysql, db) ||
mc_mysql_query(&mysql, "SHOW TABLES", 11) ||
!(*cur_table_res = mc_mysql_store_result(&mysql)))
if (mysql_select_db(&mysql, db) ||
mysql_real_query(&mysql, "SHOW TABLES", 11) ||
!(*cur_table_res = mysql_store_result(&mysql)))
{
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);
goto err;
}
......@@ -857,7 +858,7 @@ int load_master_data(THD* thd)
// adjust position in the master
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
......@@ -875,13 +876,13 @@ int load_master_data(THD* thd)
active_mi->master_log_pos = BIN_LOG_HEADER_SIZE;
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,
mc_mysql_error(&mysql));
mysql_error(&mysql));
goto err;
}
}
......@@ -920,7 +921,7 @@ err:
UNLOCK_ACTIVE_MI;
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)
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