Commit b2ba400f authored by unknown's avatar unknown

Merge with 3.23 to get bug fix for SHOW PROCESSLIST + running thread


myisam/mi_create.c:
  Auto merged
sql/log.cc:
  Auto merged
innobase/btr/btr0sea.c:
  Merge with 3.23 (use local file)
sql/slave.cc:
  merge with 3.23
sql/sql_db.cc:
  Merge with 3.23
sql/sql_parse.cc:
  Merge with 3.23
parents 43523184 e7193c63
...@@ -867,6 +867,7 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, ...@@ -867,6 +867,7 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
const char* table_name) const char* table_name)
{ {
ulong packet_len = my_net_read(net); // read create table statement ulong packet_len = my_net_read(net); // read create table statement
char *query;
Vio* save_vio; Vio* save_vio;
HA_CHECK_OPT check_opt; HA_CHECK_OPT check_opt;
TABLE_LIST tables; TABLE_LIST tables;
...@@ -886,15 +887,23 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, ...@@ -886,15 +887,23 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
return 1; return 1;
} }
thd->command = COM_TABLE_DUMP; thd->command = COM_TABLE_DUMP;
thd->query = sql_alloc(packet_len + 1); /* Note that we should not set thd->query until the area is initalized */
if (!thd->query) if (!(query = sql_alloc(packet_len + 1)))
{ {
sql_print_error("create_table_from_dump: out of memory"); sql_print_error("create_table_from_dump: out of memory");
net_printf(&thd->net, ER_GET_ERRNO, "Out of memory"); net_printf(&thd->net, ER_GET_ERRNO, "Out of memory");
return 1; return 1;
} }
memcpy(thd->query, net->read_pos, packet_len); memcpy(query, net->read_pos, packet_len);
thd->query[packet_len] = 0; query[packet_len]= 0;
thd->query_length= packet_len;
/*
We make the following lock in an attempt to ensure that the compiler will
not rearrange the code so that thd->query is set too soon
*/
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query= query;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
thd->current_tablenr = 0; thd->current_tablenr = 0;
thd->query_error = 0; thd->query_error = 0;
thd->net.no_send_ok = 1; thd->net.no_send_ok = 1;
...@@ -2049,7 +2058,9 @@ log space"); ...@@ -2049,7 +2058,9 @@ log space");
// print the current replication position // print the current replication position
sql_print_error("Slave I/O thread exiting, read up to log '%s', position %s", sql_print_error("Slave I/O thread exiting, read up to log '%s', position %s",
IO_RPL_LOG_NAME, llstr(mi->master_log_pos,llbuff)); IO_RPL_LOG_NAME, llstr(mi->master_log_pos,llbuff));
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = thd->db = 0; // extra safety thd->query = thd->db = 0; // extra safety
VOID(pthread_mutex_unlock(&LOCK_thread_count));
if (mysql) if (mysql)
{ {
mc_mysql_close(mysql); mc_mysql_close(mysql);
...@@ -2183,7 +2194,9 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ ...@@ -2183,7 +2194,9 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
RPL_LOG_NAME, llstr(rli->master_log_pos,llbuff)); RPL_LOG_NAME, llstr(rli->master_log_pos,llbuff));
err: err:
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = thd->db = 0; // extra safety thd->query = thd->db = 0; // extra safety
VOID(pthread_mutex_unlock(&LOCK_thread_count));
thd->proc_info = "Waiting for slave mutex on exit"; thd->proc_info = "Waiting for slave mutex on exit";
pthread_mutex_lock(&rli->run_lock); pthread_mutex_lock(&rli->run_lock);
DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun
......
...@@ -78,9 +78,9 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent) ...@@ -78,9 +78,9 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
if (!thd->query) if (!thd->query)
{ {
/* The client used the old obsolete mysql_create_db() call */ /* The client used the old obsolete mysql_create_db() call */
thd->query = path;
thd->query_length = (uint) (strxmov(path,"create database `", db, "`", thd->query_length = (uint) (strxmov(path,"create database `", db, "`",
NullS) - path); NullS) - path);
thd->query = path;
} }
{ {
mysql_update_log.write(thd,thd->query, thd->query_length); mysql_update_log.write(thd,thd->query, thd->query_length);
...@@ -92,8 +92,9 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent) ...@@ -92,8 +92,9 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
} }
if (thd->query == path) if (thd->query == path)
{ {
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = 0; // just in case thd->query = 0; // just in case
thd->query_length = 0; VOID(pthread_mutex_unlock(&LOCK_thread_count));
} }
send_ok(&thd->net, result); send_ok(&thd->net, result);
} }
...@@ -167,9 +168,10 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -167,9 +168,10 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{ {
if (!thd->query) if (!thd->query)
{ {
thd->query = path; thd->query_length= (uint) (strxmov(path,"drop database `", db, "`",
thd->query_length = (uint) (strxmov(path,"drop database ", db, NullS)- NullS)-
path); path);
thd->query= path;
} }
mysql_update_log.write(thd, thd->query, thd->query_length); mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
...@@ -179,8 +181,9 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -179,8 +181,9 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
} }
if (thd->query == path) if (thd->query == path)
{ {
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = 0; // just in case thd->query = 0; // just in case
thd->query_length = 0; VOID(pthread_mutex_unlock(&LOCK_thread_count));
} }
send_ok(&thd->net,(ulong) deleted); send_ok(&thd->net,(ulong) deleted);
} }
......
...@@ -852,7 +852,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) ...@@ -852,7 +852,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
goto err; goto err;
} }
net_flush(&thd->net); net_flush(&thd->net);
if ((error = table->file->dump(thd,fd))) if ((error= table->file->dump(thd,fd)))
my_error(ER_GET_ERRNO, MYF(0)); my_error(ER_GET_ERRNO, MYF(0));
err: err:
...@@ -958,7 +958,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -958,7 +958,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
tbl_name[tbl_len] = 0; tbl_name[tbl_len] = 0;
if (mysql_table_dump(thd, db, tbl_name, -1)) if (mysql_table_dump(thd, db, tbl_name, -1))
send_error(&thd->net); // dump to NET send_error(&thd->net); // dump to NET
break; break;
} }
case COM_CHANGE_USER: case COM_CHANGE_USER:
......
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