fixing the prev "auto"-merge that carried a piece of deprecated code (existing in 5.1)
This commit is contained in:
parent
a6f2076c03
commit
46b67a3b29
193
sql/slave.cc
193
sql/slave.cc
@ -1458,199 +1458,6 @@ network_err:
|
||||
DBUG_RETURN(2);
|
||||
}
|
||||
|
||||
/*
|
||||
Used by fetch_master_table (used by LOAD TABLE tblname FROM MASTER and LOAD
|
||||
DATA FROM MASTER). Drops the table (if 'overwrite' is true) and recreates it
|
||||
from the dump. Honours replication inclusion/exclusion rules.
|
||||
db must be non-zero (guarded by assertion).
|
||||
|
||||
RETURN VALUES
|
||||
0 success
|
||||
1 error
|
||||
*/
|
||||
|
||||
static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
|
||||
const char* table_name, bool overwrite)
|
||||
{
|
||||
ulong packet_len;
|
||||
char *query, *save_db;
|
||||
uint32 save_db_length;
|
||||
Vio* save_vio;
|
||||
HA_CHECK_OPT check_opt;
|
||||
TABLE_LIST tables;
|
||||
int error= 1;
|
||||
handler *file;
|
||||
ulonglong save_options;
|
||||
NET *net= &mysql->net;
|
||||
const char *found_semicolon= NULL;
|
||||
DBUG_ENTER("create_table_from_dump");
|
||||
|
||||
packet_len= my_net_read(net); // read create table statement
|
||||
if (packet_len == packet_error)
|
||||
{
|
||||
my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (net->read_pos[0] == 255) // error from master
|
||||
{
|
||||
char *err_msg;
|
||||
err_msg= (char*) net->read_pos + ((mysql->server_capabilities &
|
||||
CLIENT_PROTOCOL_41) ?
|
||||
3+SQLSTATE_LENGTH+1 : 3);
|
||||
my_error(ER_MASTER, MYF(0), err_msg);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
thd->command = COM_TABLE_DUMP;
|
||||
if (!(query = thd->strmake((char*) net->read_pos, packet_len)))
|
||||
{
|
||||
sql_print_error("create_table_from_dump: out of memory");
|
||||
my_message(ER_GET_ERRNO, "Out of memory", MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
thd->set_query(query, packet_len);
|
||||
thd->is_slave_error = 0;
|
||||
|
||||
bzero((char*) &tables,sizeof(tables));
|
||||
tables.db = (char*)db;
|
||||
tables.alias= tables.table_name= (char*)table_name;
|
||||
|
||||
/* Drop the table if 'overwrite' is true */
|
||||
if (overwrite)
|
||||
{
|
||||
if (mysql_rm_table(thd,&tables,1,0)) /* drop if exists */
|
||||
{
|
||||
sql_print_error("create_table_from_dump: failed to drop the table");
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Clear the OK result of mysql_rm_table(). */
|
||||
thd->main_da.reset_diagnostics_area();
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the table. We do not want to log the "create table" statement */
|
||||
save_options = thd->options;
|
||||
thd->options &= ~ (OPTION_BIN_LOG);
|
||||
thd_proc_info(thd, "Creating table from master dump");
|
||||
// save old db in case we are creating in a different database
|
||||
save_db = thd->db;
|
||||
save_db_length= thd->db_length;
|
||||
thd->db = (char*)db;
|
||||
DBUG_ASSERT(thd->db != 0);
|
||||
thd->db_length= strlen(thd->db);
|
||||
/* run create table */
|
||||
mysql_parse(thd, thd->query(), packet_len, &found_semicolon);
|
||||
thd->db = save_db; // leave things the way the were before
|
||||
thd->db_length= save_db_length;
|
||||
thd->options = save_options;
|
||||
|
||||
if (thd->is_slave_error)
|
||||
goto err; // mysql_parse took care of the error send
|
||||
|
||||
thd_proc_info(thd, "Opening master dump table");
|
||||
thd->main_da.reset_diagnostics_area(); /* cleanup from CREATE_TABLE */
|
||||
/*
|
||||
Note: If this function starts to fail for MERGE tables,
|
||||
change the next two lines to these:
|
||||
tables.table= NULL; // was set by mysql_rm_table()
|
||||
if (!open_n_lock_single_table(thd, &tables, TL_WRITE))
|
||||
*/
|
||||
tables.lock_type = TL_WRITE;
|
||||
if (!open_ltable(thd, &tables, TL_WRITE, 0))
|
||||
{
|
||||
sql_print_error("create_table_from_dump: could not open created table");
|
||||
goto err;
|
||||
}
|
||||
|
||||
file = tables.table->file;
|
||||
thd_proc_info(thd, "Reading master dump table data");
|
||||
/* Copy the data file */
|
||||
if (file->net_read_dump(net))
|
||||
{
|
||||
my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
|
||||
sql_print_error("create_table_from_dump: failed in\
|
||||
handler::net_read_dump()");
|
||||
goto err;
|
||||
}
|
||||
|
||||
check_opt.init();
|
||||
check_opt.flags|= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
|
||||
thd_proc_info(thd, "Rebuilding the index on master dump table");
|
||||
/*
|
||||
We do not want repair() to spam us with messages
|
||||
just send them to the error log, and report the failure in case of
|
||||
problems.
|
||||
*/
|
||||
save_vio = thd->net.vio;
|
||||
thd->net.vio = 0;
|
||||
/* Rebuild the index file from the copied data file (with REPAIR) */
|
||||
error=file->ha_repair(thd,&check_opt) != 0;
|
||||
thd->net.vio = save_vio;
|
||||
if (error)
|
||||
my_error(ER_INDEX_REBUILD, MYF(0), tables.table->s->table_name.str);
|
||||
|
||||
err:
|
||||
close_thread_tables(thd);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
int fetch_master_table(THD *thd, const char *db_name, const char *table_name,
|
||||
Master_info *mi, MYSQL *mysql, bool overwrite)
|
||||
{
|
||||
int error= 1;
|
||||
const char *errmsg=0;
|
||||
bool called_connected= (mysql != NULL);
|
||||
DBUG_ENTER("fetch_master_table");
|
||||
DBUG_PRINT("enter", ("db_name: '%s' table_name: '%s'",
|
||||
db_name,table_name));
|
||||
|
||||
if (!called_connected)
|
||||
{
|
||||
if (!(mysql = mysql_init(NULL)))
|
||||
{
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (connect_to_master(thd, mysql, mi))
|
||||
{
|
||||
my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql));
|
||||
/*
|
||||
We need to clear the active VIO since, theoretically, somebody
|
||||
might issue an awake() on this thread. If we are then in the
|
||||
middle of closing and destroying the VIO inside the
|
||||
mysql_close(), we will have a problem.
|
||||
*/
|
||||
#ifdef SIGNAL_WITH_VIO_CLOSE
|
||||
thd->clear_active_vio();
|
||||
#endif
|
||||
mysql_close(mysql);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (thd->killed)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (request_table_dump(mysql, db_name, table_name))
|
||||
{
|
||||
error= ER_UNKNOWN_ERROR;
|
||||
errmsg= "Failed on table dump request";
|
||||
goto err;
|
||||
}
|
||||
if (create_table_from_dump(thd, mysql, db_name,
|
||||
table_name, overwrite))
|
||||
goto err; // create_table_from_dump have sent the error already
|
||||
error = 0;
|
||||
|
||||
err:
|
||||
if (!called_connected)
|
||||
mysql_close(mysql);
|
||||
if (errmsg && thd->vio_ok())
|
||||
my_message(error, errmsg, MYF(0));
|
||||
DBUG_RETURN(test(error)); // Return 1 on error
|
||||
}
|
||||
|
||||
|
||||
static bool wait_for_relay_log_space(Relay_log_info* rli)
|
||||
{
|
||||
bool slave_killed=0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user