mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
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.
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user