summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-12-13 14:00:20 +0200
committerMichael Widenius <monty@askmonty.org>2011-12-13 14:00:20 +0200
commitb653115c8e0ce1015b74f9aeab3ad30f71ce4379 (patch)
tree6ab1272ea53db0ece3c05a3997d5348bb5d676c7 /sql/sql_parse.cc
parent63d32c115dd962b53cf7bcaa340472ee2f44f9e2 (diff)
downloadmariadb-git-b653115c8e0ce1015b74f9aeab3ad30f71ce4379.tar.gz
Fixed valgrind error when storing db_name_length in query_cache.
- Changed storage to be 2 bytes instead of sizeof(size_t) (simple optimization) - Fixed bug when using query_cache_strip_comments and query that started with '(' - Fixed DBUG_PRINT() that used wrong (not initialized) variables. mysql-test/mysql-test-run.pl: Added some space to make output more readable. mysql-test/r/query_cache.result: Updated test results mysql-test/t/query_cache.test: Added test with query_cache_strip_comments sql/mysql_priv.h: Added QUERY_CACHE_DB_LENGTH_SIZE sql/sql_cache.cc: Fixed bug when using query_cache_strip_comments and query that started with '(' Store db length in 2 characters instead of size_t. Get db length from correct position (earlier we had an error when query started with ' ') Fixed DBUG_PRINT() that used wrong (not initialized) variables.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index cdfbce7f0e3..1676d4a09f4 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -508,10 +508,10 @@ static void handle_bootstrap_impl(THD *thd)
query= (char *) thd->memdup_w_gap(buff, length + 1,
thd->db_length + 1 +
+ QUERY_CACHE_DB_LENGTH_SIZE +
QUERY_CACHE_FLAGS_SIZE);
- size_t db_len= 0;
- memcpy(query + length + 1, (char *) &db_len, sizeof(size_t));
thd->set_query(query, length);
+ int2store(query + length + 1, 0); // No db in bootstrap
DBUG_PRINT("query",("%-.4096s", thd->query()));
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.start_new_query();
@@ -1880,7 +1880,8 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length)
*/
if (! (query= (char*) thd->memdup_w_gap(packet,
packet_length,
- 1 + sizeof(size_t) + thd->db_length +
+ 1 + thd->db_length +
+ QUERY_CACHE_DB_LENGTH_SIZE +
QUERY_CACHE_FLAGS_SIZE)))
return TRUE;
query[packet_length]= '\0';
@@ -1889,8 +1890,7 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length)
also store this length, in case current database is changed during
execution. We might need to reallocate the 'query' buffer
*/
- char *len_pos = (query + packet_length + 1);
- memcpy(len_pos, (char *) &thd->db_length, sizeof(size_t));
+ int2store(query + packet_length + 1, thd->db_length);
thd->set_query(query, packet_length);