diff options
author | unknown <heikki@hundin.mysql.fi> | 2004-05-14 16:48:56 +0300 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2004-05-14 16:48:56 +0300 |
commit | 7bd91ac065746ba673f24d39c646dcbf7cb74386 (patch) | |
tree | b754d8cebf93bbb70cb8401e05e31ea14aeecf85 /sql/sql_class.h | |
parent | 2d743fe227f469c0dbaba803e818b4e23a3e2a76 (diff) | |
download | mariadb-git-7bd91ac065746ba673f24d39c646dcbf7cb74386.tar.gz |
Many files:
Fix remaining cases of Bug #3596: fix possible races caused by an obsolete value of thd->query_length in SHOW PROCESSLIST and SHOW INNODB STATUS; this fix depends on the fact that thd->query is always set to NULL before setting it to point to a new query
sql/sql_class.h:
Fix remaining cases of Bug #3596: fix possible races caused by an obsolete value of thd->query_length in SHOW PROCESSLIST and SHOW INNODB STATUS; this fix depends on the fact that thd->query is always set to NULL before setting it to point to a new query
sql/ha_innodb.cc:
Fix remaining cases of Bug #3596: fix possible races caused by an obsolete value of thd->query_length in SHOW PROCESSLIST and SHOW INNODB STATUS; this fix depends on the fact that thd->query is always set to NULL before setting it to point to a new query
sql/log_event.cc:
Fix remaining cases of Bug #3596: fix possible races caused by an obsolete value of thd->query_length in SHOW PROCESSLIST and SHOW INNODB STATUS; this fix depends on the fact that thd->query is always set to NULL before setting it to point to a new query
sql/slave.cc:
Fix remaining cases of Bug #3596: fix possible races caused by an obsolete value of thd->query_length in SHOW PROCESSLIST and SHOW INNODB STATUS; this fix depends on the fact that thd->query is always set to NULL before setting it to point to a new query
sql/sql_db.cc:
Fix remaining cases of Bug #3596: fix possible races caused by an obsolete value of thd->query_length in SHOW PROCESSLIST and SHOW INNODB STATUS; this fix depends on the fact that thd->query is always set to NULL before setting it to point to a new query
sql/sql_parse.cc:
Fix remaining cases of Bug #3596: fix possible races caused by an obsolete value of thd->query_length in SHOW PROCESSLIST and SHOW INNODB STATUS; this fix depends on the fact that thd->query is always set to NULL before setting it to point to a new query
sql/sql_show.cc:
Fix remaining cases of Bug #3596: fix possible races caused by an obsolete value of thd->query_length in SHOW PROCESSLIST and SHOW INNODB STATUS; this fix depends on the fact that thd->query is always set to NULL before setting it to point to a new query
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index ad1eed5448f..83dc75e2b84 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -360,7 +360,24 @@ public: struct rand_struct rand; // used for authentication struct system_variables variables; // Changeable local variables pthread_mutex_t LOCK_delete; // Locked before thd is deleted - + /* + Note that (A) if we set query = NULL, we must at the same time set + query_length = 0, and protect the whole operation with the + LOCK_thread_count mutex. And (B) we are ONLY allowed to set query to a + non-NULL value if its previous value is NULL. We do not need to protect + operation (B) with any mutex. To avoid crashes in races, if we do not + know that thd->query cannot change at the moment, one should print + thd->query like this: + (1) reserve the LOCK_thread_count mutex; + (2) check if thd->query is NULL; + (3) if not NULL, then print at most thd->query_length characters from + it. We will see the query_length field as either 0, or the right value + for it. + Assuming that the write and read of an n-bit memory field in an n-bit + computer is atomic, we can avoid races in the above way. + This printing is needed at least in SHOW PROCESSLIST and SHOW INNODB + STATUS. + */ char *query; // Points to the current query, /* A pointer to the stack frame of handle_one_connection(), |