Commit 183df2da authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Fixes cases where thd->query was not protected.

This fixes a problem with SHOW PROCESSLIST
parent fb4572a4
...@@ -1702,10 +1702,11 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1702,10 +1702,11 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
if (db_ok(thd->db, replicate_do_db, replicate_ignore_db)) if (db_ok(thd->db, replicate_do_db, replicate_ignore_db))
{ {
thd->query = (char*)query;
thd->set_time((time_t)when); thd->set_time((time_t)when);
thd->current_tablenr = 0; thd->current_tablenr = 0;
thd->query_length= q_len;
VOID(pthread_mutex_lock(&LOCK_thread_count)); VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = (char*)query;
thd->query_id = query_id++; thd->query_id = query_id++;
VOID(pthread_mutex_unlock(&LOCK_thread_count)); VOID(pthread_mutex_unlock(&LOCK_thread_count));
thd->query_error = 0; // clear error thd->query_error = 0; // clear error
...@@ -1760,7 +1761,9 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1760,7 +1761,9 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
else else
{ {
// master could be inconsistent, abort and tell DBA to check/fix it // master could be inconsistent, abort and tell DBA to check/fix it
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->db = thd->query = 0; thd->db = thd->query = 0;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
thd->variables.convert_set = 0; thd->variables.convert_set = 0;
close_thread_tables(thd); close_thread_tables(thd);
free_root(&thd->mem_root,0); free_root(&thd->mem_root,0);
...@@ -1768,7 +1771,9 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) ...@@ -1768,7 +1771,9 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
} }
} }
thd->db= 0; // prevent db from being freed thd->db= 0; // prevent db from being freed
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query= 0; // just to be sure thd->query= 0; // just to be sure
VOID(pthread_mutex_unlock(&LOCK_thread_count));
// assume no convert for next query unless set explictly // assume no convert for next query unless set explictly
thd->variables.convert_set = 0; thd->variables.convert_set = 0;
close_thread_tables(thd); close_thread_tables(thd);
...@@ -1816,7 +1821,8 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, ...@@ -1816,7 +1821,8 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
{ {
init_sql_alloc(&thd->mem_root, 8192,0); init_sql_alloc(&thd->mem_root, 8192,0);
thd->db = rewrite_db((char*)db); thd->db = rewrite_db((char*)db);
thd->query = 0; DBUG_ASSERT(thd->query == 0);
thd->query = 0; // Should not be needed
thd->query_error = 0; thd->query_error = 0;
if (db_ok(thd->db, replicate_do_db, replicate_ignore_db)) if (db_ok(thd->db, replicate_do_db, replicate_ignore_db))
......
...@@ -2322,6 +2322,7 @@ my_bool grant_init(THD *org_thd) ...@@ -2322,6 +2322,7 @@ my_bool grant_init(THD *org_thd)
if (t_table->file->index_first(t_table->record[0])) if (t_table->file->index_first(t_table->record[0]))
{ {
t_table->file->index_end(); t_table->file->index_end();
return_val= 0;
goto end_unlock; goto end_unlock;
} }
grant_option= TRUE; grant_option= TRUE;
......
...@@ -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_length = (uint) (strxmov(path,"create database `", db, "`", thd->query_length= (uint) (strxmov(path,"create database `", db, "`",
NullS) - path); NullS) - path);
thd->query = path; thd->query= path;
} }
{ {
mysql_update_log.write(thd,thd->query, thd->query_length); mysql_update_log.write(thd,thd->query, thd->query_length);
...@@ -93,7 +93,7 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent) ...@@ -93,7 +93,7 @@ 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)); VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = 0; // just in case thd->query= 0;
VOID(pthread_mutex_unlock(&LOCK_thread_count)); VOID(pthread_mutex_unlock(&LOCK_thread_count));
} }
send_ok(&thd->net, result); send_ok(&thd->net, result);
...@@ -182,7 +182,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -182,7 +182,7 @@ 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)); VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = 0; // just in case thd->query= 0;
VOID(pthread_mutex_unlock(&LOCK_thread_count)); VOID(pthread_mutex_unlock(&LOCK_thread_count));
} }
send_ok(&thd->net,(ulong) deleted); send_ok(&thd->net,(ulong) deleted);
......
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