diff options
author | Michael Widenius <monty@askmonty.org> | 2011-12-13 14:00:20 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-12-13 14:00:20 +0200 |
commit | b653115c8e0ce1015b74f9aeab3ad30f71ce4379 (patch) | |
tree | 6ab1272ea53db0ece3c05a3997d5348bb5d676c7 /sql/sp_head.cc | |
parent | 63d32c115dd962b53cf7bcaa340472ee2f44f9e2 (diff) | |
download | mariadb-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/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 2d0870674f9..b30347a5ca7 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1024,17 +1024,18 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str) buffer :== <statement> The input statement(s) '\0' Terminating null char - <length> Length of following current database name (size_t) + <length> Length of following current database name 2 <db_name> Name of current database <flags> Flags struct */ - buf_len= qbuf.length() + 1 + sizeof(size_t) + thd->db_length + - QUERY_CACHE_FLAGS_SIZE + 1; + buf_len= (qbuf.length() + 1 + QUERY_CACHE_DB_LENGTH_SIZE + thd->db_length + + QUERY_CACHE_FLAGS_SIZE + 1); if ((pbuf= (char *) alloc_root(thd->mem_root, buf_len))) { + char *ptr= pbuf + qbuf.length(); memcpy(pbuf, qbuf.ptr(), qbuf.length()); - pbuf[qbuf.length()]= 0; - memcpy(pbuf+qbuf.length()+1, (char *) &thd->db_length, sizeof(size_t)); + *ptr= 0; + int2store(ptr+1, thd->db_length); } else DBUG_RETURN(TRUE); |