diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-06-06 21:32:29 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-06-06 21:32:29 +0200 |
commit | 72ba95873a6d99def07a4bfecda44fb942165142 (patch) | |
tree | 4bcb11afc568c4894f4cb109d57c14968320a58b /sql/sql_cache.cc | |
parent | fab9a55d077b4f2a511b273d5f51272f1e3dc1ff (diff) | |
parent | 4749d40c635634e25e07d28ce1a04e9263bcc375 (diff) | |
download | mariadb-git-72ba95873a6d99def07a4bfecda44fb942165142.tar.gz |
10.0-base merge
(without InnoDB - all InnoDB changes were ignored)
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r-- | sql/sql_cache.cc | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index ba204f48978..436f7043c49 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -472,6 +472,8 @@ static void make_base_query(String *new_query, /* The following is guaranteed by the query_cache interface */ DBUG_ASSERT(query[query_length] == 0); DBUG_ASSERT(!is_white_space(query[0])); + /* We do not support UCS2, UTF16, UTF32 as a client character set */ + DBUG_ASSERT(current_thd->variables.character_set_client->mbminlen == 1); new_query->length(0); // Don't copy anything from old buffer if (new_query->realloc(query_length + additional_length)) @@ -2439,7 +2441,28 @@ void Query_cache::init() m_cache_status= Query_cache::OK; m_requests_in_progress= 0; initialized = 1; - query_state_map= default_charset_info->state_map; + /* + Using state_map from latin1 should be fine in all cases: + 1. We do not support UCS2, UTF16, UTF32 as a client character set. + 2. The other character sets are compatible on the lower ASCII-range + 0x00-0x20, and have the following characters marked as spaces: + + 0x09 TAB + 0x0A LINE FEED + 0x0B VERTICAL TAB + 0x0C FORM FEED + 0x0D CARRIAGE RETUR + 0x20 SPACE + + Additionally, only some of the ASCII-compatible character sets + (including latin1) can have 0xA0 mapped to "NON-BREAK SPACE" + and thus marked as space. + That should not be a problem for those charsets that map 0xA0 + to something else: the parser will just return syntax error + if this character appears straight in the query + (i.e. not inside a string literal or comment). + */ + query_state_map= my_charset_latin1.state_map; /* If we explicitly turn off query cache from the command line query cache will be disabled for the reminder of the server life @@ -3972,6 +3995,18 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used, /* +In non-embedded QC intercepts result in net_real_write +but if we have no net.vio then net_real_write +will not be called, so QC can't get results of the query +*/ +#ifdef EMBEDDED_LIBRARY +#define qc_is_able_to_intercept_result(T) 1 +#else +#define qc_is_able_to_intercept_result(T) ((T)->net.vio) +#endif + + +/* If query is cacheable return number tables in query (query without tables are not cached) */ @@ -3986,7 +4021,8 @@ Query_cache::is_cacheable(THD *thd, LEX *lex, if (thd->lex->safe_to_cache_query && (thd->variables.query_cache_type == 1 || (thd->variables.query_cache_type == 2 && (lex->select_lex.options & - OPTION_TO_QUERY_CACHE)))) + OPTION_TO_QUERY_CACHE))) && + qc_is_able_to_intercept_result(thd)) { DBUG_PRINT("qcache", ("options: %lx %lx type: %u", (long) OPTION_TO_QUERY_CACHE, @@ -4008,11 +4044,12 @@ Query_cache::is_cacheable(THD *thd, LEX *lex, } DBUG_PRINT("qcache", - ("not interesting query: %d or not cacheable, options %lx %lx type: %u", + ("not interesting query: %d or not cacheable, options %lx %lx type: %u net->vio present: %u", (int) lex->sql_command, (long) OPTION_TO_QUERY_CACHE, (long) lex->select_lex.options, - (int) thd->variables.query_cache_type)); + (int) thd->variables.query_cache_type, + (uint) test(qc_is_able_to_intercept_result(thd)))); DBUG_RETURN(0); } |