summaryrefslogtreecommitdiff
path: root/sql/slave.cc
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-01-19 01:31:43 +0200
committerunknown <monty@mashka.mysql.fi>2003-01-19 01:31:43 +0200
commitb2ba400f07d843903ab6efd946940a6e6e76fc3c (patch)
tree1511dd7f34610f206624b1626c7e8cffb903dd07 /sql/slave.cc
parent43523184f2c3664b221ef64c5b23dd7710e02bef (diff)
parente7193c63ceb339bede6775d563be53aae63c78c2 (diff)
downloadmariadb-git-b2ba400f07d843903ab6efd946940a6e6e76fc3c.tar.gz
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
Diffstat (limited to 'sql/slave.cc')
-rw-r--r--sql/slave.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index b8689a28a54..30c345f8030 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -867,6 +867,7 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
const char* table_name)
{
ulong packet_len = my_net_read(net); // read create table statement
+ char *query;
Vio* save_vio;
HA_CHECK_OPT check_opt;
TABLE_LIST tables;
@@ -886,15 +887,23 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
return 1;
}
thd->command = COM_TABLE_DUMP;
- thd->query = sql_alloc(packet_len + 1);
- if (!thd->query)
+ /* Note that we should not set thd->query until the area is initalized */
+ if (!(query = sql_alloc(packet_len + 1)))
{
sql_print_error("create_table_from_dump: out of memory");
net_printf(&thd->net, ER_GET_ERRNO, "Out of memory");
return 1;
}
- memcpy(thd->query, net->read_pos, packet_len);
- thd->query[packet_len] = 0;
+ memcpy(query, net->read_pos, packet_len);
+ 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->query_error = 0;
thd->net.no_send_ok = 1;
@@ -2049,7 +2058,9 @@ err:
// print the current replication position
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));
+ VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = thd->db = 0; // extra safety
+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
if (mysql)
{
mc_mysql_close(mysql);
@@ -2183,7 +2194,9 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
RPL_LOG_NAME, llstr(rli->master_log_pos,llbuff));
err:
+ VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = thd->db = 0; // extra safety
+ VOID(pthread_mutex_unlock(&LOCK_thread_count));
thd->proc_info = "Waiting for slave mutex on exit";
pthread_mutex_lock(&rli->run_lock);
DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun