Skip to content

Commit 46b67a3

Browse files
author
Andrei Elkin
committed
fixing the prev "auto"-merge that carried a piece of deprecated code (existing in 5.1)
1 parent a6f2076 commit 46b67a3

File tree

1 file changed

+0
-193
lines changed

1 file changed

+0
-193
lines changed

sql/slave.cc

Lines changed: 0 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,199 +1458,6 @@ when it try to get the value of TIME_ZONE global variable from master.";
14581458
DBUG_RETURN(2);
14591459
}
14601460

1461-
/*
1462-
Used by fetch_master_table (used by LOAD TABLE tblname FROM MASTER and LOAD
1463-
DATA FROM MASTER). Drops the table (if 'overwrite' is true) and recreates it
1464-
from the dump. Honours replication inclusion/exclusion rules.
1465-
db must be non-zero (guarded by assertion).
1466-
1467-
RETURN VALUES
1468-
0 success
1469-
1 error
1470-
*/
1471-
1472-
static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
1473-
const char* table_name, bool overwrite)
1474-
{
1475-
ulong packet_len;
1476-
char *query, *save_db;
1477-
uint32 save_db_length;
1478-
Vio* save_vio;
1479-
HA_CHECK_OPT check_opt;
1480-
TABLE_LIST tables;
1481-
int error= 1;
1482-
handler *file;
1483-
ulonglong save_options;
1484-
NET *net= &mysql->net;
1485-
const char *found_semicolon= NULL;
1486-
DBUG_ENTER("create_table_from_dump");
1487-
1488-
packet_len= my_net_read(net); // read create table statement
1489-
if (packet_len == packet_error)
1490-
{
1491-
my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
1492-
DBUG_RETURN(1);
1493-
}
1494-
if (net->read_pos[0] == 255) // error from master
1495-
{
1496-
char *err_msg;
1497-
err_msg= (char*) net->read_pos + ((mysql->server_capabilities &
1498-
CLIENT_PROTOCOL_41) ?
1499-
3+SQLSTATE_LENGTH+1 : 3);
1500-
my_error(ER_MASTER, MYF(0), err_msg);
1501-
DBUG_RETURN(1);
1502-
}
1503-
thd->command = COM_TABLE_DUMP;
1504-
if (!(query = thd->strmake((char*) net->read_pos, packet_len)))
1505-
{
1506-
sql_print_error("create_table_from_dump: out of memory");
1507-
my_message(ER_GET_ERRNO, "Out of memory", MYF(0));
1508-
DBUG_RETURN(1);
1509-
}
1510-
thd->set_query(query, packet_len);
1511-
thd->is_slave_error = 0;
1512-
1513-
bzero((char*) &tables,sizeof(tables));
1514-
tables.db = (char*)db;
1515-
tables.alias= tables.table_name= (char*)table_name;
1516-
1517-
/* Drop the table if 'overwrite' is true */
1518-
if (overwrite)
1519-
{
1520-
if (mysql_rm_table(thd,&tables,1,0)) /* drop if exists */
1521-
{
1522-
sql_print_error("create_table_from_dump: failed to drop the table");
1523-
goto err;
1524-
}
1525-
else
1526-
{
1527-
/* Clear the OK result of mysql_rm_table(). */
1528-
thd->main_da.reset_diagnostics_area();
1529-
}
1530-
}
1531-
1532-
/* Create the table. We do not want to log the "create table" statement */
1533-
save_options = thd->options;
1534-
thd->options &= ~ (OPTION_BIN_LOG);
1535-
thd_proc_info(thd, "Creating table from master dump");
1536-
// save old db in case we are creating in a different database
1537-
save_db = thd->db;
1538-
save_db_length= thd->db_length;
1539-
thd->db = (char*)db;
1540-
DBUG_ASSERT(thd->db != 0);
1541-
thd->db_length= strlen(thd->db);
1542-
/* run create table */
1543-
mysql_parse(thd, thd->query(), packet_len, &found_semicolon);
1544-
thd->db = save_db; // leave things the way the were before
1545-
thd->db_length= save_db_length;
1546-
thd->options = save_options;
1547-
1548-
if (thd->is_slave_error)
1549-
goto err; // mysql_parse took care of the error send
1550-
1551-
thd_proc_info(thd, "Opening master dump table");
1552-
thd->main_da.reset_diagnostics_area(); /* cleanup from CREATE_TABLE */
1553-
/*
1554-
Note: If this function starts to fail for MERGE tables,
1555-
change the next two lines to these:
1556-
tables.table= NULL; // was set by mysql_rm_table()
1557-
if (!open_n_lock_single_table(thd, &tables, TL_WRITE))
1558-
*/
1559-
tables.lock_type = TL_WRITE;
1560-
if (!open_ltable(thd, &tables, TL_WRITE, 0))
1561-
{
1562-
sql_print_error("create_table_from_dump: could not open created table");
1563-
goto err;
1564-
}
1565-
1566-
file = tables.table->file;
1567-
thd_proc_info(thd, "Reading master dump table data");
1568-
/* Copy the data file */
1569-
if (file->net_read_dump(net))
1570-
{
1571-
my_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
1572-
sql_print_error("create_table_from_dump: failed in\
1573-
handler::net_read_dump()");
1574-
goto err;
1575-
}
1576-
1577-
check_opt.init();
1578-
check_opt.flags|= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
1579-
thd_proc_info(thd, "Rebuilding the index on master dump table");
1580-
/*
1581-
We do not want repair() to spam us with messages
1582-
just send them to the error log, and report the failure in case of
1583-
problems.
1584-
*/
1585-
save_vio = thd->net.vio;
1586-
thd->net.vio = 0;
1587-
/* Rebuild the index file from the copied data file (with REPAIR) */
1588-
error=file->ha_repair(thd,&check_opt) != 0;
1589-
thd->net.vio = save_vio;
1590-
if (error)
1591-
my_error(ER_INDEX_REBUILD, MYF(0), tables.table->s->table_name.str);
1592-
1593-
err:
1594-
close_thread_tables(thd);
1595-
DBUG_RETURN(error);
1596-
}
1597-
1598-
1599-
int fetch_master_table(THD *thd, const char *db_name, const char *table_name,
1600-
Master_info *mi, MYSQL *mysql, bool overwrite)
1601-
{
1602-
int error= 1;
1603-
const char *errmsg=0;
1604-
bool called_connected= (mysql != NULL);
1605-
DBUG_ENTER("fetch_master_table");
1606-
DBUG_PRINT("enter", ("db_name: '%s' table_name: '%s'",
1607-
db_name,table_name));
1608-
1609-
if (!called_connected)
1610-
{
1611-
if (!(mysql = mysql_init(NULL)))
1612-
{
1613-
DBUG_RETURN(1);
1614-
}
1615-
if (connect_to_master(thd, mysql, mi))
1616-
{
1617-
my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql));
1618-
/*
1619-
We need to clear the active VIO since, theoretically, somebody
1620-
might issue an awake() on this thread. If we are then in the
1621-
middle of closing and destroying the VIO inside the
1622-
mysql_close(), we will have a problem.
1623-
*/
1624-
#ifdef SIGNAL_WITH_VIO_CLOSE
1625-
thd->clear_active_vio();
1626-
#endif
1627-
mysql_close(mysql);
1628-
DBUG_RETURN(1);
1629-
}
1630-
if (thd->killed)
1631-
goto err;
1632-
}
1633-
1634-
if (request_table_dump(mysql, db_name, table_name))
1635-
{
1636-
error= ER_UNKNOWN_ERROR;
1637-
errmsg= "Failed on table dump request";
1638-
goto err;
1639-
}
1640-
if (create_table_from_dump(thd, mysql, db_name,
1641-
table_name, overwrite))
1642-
goto err; // create_table_from_dump have sent the error already
1643-
error = 0;
1644-
1645-
err:
1646-
if (!called_connected)
1647-
mysql_close(mysql);
1648-
if (errmsg && thd->vio_ok())
1649-
my_message(error, errmsg, MYF(0));
1650-
DBUG_RETURN(test(error)); // Return 1 on error
1651-
}
1652-
1653-
16541461
static bool wait_for_relay_log_space(Relay_log_info* rli)
16551462
{
16561463
bool slave_killed=0;

0 commit comments

Comments
 (0)