]> git.pld-linux.org Git - packages/mysql.git/blob - mysql-query_cache_enhance.patch
remove id expansion
[packages/mysql.git] / mysql-query_cache_enhance.patch
1 # name       : query_cache_with_comments.patch
2 # introduced : 11 or before
3 # maintainer : Oleg
4 #
5 #!!! notice !!!
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 --- /dev/null
9 +++ b/patch_info/query_cache_enhance.patch
10 @@ -0,0 +1,14 @@
11 +File=query_cache_enhance.patch
12 +Name= query cache Percona's cumulative patch
13 +Version=1.0
14 +Author=Percona <info@percona.com>
15 +License=GPL
16 +Comment= 1) Add new status - Waiting on query cache mutex (status_wait_query_cache_mutex.patch)
17 +         2) Remove comments from query (need for cache hit) (query_cache_with_comments.patch)
18 +         3) Totally disable query cache (query_cache_totally_disable.info)
19 +2010-05 - First version avaliable (query_cache_with_comments.patch)
20 +2010-07 - First version avaliable (status_wait_query_cache_mutex.patch
21 +2010-07 - First version avaliable (query_cache_totally_disable.info)
22 +2010-07 - Fix crash (query_cache_with_comments.patch)
23 +2010-07 - Fix incorrect behavior diff (query_cache_with_comments.patch)
24 +2010-09 - Merge patches to one
25 --- a/sql/mysqld.cc
26 +++ b/sql/mysqld.cc
27 @@ -535,6 +535,7 @@
28  my_bool opt_log_slow_slave_statements= 0;
29  my_bool opt_log_slow_sp_statements= 0;
30  my_bool opt_log_slow_timestamp_every= 0;
31 +my_bool opt_query_cache_strip_comments = 0;
32  my_bool opt_use_global_long_query_time= 0;
33  my_bool opt_slow_query_log_microseconds_timestamp= 0;
34  my_bool lower_case_file_system= 0;
35 @@ -5922,6 +5923,7 @@
36    OPT_THREAD_STATISTICS,
37    OPT_OPTIMIZER_FIX,
38    OPT_SUPPRESS_LOG_WARNING_1592,
39 +  OPT_QUERY_CACHE_STRIP_COMMENTS,
40    OPT_USE_GLOBAL_LONG_QUERY_TIME,
41    OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
42    OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP,
43 @@ -6977,6 +6979,10 @@
44    {"use_global_log_slow_control", OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
45      "Choose flags, wich always use the global variables. Multiple flags allowed in a comma-separated string. [none, log_slow_filter, log_slow_rate_limit, log_slow_verbosity, long_query_time, min_examined_row_limit, all]",
46     0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_UG_NONE, 0, 0},
47 +  {"query_cache_strip_comments", OPT_QUERY_CACHE_STRIP_COMMENTS,
48 +   "Enable and disable optimisation \"strip comment for query cache\" - optimisation strip all comments from query while search query result in query cache",
49 +   (uchar**) &opt_query_cache_strip_comments, (uchar**) &opt_query_cache_strip_comments,
50 +   0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
51    {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
52     "Control always use global long_query_time or local long_query_time.",
53     (uchar**) &opt_use_global_long_query_time, (uchar**) &opt_use_global_long_query_time,
54 --- a/sql/mysql_priv.h
55 +++ b/sql/mysql_priv.h
56 @@ -2117,6 +2117,7 @@
57  extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
58  extern my_bool opt_log_slow_sp_statements;
59  extern my_bool opt_log_slow_timestamp_every;
60 +extern my_bool opt_query_cache_strip_comments;
61  extern my_bool opt_use_global_long_query_time;
62  extern my_bool opt_slow_query_log_microseconds_timestamp;
63  extern my_bool sp_automatic_privileges, opt_noacl;
64 --- /dev/null
65 +++ b/sql/query_strip_comments.h
66 @@ -0,0 +1,37 @@
67 +#ifndef _SQL_QUERY_STRIPC_COMMENTS_H_
68 +#define _SQL_QUERY_STRIPC_COMMENTS_H_
69 +#ifdef HAVE_QUERY_CACHE
70 +
71 +// implemented in sql_cache.cc
72 +class QueryStripComments
73 +{
74 +private:
75 +  QueryStripComments(const QueryStripComments&);
76 +  QueryStripComments& operator=(const QueryStripComments&);
77 +public:
78 +  QueryStripComments();
79 +  ~QueryStripComments();
80 +  void set(const char* a_query, uint a_query_length, uint a_additional_length);
81 +  
82 +  char* query()        { return buffer; }
83 +  uint  query_length() { return length; }
84 +private:
85 +  void cleanup();
86 +private:
87 +  char* buffer;
88 +  uint  length /*query length, not buffer length*/;
89 +  uint  buffer_length;
90 +};
91 +class QueryStripComments_Backup
92 +{
93 +public:
94 +  QueryStripComments_Backup(THD* a_thd,QueryStripComments* qsc);
95 +  ~QueryStripComments_Backup();
96 +private:
97 +  THD*  thd;
98 +  char* query;
99 +  uint  length;
100 +};
101 +
102 +#endif // HAVE_QUERY_CACHE
103 +#endif // _SQL_QUERY_STRIPC_COMMENTS_H_
104 --- a/sql/set_var.cc
105 +++ b/sql/set_var.cc
106 @@ -126,8 +126,10 @@
107  static void fix_net_write_timeout(THD *thd, enum_var_type type);
108  static void fix_net_retry_count(THD *thd, enum_var_type type);
109  static void fix_max_join_size(THD *thd, enum_var_type type);
110 +#ifdef HAVE_QUERY_CACHE
111  static void fix_query_cache_size(THD *thd, enum_var_type type);
112  static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type);
113 +#endif
114  static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
115  static void fix_max_binlog_size(THD *thd, enum_var_type type);
116  static void fix_max_relay_log_size(THD *thd, enum_var_type type);
117 @@ -583,9 +585,6 @@
118                                                &SV::div_precincrement);
119  static sys_var_long_ptr        sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
120                                               &rpl_recovery_rank);
121 -static sys_var_long_ptr        sys_query_cache_size(&vars, "query_cache_size",
122 -                                            &query_cache_size,
123 -                                            fix_query_cache_size);
124  
125  static sys_var_thd_ulong       sys_range_alloc_block_size(&vars, "range_alloc_block_size",
126                                                    &SV::range_alloc_block_size);
127 @@ -651,14 +650,20 @@
128                                              NULL);
129  
130  #ifdef HAVE_QUERY_CACHE
131 +static sys_var_long_ptr        sys_query_cache_size(&vars, "query_cache_size",
132 +                                             &query_cache_size,
133 +                                             fix_query_cache_size);
134  static sys_var_long_ptr        sys_query_cache_limit(&vars, "query_cache_limit",
135                                               &query_cache.query_cache_limit);
136 -static sys_var_long_ptr        sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit",
137 +static sys_var_long_ptr
138 +  sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit",
139                                                      &query_cache_min_res_unit,
140                                                      fix_query_cache_min_res_unit);
141 +static int check_query_cache_type(THD *thd, set_var *var);
142  static sys_var_thd_enum        sys_query_cache_type(&vars, "query_cache_type",
143                                              &SV::query_cache_type,
144 -                                            &query_cache_type_typelib);
145 +                                            &query_cache_type_typelib, NULL,
146 +                                             check_query_cache_type);
147  static sys_var_thd_bool
148  sys_query_cache_wlock_invalidate(&vars, "query_cache_wlock_invalidate",
149                                  &SV::query_cache_wlock_invalidate);
150 @@ -942,6 +947,8 @@
151  #ifndef EMBEDDED_LIBRARY
152  static sys_var_const_str_ptr    sys_repl_report_host(&vars, "report_host", &report_host);
153  static sys_var_const_str_ptr    sys_repl_report_user(&vars, "report_user", &report_user);
154 +static sys_var_bool_ptr       sys_query_cache_strip_comments(&vars, "query_cache_strip_comments",
155 +                                                       &opt_query_cache_strip_comments);
156  static sys_var_const_str_ptr    sys_repl_report_password(&vars, "report_password", &report_password);
157  
158  static uchar *slave_get_report_port(THD *thd)
159 @@ -1259,10 +1266,9 @@
160  {}
161  #endif /* HAVE_REPLICATION */
162  
163 -
164 +#ifdef HAVE_QUERY_CACHE
165  static void fix_query_cache_size(THD *thd, enum_var_type type)
166  {
167 -#ifdef HAVE_QUERY_CACHE
168    ulong new_cache_size= query_cache.resize(query_cache_size);
169  
170    /*
171 @@ -1276,11 +1282,35 @@
172                         query_cache_size, new_cache_size);
173    
174    query_cache_size= new_cache_size;
175 -#endif
176  }
177  
178  
179 -#ifdef HAVE_QUERY_CACHE
180 +/**
181 +  Trigger before query_cache_type variable is updated.
182 +  @param thd Thread handler
183 +  @param var Pointer to the new variable status
184 +
185 +  @return Status code
186 +   @retval 1 Failure
187 +   @retval 0 Success
188 +*/
189 +
190 +static int check_query_cache_type(THD *thd, set_var *var)
191 +{
192 +  /*
193 +    Don't allow changes of the query_cache_type if the query cache
194 +    is disabled.
195 +  */
196 +  if (query_cache.is_disabled())
197 +  {
198 +    my_error(ER_QUERY_CACHE_DISABLED,MYF(0));
199 +    return 1;
200 +  }
201 +
202 +  return 0;
203 +}
204 +
205 +
206  static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type)
207  {
208    query_cache_min_res_unit= 
209 @@ -3638,6 +3668,16 @@
210    Functions to handle SET mysql_internal_variable=const_expr
211  *****************************************************************************/
212  
213 +/**
214 +  Verify that the supplied value is correct.
215 +
216 +  @param thd Thread handler
217 +
218 +  @return status code
219 +    @retval -1 Failure
220 +    @retval 0 Success
221 +*/
222 +
223  int set_var::check(THD *thd)
224  {
225    if (var->is_readonly())
226 --- a/sql/sql_cache.cc
227 +++ b/sql/sql_cache.cc
228 @@ -288,6 +288,7 @@
229           if (and only if) this query has a registered result set writer
230           (thd->net.query_cache_query).
231   4. Query_cache::invalidate
232 +    Query_cache::invalidate_locked_for_write
233         - Called from various places to invalidate query cache based on data-
234           base, table and myisam file name. During an on going invalidation
235           the query cache is temporarily disabled.
236 @@ -335,6 +336,181 @@
237  #include <hash.h>
238  #include "../storage/myisammrg/ha_myisammrg.h"
239  #include "../storage/myisammrg/myrg_def.h"
240 +#include "query_strip_comments.h"
241 +
242 +QueryStripComments::QueryStripComments()
243 +{
244 +  buffer = 0;
245 +  length = 0;
246 +  buffer_length = 0;
247 +}
248 +QueryStripComments::~QueryStripComments()
249 +{
250 +  cleanup();
251 +}
252 +
253 +inline bool query_strip_comments_is_white_space(char c)
254 +{
255 +  return ((' ' == c) || ('\t' == c) || ('\r' == c) || ('\n' ==c ));
256 +}
257 +void QueryStripComments::set(const char* query, uint query_length, uint additional_length)
258 +{
259 +  uint new_buffer_length = query_length + additional_length;
260 +  if(new_buffer_length > buffer_length)
261 +  {
262 +    cleanup();
263 +    buffer = (char*)my_malloc(new_buffer_length,MYF(0));
264 +    memset(buffer,0,new_buffer_length);
265 +  }
266 +  uint query_position = 0;
267 +  uint position = 0;
268 +  // Skip whitespaces from begin
269 +  while((query_position < query_length) && query_strip_comments_is_white_space(query[query_position]))
270 +  {
271 +    ++query_position;
272 +  }
273 +  long int last_space = -1;
274 +  while(query_position < query_length)
275 +  {
276 +    char current = query[query_position];
277 +    bool insert_space = false; // insert space to buffer, (IMPORTANT) don't update query_position
278 +    switch(current)
279 +    {
280 +    case '\'':
281 +    case '"':
282 +      {
283 +        buffer[position++] = query[query_position++]; // copy current symbol
284 +        while(query_position < query_length)
285 +        {
286 +          if(current == query[query_position]) // found pair quote
287 +          {
288 +            break;
289 +          }
290 +          buffer[position++] = query[query_position++]; // copy current symbol
291 +        }
292 +        break;
293 +      }
294 +    case '/':
295 +      {
296 +        if(((query_position + 2) < query_length) && ('*' == query[query_position+1]) && ('!' != query[query_position+2]))
297 +        {
298 +          query_position += 2; // skip "/*"
299 +          do
300 +          {
301 +            if('*' == query[query_position] && '/' == query[query_position+1]) // check for "*/"
302 +            {
303 +              query_position += 2; // skip "*/"
304 +              insert_space = true;
305 +              break;
306 +            }
307 +            else
308 +            {
309 +              ++query_position;
310 +            }
311 +          }
312 +          while(query_position < query_length);
313 +          if(!insert_space)
314 +          {
315 +            continue;
316 +          }
317 +        }
318 +        break;
319 +      }
320 +    case '-':
321 +      {
322 +        if(query[query_position+1] == '-')
323 +        {
324 +          ++query_position; // skip "-", and go to search of "\n"
325 +        }
326 +        else
327 +        {
328 +          break;
329 +        }
330 +      }
331 +    case '#':
332 +      {
333 +        do
334 +        {
335 +          ++query_position; // skip current symbol (# or -)
336 +          if('\n' == query[query_position])  // check for '\n'
337 +          {
338 +            ++query_position; // skip '\n'
339 +            insert_space = true;
340 +            break;
341 +          }
342 +        }
343 +        while(query_position < query_length);
344 +        if(insert_space)
345 +        {
346 +          break;
347 +        }
348 +        else
349 +        {
350 +          continue;
351 +        }
352 +      }
353 +    default:
354 +      if(query_strip_comments_is_white_space(current))
355 +      {
356 +        insert_space = true;
357 +        ++query_position;
358 +      }
359 +      break; // make gcc happy
360 +    }
361 +    if(insert_space)
362 +    {
363 +      if((uint) (last_space + 1) != position)
364 +      {
365 +        last_space = position;
366 +        buffer[position++] = ' ';
367 +      }
368 +    }
369 +    else
370 +    {
371 +      buffer[position++] = query[query_position++];
372 +    }
373 +  }
374 +  while((0 < position) && query_strip_comments_is_white_space(buffer[position - 1]))
375 +  {
376 +    --position;
377 +  }
378 +  buffer[position] = 0;
379 +  length = position;
380 +}
381 +void QueryStripComments::cleanup()
382 +{
383 +  if(buffer)
384 +  {
385 +    my_free(buffer,MYF(0));
386 +  }
387 +  buffer        = 0;
388 +  length        = 0;
389 +  buffer_length = 0;
390 +}
391 +QueryStripComments_Backup::QueryStripComments_Backup(THD* a_thd,QueryStripComments* qsc)
392 +{
393 +  if(opt_query_cache_strip_comments)
394 +  {
395 +    thd = a_thd;
396 +    query = thd->query();
397 +    length = thd->query_length();
398 +    qsc->set(query,length,thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE);
399 +    thd->set_query(qsc->query(),qsc->query_length());
400 +  }
401 +  else
402 +  {
403 +    thd = 0;
404 +    query = 0;
405 +    length = 0;
406 +  }
407 +}
408 +QueryStripComments_Backup::~QueryStripComments_Backup()
409 +{
410 +  if(thd)
411 +  {
412 +    thd->set_query(query,length);
413 +  }
414 +}
415  
416  #ifdef EMBEDDED_LIBRARY
417  #include "emb_qcache.h"
418 @@ -437,7 +613,13 @@
419    bool interrupt= FALSE;
420    DBUG_ENTER("Query_cache::try_lock");
421  
422 +  THD *thd = current_thd;
423 +  const char* old_proc_info= thd->proc_info;
424 +  thd_proc_info(thd,"Waiting on query cache mutex");
425    pthread_mutex_lock(&structure_guard_mutex);
426 +  DBUG_EXECUTE_IF("status_wait_query_cache_mutex_sleep", {
427 +      sleep(5);
428 +    });
429    while (1)
430    {
431      if (m_cache_lock_status == Query_cache::UNLOCKED)
432 @@ -485,6 +667,7 @@
433      }
434    }
435    pthread_mutex_unlock(&structure_guard_mutex);
436 +  thd->proc_info = old_proc_info;
437  
438    DBUG_RETURN(interrupt);
439  }
440 @@ -865,11 +1048,14 @@
441    DBUG_EXECUTE_IF("wait_in_query_cache_insert",
442                    debug_wait_for_kill("wait_in_query_cache_insert"); );
443  
444 +  if(query_cache.is_disabled())
445 +    DBUG_VOID_RETURN;
446 +
447    if (query_cache.try_lock())
448      DBUG_VOID_RETURN;
449  
450    Query_cache_block *query_block= (Query_cache_block*)net->query_cache_query;
451 -  if (!query_block)
452 +  if (NULL == query_block)
453    {
454      /*
455        We lost the writer and the currently processed query has been
456 @@ -923,6 +1109,9 @@
457    if (net->query_cache_query == 0)
458      DBUG_VOID_RETURN;
459  
460 +  if(query_cache.is_disabled())
461 +    DBUG_VOID_RETURN;
462 +
463    if (query_cache.try_lock())
464      DBUG_VOID_RETURN;
465  
466 @@ -1056,6 +1245,7 @@
467     query_cache_limit(query_cache_limit_arg),
468     queries_in_cache(0), hits(0), inserts(0), refused(0),
469     total_blocks(0), lowmem_prunes(0),
470 +   m_query_cache_is_disabled(FALSE),
471     min_allocation_unit(ALIGN_SIZE(min_allocation_unit_arg)),
472     min_result_data_size(ALIGN_SIZE(min_result_data_size_arg)),
473     def_query_hash_size(ALIGN_SIZE(def_query_hash_size_arg)),
474 @@ -1237,6 +1427,8 @@
475        unlock();
476        DBUG_VOID_RETURN;
477      }
478 +    QueryStripComments *query_strip_comments = &(thd->query_strip_comments);
479 +    QueryStripComments_Backup backup(thd,query_strip_comments);
480  
481      /* Key is query + database + flag */
482      if (thd->db_length)
483 @@ -1407,6 +1599,9 @@
484    Query_cache_block_table *block_table, *block_table_end;
485    ulong tot_length;
486    Query_cache_query_flags flags;
487 +  QueryStripComments *query_strip_comments = &(thd->query_strip_comments);
488 +  char *sql_backup          = sql;
489 +  uint  query_length_backup = query_length;
490    DBUG_ENTER("Query_cache::send_result_to_client");
491  
492    /*
493 @@ -1416,8 +1611,8 @@
494  
495      See also a note on double-check locking usage above.
496    */
497 -  if (thd->locked_tables || thd->variables.query_cache_type == 0 ||
498 -      query_cache_size == 0)
499 +  if (is_disabled() || thd->locked_tables ||
500 +      thd->variables.query_cache_type == 0 || query_cache_size == 0)
501      goto err;
502  
503    if (!thd->lex->safe_to_cache_query)
504 @@ -1428,6 +1623,87 @@
505  
506    {
507      uint i= 0;
508 +    if(opt_query_cache_strip_comments)
509 +    {
510 +      /* Skip all comments and non-letter symbols */
511 +      uint& query_position = i;
512 +      char* query = sql;
513 +      while(query_position < query_length)
514 +      {
515 +        bool check = false;
516 +        char current = query[query_position];
517 +        switch(current)
518 +        {
519 +        case '/':
520 +          if(((query_position + 2) < query_length) && ('*' == query[query_position+1]) && ('!' != query[query_position+2]))
521 +          {
522 +            query_position += 2; // skip "/*"
523 +            do
524 +            {
525 +              if('*' == query[query_position] && '/' == query[query_position+1]) // check for "*/" (without space)
526 +              {
527 +                query_position += 2; // skip "*/" (without space)
528 +                break;
529 +              }
530 +              else
531 +              {
532 +                ++query_position;
533 +              }
534 +            }
535 +            while(query_position < query_length);
536 +            continue; // analyze current symbol
537 +          }
538 +          break;
539 +        case '-':
540 +          if(query[query_position+1] == '-')
541 +          {
542 +            ++query_position; // skip "-"
543 +          }
544 +          else
545 +          {
546 +            break;
547 +          }
548 +        case '#':
549 +          do
550 +          {
551 +            ++query_position; // skip current symbol
552 +            if('\n' == query[query_position])  // check for '\n'
553 +            {
554 +              ++query_position; // skip '\n'
555 +              break;
556 +            }
557 +          }
558 +          while(query_position < query_length);
559 +          continue; // analyze current symbol
560 +        case '\r':
561 +        case '\n':
562 +        case '\t':
563 +        case ' ':
564 +        case '(':
565 +        case ')':
566 +          break;
567 +        default:
568 +          check = true;
569 +          break; // make gcc happy
570 +        } // switch(current)
571 +        if(check)
572 +        {
573 +          if(query_position + 2 < query_length)
574 +          {
575 +            // cacheable
576 +            break;
577 +          }
578 +          else
579 +          {
580 +            DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
581 +            goto err;
582 +          }
583 +        } // if(check)
584 +        ++query_position;
585 +      } // while(query_position < query_length)
586 +    }
587 +    else // if(opt_query_cache_strip_comments)
588 +    {
589      /*
590        Skip '(' characters in queries like following:
591        (select a from t1) union (select a from t1);
592 @@ -1435,6 +1711,7 @@
593      while (sql[i]=='(')
594        i++;
595  
596 +    } // if(opt_query_cache_strip_comments)    
597      /*
598        Test if the query is a SELECT
599        (pre-space is removed in dispatch_command).
600 @@ -1451,7 +1728,6 @@
601        DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
602        goto err;
603      }
604 -    
605      if (query_length > 20 && has_no_cache_directive(&sql[i+6]))
606      {
607        /*
608 @@ -1483,6 +1759,12 @@
609    DBUG_ASSERT(thd->net.query_cache_query == 0);
610  
611    Query_cache_block *query_block;
612 +  if(opt_query_cache_strip_comments)
613 +  {
614 +    query_strip_comments->set(sql, query_length, thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE);
615 +    sql          = query_strip_comments->query();
616 +    query_length = query_strip_comments->query_length();
617 +  }
618  
619    tot_length= query_length + thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE;
620    if (thd->db_length)
621 @@ -1549,6 +1831,8 @@
622          (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE);
623    query_block = (Query_cache_block *)  hash_search(&queries, (uchar*) sql,
624                                                    tot_length);
625 +  sql          = sql_backup;
626 +  query_length = query_length_backup;
627    /* Quick abort on unlocked data */
628    if (query_block == 0 ||
629        query_block->query()->result() == 0 ||
630 @@ -1729,6 +2013,8 @@
631                              my_bool using_transactions)
632  {
633    DBUG_ENTER("Query_cache::invalidate (table list)");
634 +  if (is_disabled())
635 +    DBUG_VOID_RETURN;
636  
637    using_transactions= using_transactions &&
638      (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN));
639 @@ -1759,6 +2045,9 @@
640  void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used)
641  {
642    DBUG_ENTER("Query_cache::invalidate (changed table list)");
643 +  if (is_disabled())
644 +    DBUG_VOID_RETURN;
645 +
646    THD *thd= current_thd;
647    for (; tables_used; tables_used= tables_used->next)
648    {
649 @@ -1784,8 +2073,11 @@
650  */
651  void Query_cache::invalidate_locked_for_write(TABLE_LIST *tables_used)
652  {
653 -  THD *thd= current_thd;
654    DBUG_ENTER("Query_cache::invalidate_locked_for_write");
655 +  if (is_disabled())
656 +    DBUG_VOID_RETURN;
657 +
658 +  THD *thd= current_thd;
659    for (; tables_used; tables_used= tables_used->next_local)
660    {
661      thd_proc_info(thd, "invalidating query cache entries (table)");
662 @@ -1806,6 +2098,8 @@
663                              my_bool using_transactions)
664  {
665    DBUG_ENTER("Query_cache::invalidate (table)");
666 +  if (is_disabled())
667 +    DBUG_VOID_RETURN;
668    
669    using_transactions= using_transactions &&
670      (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN));
671 @@ -1823,6 +2117,8 @@
672                              my_bool using_transactions)
673  {
674    DBUG_ENTER("Query_cache::invalidate (key)");
675 +  if (is_disabled())
676 +   DBUG_VOID_RETURN;
677  
678    using_transactions= using_transactions &&
679      (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN));
680 @@ -1841,9 +2137,11 @@
681  
682  void Query_cache::invalidate(char *db)
683  {
684 -  bool restart= FALSE;
685 -  DBUG_ENTER("Query_cache::invalidate (db)");
686  
687 +  DBUG_ENTER("Query_cache::invalidate (db)");
688 +  if (is_disabled())
689 +    DBUG_VOID_RETURN;
690 +  bool restart= FALSE;
691    /*
692      Lock the query cache and queue all invalidation attempts to avoid
693      the risk of a race between invalidation, cache inserts and flushes.
694 @@ -1928,6 +2226,9 @@
695  void Query_cache::flush()
696  {
697    DBUG_ENTER("Query_cache::flush");
698 +  if (is_disabled())
699 +    DBUG_VOID_RETURN;
700 +
701    DBUG_EXECUTE_IF("wait_in_query_cache_flush1",
702                    debug_wait_for_kill("wait_in_query_cache_flush1"););
703  
704 @@ -1959,6 +2260,9 @@
705  {
706    DBUG_ENTER("Query_cache::pack");
707  
708 +  if (is_disabled())
709 +    DBUG_VOID_RETURN;
710 +
711    /*
712      If the entire qc is being invalidated we can bail out early
713      instead of waiting for the lock.
714 @@ -2016,6 +2320,15 @@
715    pthread_cond_init(&COND_cache_status_changed, NULL);
716    m_cache_lock_status= Query_cache::UNLOCKED;
717    initialized = 1;
718 +  /*
719 +    If we explicitly turn off query cache from the command line query cache will
720 +    be disabled for the reminder of the server life time. This is because we
721 +    want to avoid locking the QC specific mutex if query cache isn't going to
722 +    be used.
723 +  */
724 +  if (global_system_variables.query_cache_type == 0)
725 +    query_cache.disable_query_cache();
726 +
727    DBUG_VOID_RETURN;
728  }
729  
730 @@ -4719,3 +5032,4 @@
731  #endif /* DBUG_OFF */
732  
733  #endif /*HAVE_QUERY_CACHE*/
734 +
735 --- a/sql/sql_class.h
736 +++ b/sql/sql_class.h
737 @@ -24,7 +24,9 @@
738  
739  #include "log.h"
740  #include "rpl_tblmap.h"
741 -
742 +#ifdef HAVE_QUERY_CACHE
743 +#include "query_strip_comments.h"
744 +#endif // HAVE_QUERY_CACHE
745  /**
746    An interface that is used to take an action when
747    the locking module notices that a table version has changed
748 @@ -672,6 +674,9 @@
749    */
750    LEX_STRING query_string;
751    Server_side_cursor *cursor;
752 +#ifdef HAVE_QUERY_CACHE
753 +  QueryStripComments query_strip_comments; // see sql_cache.cc
754 +#endif //HAVE_QUERY_CACHE
755  
756    inline char *query() { return query_string.str; }
757    inline uint32 query_length() { return query_string.length; }
758 --- /dev/null
759 +++ b/mysql-test/r/query_cache_disabled.result
760 @@ -0,0 +1,14 @@
761 +SHOW GLOBAL VARIABLES LIKE 'query_cache_type';
762 +Variable_name  Value
763 +query_cache_type       OFF
764 +SET GLOBAL query_cache_type=ON;
765 +ERROR HY000: Query cache is disabled; restart the server with query_cache_type=1 to enable it
766 +SET GLOBAL query_cache_type=DEMAND;
767 +ERROR HY000: Query cache is disabled; restart the server with query_cache_type=1 to enable it
768 +SET GLOBAL query_cache_type=OFF;
769 +ERROR HY000: Query cache is disabled; restart the server with query_cache_type=1 to enable it
770 +SET GLOBAL query_cache_size=1024*1024;
771 +SHOW GLOBAL VARIABLES LIKE 'query_cache_size';
772 +Variable_name  Value
773 +query_cache_size       1048576
774 +SET GLOBAL query_cache_size=0;
775 --- /dev/null
776 +++ b/mysql-test/t/query_cache_disabled-master.opt
777 @@ -0,0 +1 @@
778 +--query_cache_type=0
779 --- /dev/null
780 +++ b/mysql-test/t/query_cache_disabled.test
781 @@ -0,0 +1,15 @@
782 +-- source include/have_query_cache.inc
783 +#
784 +# Bug#38551 query cache can still consume [very little] cpu time even when it is off.
785 +#
786 +SHOW GLOBAL VARIABLES LIKE 'query_cache_type';
787 +--error ER_QUERY_CACHE_DISABLED
788 +SET GLOBAL query_cache_type=ON;
789 +--error ER_QUERY_CACHE_DISABLED
790 +SET GLOBAL query_cache_type=DEMAND;
791 +--error ER_QUERY_CACHE_DISABLED
792 +SET GLOBAL query_cache_type=OFF;
793 +SET GLOBAL query_cache_size=1024*1024;
794 +SHOW GLOBAL VARIABLES LIKE 'query_cache_size';
795 +SET GLOBAL query_cache_size=0;
796 +
797 --- a/sql/set_var.h
798 +++ b/sql/set_var.h
799 @@ -521,10 +521,16 @@
800    { chain_sys_var(chain); }
801    bool check(THD *thd, set_var *var)
802    {
803 -    int ret= 0;
804 -    if (check_func)
805 -      ret= (*check_func)(thd, var);
806 -    return ret ? ret : check_enum(thd, var, enum_names);
807 +    /*
808 +      check_enum fails if the character representation supplied was wrong
809 +      or that the integer value was wrong or missing.
810 +    */
811 +    if (check_enum(thd, var, enum_names))
812 +      return TRUE;
813 +    else if ((check_func && (*check_func)(thd, var)))
814 +      return TRUE;
815 +    else
816 +      return FALSE;
817    }
818    bool update(THD *thd, set_var *var);
819    void set_default(THD *thd, enum_var_type type);
820 --- a/sql/share/errmsg.txt
821 +++ b/sql/share/errmsg.txt
822 @@ -6213,3 +6213,8 @@
823  ER_DEBUG_SYNC_HIT_LIMIT
824    eng "debug sync point hit limit reached"
825    ger "Debug Sync Point Hit Limit erreicht"
826 +PADD_QUERY_CACHE_DISABLED 1651
827 +  eng "ER_QUERY_CACHE_DISABLED padding to 1651 error"
828 +ER_QUERY_CACHE_DISABLED
829 +  eng "Query cache is disabled; restart the server with query_cache_type=1 to enable it"
830 +
831 --- a/sql/sql_cache.h
832 +++ b/sql/sql_cache.h
833 @@ -282,8 +282,11 @@
834    enum Cache_lock_status { UNLOCKED, LOCKED_NO_WAIT, LOCKED };
835    Cache_lock_status m_cache_lock_status;
836  
837 +  bool m_query_cache_is_disabled;
838 +
839    void free_query_internal(Query_cache_block *point);
840    void invalidate_table_internal(THD *thd, uchar *key, uint32 key_length);
841 +  void disable_query_cache(void) { m_query_cache_is_disabled= TRUE; }
842  
843  protected:
844    /*
845 @@ -426,6 +429,8 @@
846               uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
847               uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);
848  
849 +  bool is_disabled(void) { return m_query_cache_is_disabled; }
850 +
851    /* initialize cache (mutex) */
852    void init();
853    /* resize query cache (return real query size, 0 if disabled) */
854 --- /dev/null
855 +++ b/mysql-test/include/percona_query_cache_with_comments.inc
856 @@ -0,0 +1,95 @@
857 +--source include/percona_query_cache_with_comments_clear.inc
858 +let $query=/* with comment first */select * from t1;
859 +eval $query;
860 +--source include/percona_query_cache_with_comments_eval.inc
861 +
862 +let $query=# with comment first
863 +select * from t1;
864 +--source include/percona_query_cache_with_comments_eval.inc
865 +
866 +let $query=-- with comment first
867 +select * from t1;
868 +--source include/percona_query_cache_with_comments_eval.inc
869 +
870 +let $query=/* with comment first and "quote" */select * from t1;
871 +--source include/percona_query_cache_with_comments_eval.inc
872 +
873 +let $query=# with comment first and "quote"
874 +select * from t1;
875 +--source include/percona_query_cache_with_comments_eval.inc
876 +
877 +let $query=-- with comment first and "quote" 
878 +select * from t1;
879 +--source include/percona_query_cache_with_comments_eval.inc
880 +
881 +let $query=
882 +    /* with comment and whitespaces first */select * from t1;
883 +--source include/percona_query_cache_with_comments_eval.inc
884 +
885 +let $query= 
886 +    # with comment and whitespaces first
887 +select * from t1;
888 +--source include/percona_query_cache_with_comments_eval.inc
889 +
890 +let $query=
891 +    -- with comment and whitespaces first
892 +select * from t1;
893 +--source include/percona_query_cache_with_comments_eval.inc
894 +
895 +let $internal=* internal comment *;
896 +
897 +let $query=select * /$internal/ from t1;
898 +--source include/percona_query_cache_with_comments_eval.inc
899 +let $query=select */$internal/ from t1;
900 +--source include/percona_query_cache_with_comments_eval.inc
901 +let $query=select */$internal/from t1;
902 +--source include/percona_query_cache_with_comments_eval.inc
903 +
904 +let $internal=* internal comment with "quote" *;
905 +
906 +let $query=select * /$internal/ from t1;
907 +--source include/percona_query_cache_with_comments_eval.inc
908 +let $query=select */$internal/ from t1;
909 +--source include/percona_query_cache_with_comments_eval.inc
910 +let $query=select */$internal/from t1;
911 +--source include/percona_query_cache_with_comments_eval.inc
912 +
913 +let $query=select * from t1
914 +;
915 +--source include/percona_query_cache_with_comments_eval.inc
916 +
917 +let $query=select * from t1 ;
918 +--source include/percona_query_cache_with_comments_eval.inc
919 +
920 +let $query=select * from t1    ;
921 +--source include/percona_query_cache_with_comments_eval.inc
922 +
923 +let $query=select * from t1
924 +/* comment in the end */;
925 +--source include/percona_query_cache_with_comments_eval.inc
926 +
927 +let $query=select * from t1
928 +/* *\/ */;
929 +--source include/percona_query_cache_with_comments_eval.inc
930 +
931 +let $query=select * from t1
932 +/* comment in the end */
933 +;
934 +--source include/percona_query_cache_with_comments_eval.inc
935 +
936 +let $query=select * from t1 #comment in the end;
937 +--source include/percona_query_cache_with_comments_eval.inc
938 +
939 +let $query=select * from t1 #comment in the end
940 +;
941 +--source include/percona_query_cache_with_comments_eval.inc
942 +
943 +let $query=select * from t1 -- comment in the end;
944 +--source include/percona_query_cache_with_comments_eval.inc
945 +
946 +let $query=select * from t1 -- comment in the end
947 +;
948 +--source include/percona_query_cache_with_comments_eval.inc
949 +
950 +let $query=select ' \'  ' from t1;
951 +--source include/percona_query_cache_with_comments_eval.inc
952 --- /dev/null
953 +++ b/mysql-test/include/percona_query_cache_with_comments_begin.inc
954 @@ -0,0 +1,12 @@
955 +-- source include/have_query_cache.inc
956 +
957 +set GLOBAL query_cache_size=1355776;
958 +
959 +--disable_warnings
960 +drop table if exists t1;
961 +--enable_warnings
962 +
963 +create table t1 (a int not null);
964 +insert into t1 values (1),(2),(3);
965 +
966 +--source include/percona_query_cache_with_comments_clear.inc
967 --- /dev/null
968 +++ b/mysql-test/include/percona_query_cache_with_comments_clear.inc
969 @@ -0,0 +1,5 @@
970 +# Reset query cache variables.
971 +flush query cache; # This crashed in some versions
972 +flush query cache; # This crashed in some versions
973 +reset query cache;
974 +flush status;
975 --- /dev/null
976 +++ b/mysql-test/include/percona_query_cache_with_comments_end.inc
977 @@ -0,0 +1,3 @@
978 +DROP TABLE t1;
979 +SET GLOBAL query_cache_size=default;
980 +set global query_cache_strip_comments=OFF;
981 --- /dev/null
982 +++ b/mysql-test/include/percona_query_cache_with_comments_eval.inc
983 @@ -0,0 +1,7 @@
984 +echo -----------------------------------------------------;
985 +echo $query;
986 +echo -----------------------------------------------------;
987 +--source include/percona_query_cache_with_comments_show.inc
988 +eval $query;
989 +eval $query;
990 +--source include/percona_query_cache_with_comments_show.inc
991 --- /dev/null
992 +++ b/mysql-test/include/percona_query_cache_with_comments_show.inc
993 @@ -0,0 +1,8 @@
994 +let $show=show status like "Qcache_queries_in_cache";
995 +eval $show;
996 +let $show=show status like "Qcache_inserts";
997 +eval $show;
998 +let $show=show status like "Qcache_hits";
999 +eval $show;
1000 +
1001 +
1002 --- /dev/null
1003 +++ b/mysql-test/r/percona_query_cache_with_comments.result
1004 @@ -0,0 +1,866 @@
1005 +set global query_cache_strip_comments=ON;
1006 +set GLOBAL query_cache_size=1355776;
1007 +drop table if exists t1;
1008 +create table t1 (a int not null);
1009 +insert into t1 values (1),(2),(3);
1010 +flush query cache;
1011 +flush query cache;
1012 +reset query cache;
1013 +flush status;
1014 +flush query cache;
1015 +flush query cache;
1016 +reset query cache;
1017 +flush status;
1018 +/* with comment first */select * from t1;
1019 +a
1020 +1
1021 +2
1022 +3
1023 +-----------------------------------------------------
1024 +/* with comment first */select * from t1
1025 +-----------------------------------------------------
1026 +show status like "Qcache_queries_in_cache";
1027 +Variable_name  Value
1028 +Qcache_queries_in_cache        1
1029 +show status like "Qcache_inserts";
1030 +Variable_name  Value
1031 +Qcache_inserts 1
1032 +show status like "Qcache_hits";
1033 +Variable_name  Value
1034 +Qcache_hits    0
1035 +/* with comment first */select * from t1;
1036 +a
1037 +1
1038 +2
1039 +3
1040 +/* with comment first */select * from t1;
1041 +a
1042 +1
1043 +2
1044 +3
1045 +show status like "Qcache_queries_in_cache";
1046 +Variable_name  Value
1047 +Qcache_queries_in_cache        1
1048 +show status like "Qcache_inserts";
1049 +Variable_name  Value
1050 +Qcache_inserts 1
1051 +show status like "Qcache_hits";
1052 +Variable_name  Value
1053 +Qcache_hits    2
1054 +-----------------------------------------------------
1055 +# with comment first
1056 +select * from t1
1057 +-----------------------------------------------------
1058 +show status like "Qcache_queries_in_cache";
1059 +Variable_name  Value
1060 +Qcache_queries_in_cache        1
1061 +show status like "Qcache_inserts";
1062 +Variable_name  Value
1063 +Qcache_inserts 1
1064 +show status like "Qcache_hits";
1065 +Variable_name  Value
1066 +Qcache_hits    2
1067 +# with comment first
1068 +select * from t1;
1069 +a
1070 +1
1071 +2
1072 +3
1073 +# with comment first
1074 +select * from t1;
1075 +a
1076 +1
1077 +2
1078 +3
1079 +show status like "Qcache_queries_in_cache";
1080 +Variable_name  Value
1081 +Qcache_queries_in_cache        1
1082 +show status like "Qcache_inserts";
1083 +Variable_name  Value
1084 +Qcache_inserts 1
1085 +show status like "Qcache_hits";
1086 +Variable_name  Value
1087 +Qcache_hits    4
1088 +-----------------------------------------------------
1089 +-- with comment first
1090 +select * from t1
1091 +-----------------------------------------------------
1092 +show status like "Qcache_queries_in_cache";
1093 +Variable_name  Value
1094 +Qcache_queries_in_cache        1
1095 +show status like "Qcache_inserts";
1096 +Variable_name  Value
1097 +Qcache_inserts 1
1098 +show status like "Qcache_hits";
1099 +Variable_name  Value
1100 +Qcache_hits    4
1101 +-- with comment first
1102 +select * from t1;
1103 +a
1104 +1
1105 +2
1106 +3
1107 +-- with comment first
1108 +select * from t1;
1109 +a
1110 +1
1111 +2
1112 +3
1113 +show status like "Qcache_queries_in_cache";
1114 +Variable_name  Value
1115 +Qcache_queries_in_cache        1
1116 +show status like "Qcache_inserts";
1117 +Variable_name  Value
1118 +Qcache_inserts 1
1119 +show status like "Qcache_hits";
1120 +Variable_name  Value
1121 +Qcache_hits    6
1122 +-----------------------------------------------------
1123 +/* with comment first and "quote" */select * from t1
1124 +-----------------------------------------------------
1125 +show status like "Qcache_queries_in_cache";
1126 +Variable_name  Value
1127 +Qcache_queries_in_cache        1
1128 +show status like "Qcache_inserts";
1129 +Variable_name  Value
1130 +Qcache_inserts 1
1131 +show status like "Qcache_hits";
1132 +Variable_name  Value
1133 +Qcache_hits    6
1134 +/* with comment first and "quote" */select * from t1;
1135 +a
1136 +1
1137 +2
1138 +3
1139 +/* with comment first and "quote" */select * from t1;
1140 +a
1141 +1
1142 +2
1143 +3
1144 +show status like "Qcache_queries_in_cache";
1145 +Variable_name  Value
1146 +Qcache_queries_in_cache        1
1147 +show status like "Qcache_inserts";
1148 +Variable_name  Value
1149 +Qcache_inserts 1
1150 +show status like "Qcache_hits";
1151 +Variable_name  Value
1152 +Qcache_hits    8
1153 +-----------------------------------------------------
1154 +# with comment first and "quote"
1155 +select * from t1
1156 +-----------------------------------------------------
1157 +show status like "Qcache_queries_in_cache";
1158 +Variable_name  Value
1159 +Qcache_queries_in_cache        1
1160 +show status like "Qcache_inserts";
1161 +Variable_name  Value
1162 +Qcache_inserts 1
1163 +show status like "Qcache_hits";
1164 +Variable_name  Value
1165 +Qcache_hits    8
1166 +# with comment first and "quote"
1167 +select * from t1;
1168 +a
1169 +1
1170 +2
1171 +3
1172 +# with comment first and "quote"
1173 +select * from t1;
1174 +a
1175 +1
1176 +2
1177 +3
1178 +show status like "Qcache_queries_in_cache";
1179 +Variable_name  Value
1180 +Qcache_queries_in_cache        1
1181 +show status like "Qcache_inserts";
1182 +Variable_name  Value
1183 +Qcache_inserts 1
1184 +show status like "Qcache_hits";
1185 +Variable_name  Value
1186 +Qcache_hits    10
1187 +-----------------------------------------------------
1188 +-- with comment first and "quote" 
1189 +select * from t1
1190 +-----------------------------------------------------
1191 +show status like "Qcache_queries_in_cache";
1192 +Variable_name  Value
1193 +Qcache_queries_in_cache        1
1194 +show status like "Qcache_inserts";
1195 +Variable_name  Value
1196 +Qcache_inserts 1
1197 +show status like "Qcache_hits";
1198 +Variable_name  Value
1199 +Qcache_hits    10
1200 +-- with comment first and "quote" 
1201 +select * from t1;
1202 +a
1203 +1
1204 +2
1205 +3
1206 +-- with comment first and "quote" 
1207 +select * from t1;
1208 +a
1209 +1
1210 +2
1211 +3
1212 +show status like "Qcache_queries_in_cache";
1213 +Variable_name  Value
1214 +Qcache_queries_in_cache        1
1215 +show status like "Qcache_inserts";
1216 +Variable_name  Value
1217 +Qcache_inserts 1
1218 +show status like "Qcache_hits";
1219 +Variable_name  Value
1220 +Qcache_hits    12
1221 +-----------------------------------------------------
1222 +/* with comment and whitespaces first */select * from t1
1223 +-----------------------------------------------------
1224 +show status like "Qcache_queries_in_cache";
1225 +Variable_name  Value
1226 +Qcache_queries_in_cache        1
1227 +show status like "Qcache_inserts";
1228 +Variable_name  Value
1229 +Qcache_inserts 1
1230 +show status like "Qcache_hits";
1231 +Variable_name  Value
1232 +Qcache_hits    12
1233 +/* with comment and whitespaces first */select * from t1;
1234 +a
1235 +1
1236 +2
1237 +3
1238 +/* with comment and whitespaces first */select * from t1;
1239 +a
1240 +1
1241 +2
1242 +3
1243 +show status like "Qcache_queries_in_cache";
1244 +Variable_name  Value
1245 +Qcache_queries_in_cache        1
1246 +show status like "Qcache_inserts";
1247 +Variable_name  Value
1248 +Qcache_inserts 1
1249 +show status like "Qcache_hits";
1250 +Variable_name  Value
1251 +Qcache_hits    14
1252 +-----------------------------------------------------
1253 +# with comment and whitespaces first
1254 +select * from t1
1255 +-----------------------------------------------------
1256 +show status like "Qcache_queries_in_cache";
1257 +Variable_name  Value
1258 +Qcache_queries_in_cache        1
1259 +show status like "Qcache_inserts";
1260 +Variable_name  Value
1261 +Qcache_inserts 1
1262 +show status like "Qcache_hits";
1263 +Variable_name  Value
1264 +Qcache_hits    14
1265 +# with comment and whitespaces first
1266 +select * from t1;
1267 +a
1268 +1
1269 +2
1270 +3
1271 +# with comment and whitespaces first
1272 +select * from t1;
1273 +a
1274 +1
1275 +2
1276 +3
1277 +show status like "Qcache_queries_in_cache";
1278 +Variable_name  Value
1279 +Qcache_queries_in_cache        1
1280 +show status like "Qcache_inserts";
1281 +Variable_name  Value
1282 +Qcache_inserts 1
1283 +show status like "Qcache_hits";
1284 +Variable_name  Value
1285 +Qcache_hits    16
1286 +-----------------------------------------------------
1287 +-- with comment and whitespaces first
1288 +select * from t1
1289 +-----------------------------------------------------
1290 +show status like "Qcache_queries_in_cache";
1291 +Variable_name  Value
1292 +Qcache_queries_in_cache        1
1293 +show status like "Qcache_inserts";
1294 +Variable_name  Value
1295 +Qcache_inserts 1
1296 +show status like "Qcache_hits";
1297 +Variable_name  Value
1298 +Qcache_hits    16
1299 +-- with comment and whitespaces first
1300 +select * from t1;
1301 +a
1302 +1
1303 +2
1304 +3
1305 +-- with comment and whitespaces first
1306 +select * from t1;
1307 +a
1308 +1
1309 +2
1310 +3
1311 +show status like "Qcache_queries_in_cache";
1312 +Variable_name  Value
1313 +Qcache_queries_in_cache        1
1314 +show status like "Qcache_inserts";
1315 +Variable_name  Value
1316 +Qcache_inserts 1
1317 +show status like "Qcache_hits";
1318 +Variable_name  Value
1319 +Qcache_hits    18
1320 +-----------------------------------------------------
1321 +select * /* internal comment */ from t1
1322 +-----------------------------------------------------
1323 +show status like "Qcache_queries_in_cache";
1324 +Variable_name  Value
1325 +Qcache_queries_in_cache        1
1326 +show status like "Qcache_inserts";
1327 +Variable_name  Value
1328 +Qcache_inserts 1
1329 +show status like "Qcache_hits";
1330 +Variable_name  Value
1331 +Qcache_hits    18
1332 +select * /* internal comment */ from t1;
1333 +a
1334 +1
1335 +2
1336 +3
1337 +select * /* internal comment */ from t1;
1338 +a
1339 +1
1340 +2
1341 +3
1342 +show status like "Qcache_queries_in_cache";
1343 +Variable_name  Value
1344 +Qcache_queries_in_cache        1
1345 +show status like "Qcache_inserts";
1346 +Variable_name  Value
1347 +Qcache_inserts 1
1348 +show status like "Qcache_hits";
1349 +Variable_name  Value
1350 +Qcache_hits    20
1351 +-----------------------------------------------------
1352 +select */* internal comment */ from t1
1353 +-----------------------------------------------------
1354 +show status like "Qcache_queries_in_cache";
1355 +Variable_name  Value
1356 +Qcache_queries_in_cache        1
1357 +show status like "Qcache_inserts";
1358 +Variable_name  Value
1359 +Qcache_inserts 1
1360 +show status like "Qcache_hits";
1361 +Variable_name  Value
1362 +Qcache_hits    20
1363 +select */* internal comment */ from t1;
1364 +a
1365 +1
1366 +2
1367 +3
1368 +select */* internal comment */ from t1;
1369 +a
1370 +1
1371 +2
1372 +3
1373 +show status like "Qcache_queries_in_cache";
1374 +Variable_name  Value
1375 +Qcache_queries_in_cache        1
1376 +show status like "Qcache_inserts";
1377 +Variable_name  Value
1378 +Qcache_inserts 1
1379 +show status like "Qcache_hits";
1380 +Variable_name  Value
1381 +Qcache_hits    22
1382 +-----------------------------------------------------
1383 +select */* internal comment */from t1
1384 +-----------------------------------------------------
1385 +show status like "Qcache_queries_in_cache";
1386 +Variable_name  Value
1387 +Qcache_queries_in_cache        1
1388 +show status like "Qcache_inserts";
1389 +Variable_name  Value
1390 +Qcache_inserts 1
1391 +show status like "Qcache_hits";
1392 +Variable_name  Value
1393 +Qcache_hits    22
1394 +select */* internal comment */from t1;
1395 +a
1396 +1
1397 +2
1398 +3
1399 +select */* internal comment */from t1;
1400 +a
1401 +1
1402 +2
1403 +3
1404 +show status like "Qcache_queries_in_cache";
1405 +Variable_name  Value
1406 +Qcache_queries_in_cache        1
1407 +show status like "Qcache_inserts";
1408 +Variable_name  Value
1409 +Qcache_inserts 1
1410 +show status like "Qcache_hits";
1411 +Variable_name  Value
1412 +Qcache_hits    24
1413 +-----------------------------------------------------
1414 +select * /* internal comment with "quote" */ from t1
1415 +-----------------------------------------------------
1416 +show status like "Qcache_queries_in_cache";
1417 +Variable_name  Value
1418 +Qcache_queries_in_cache        1
1419 +show status like "Qcache_inserts";
1420 +Variable_name  Value
1421 +Qcache_inserts 1
1422 +show status like "Qcache_hits";
1423 +Variable_name  Value
1424 +Qcache_hits    24
1425 +select * /* internal comment with "quote" */ from t1;
1426 +a
1427 +1
1428 +2
1429 +3
1430 +select * /* internal comment with "quote" */ from t1;
1431 +a
1432 +1
1433 +2
1434 +3
1435 +show status like "Qcache_queries_in_cache";
1436 +Variable_name  Value
1437 +Qcache_queries_in_cache        1
1438 +show status like "Qcache_inserts";
1439 +Variable_name  Value
1440 +Qcache_inserts 1
1441 +show status like "Qcache_hits";
1442 +Variable_name  Value
1443 +Qcache_hits    26
1444 +-----------------------------------------------------
1445 +select */* internal comment with "quote" */ from t1
1446 +-----------------------------------------------------
1447 +show status like "Qcache_queries_in_cache";
1448 +Variable_name  Value
1449 +Qcache_queries_in_cache        1
1450 +show status like "Qcache_inserts";
1451 +Variable_name  Value
1452 +Qcache_inserts 1
1453 +show status like "Qcache_hits";
1454 +Variable_name  Value
1455 +Qcache_hits    26
1456 +select */* internal comment with "quote" */ from t1;
1457 +a
1458 +1
1459 +2
1460 +3
1461 +select */* internal comment with "quote" */ from t1;
1462 +a
1463 +1
1464 +2
1465 +3
1466 +show status like "Qcache_queries_in_cache";
1467 +Variable_name  Value
1468 +Qcache_queries_in_cache        1
1469 +show status like "Qcache_inserts";
1470 +Variable_name  Value
1471 +Qcache_inserts 1
1472 +show status like "Qcache_hits";
1473 +Variable_name  Value
1474 +Qcache_hits    28
1475 +-----------------------------------------------------
1476 +select */* internal comment with "quote" */from t1
1477 +-----------------------------------------------------
1478 +show status like "Qcache_queries_in_cache";
1479 +Variable_name  Value
1480 +Qcache_queries_in_cache        1
1481 +show status like "Qcache_inserts";
1482 +Variable_name  Value
1483 +Qcache_inserts 1
1484 +show status like "Qcache_hits";
1485 +Variable_name  Value
1486 +Qcache_hits    28
1487 +select */* internal comment with "quote" */from t1;
1488 +a
1489 +1
1490 +2
1491 +3
1492 +select */* internal comment with "quote" */from t1;
1493 +a
1494 +1
1495 +2
1496 +3
1497 +show status like "Qcache_queries_in_cache";
1498 +Variable_name  Value
1499 +Qcache_queries_in_cache        1
1500 +show status like "Qcache_inserts";
1501 +Variable_name  Value
1502 +Qcache_inserts 1
1503 +show status like "Qcache_hits";
1504 +Variable_name  Value
1505 +Qcache_hits    30
1506 +-----------------------------------------------------
1507 +select * from t1
1508 +
1509 +-----------------------------------------------------
1510 +show status like "Qcache_queries_in_cache";
1511 +Variable_name  Value
1512 +Qcache_queries_in_cache        1
1513 +show status like "Qcache_inserts";
1514 +Variable_name  Value
1515 +Qcache_inserts 1
1516 +show status like "Qcache_hits";
1517 +Variable_name  Value
1518 +Qcache_hits    30
1519 +select * from t1
1520 +;
1521 +a
1522 +1
1523 +2
1524 +3
1525 +select * from t1
1526 +;
1527 +a
1528 +1
1529 +2
1530 +3
1531 +show status like "Qcache_queries_in_cache";
1532 +Variable_name  Value
1533 +Qcache_queries_in_cache        1
1534 +show status like "Qcache_inserts";
1535 +Variable_name  Value
1536 +Qcache_inserts 1
1537 +show status like "Qcache_hits";
1538 +Variable_name  Value
1539 +Qcache_hits    32
1540 +-----------------------------------------------------
1541 +select * from t1 
1542 +-----------------------------------------------------
1543 +show status like "Qcache_queries_in_cache";
1544 +Variable_name  Value
1545 +Qcache_queries_in_cache        1
1546 +show status like "Qcache_inserts";
1547 +Variable_name  Value
1548 +Qcache_inserts 1
1549 +show status like "Qcache_hits";
1550 +Variable_name  Value
1551 +Qcache_hits    32
1552 +select * from t1 ;
1553 +a
1554 +1
1555 +2
1556 +3
1557 +select * from t1 ;
1558 +a
1559 +1
1560 +2
1561 +3
1562 +show status like "Qcache_queries_in_cache";
1563 +Variable_name  Value
1564 +Qcache_queries_in_cache        1
1565 +show status like "Qcache_inserts";
1566 +Variable_name  Value
1567 +Qcache_inserts 1
1568 +show status like "Qcache_hits";
1569 +Variable_name  Value
1570 +Qcache_hits    34
1571 +-----------------------------------------------------
1572 +select * from t1       
1573 +-----------------------------------------------------
1574 +show status like "Qcache_queries_in_cache";
1575 +Variable_name  Value
1576 +Qcache_queries_in_cache        1
1577 +show status like "Qcache_inserts";
1578 +Variable_name  Value
1579 +Qcache_inserts 1
1580 +show status like "Qcache_hits";
1581 +Variable_name  Value
1582 +Qcache_hits    34
1583 +select * from t1       ;
1584 +a
1585 +1
1586 +2
1587 +3
1588 +select * from t1       ;
1589 +a
1590 +1
1591 +2
1592 +3
1593 +show status like "Qcache_queries_in_cache";
1594 +Variable_name  Value
1595 +Qcache_queries_in_cache        1
1596 +show status like "Qcache_inserts";
1597 +Variable_name  Value
1598 +Qcache_inserts 1
1599 +show status like "Qcache_hits";
1600 +Variable_name  Value
1601 +Qcache_hits    36
1602 +-----------------------------------------------------
1603 +select * from t1
1604 +/* comment in the end */
1605 +-----------------------------------------------------
1606 +show status like "Qcache_queries_in_cache";
1607 +Variable_name  Value
1608 +Qcache_queries_in_cache        1
1609 +show status like "Qcache_inserts";
1610 +Variable_name  Value
1611 +Qcache_inserts 1
1612 +show status like "Qcache_hits";
1613 +Variable_name  Value
1614 +Qcache_hits    36
1615 +select * from t1
1616 +/* comment in the end */;
1617 +a
1618 +1
1619 +2
1620 +3
1621 +select * from t1
1622 +/* comment in the end */;
1623 +a
1624 +1
1625 +2
1626 +3
1627 +show status like "Qcache_queries_in_cache";
1628 +Variable_name  Value
1629 +Qcache_queries_in_cache        1
1630 +show status like "Qcache_inserts";
1631 +Variable_name  Value
1632 +Qcache_inserts 1
1633 +show status like "Qcache_hits";
1634 +Variable_name  Value
1635 +Qcache_hits    38
1636 +-----------------------------------------------------
1637 +select * from t1
1638 +/* *\/ */
1639 +-----------------------------------------------------
1640 +show status like "Qcache_queries_in_cache";
1641 +Variable_name  Value
1642 +Qcache_queries_in_cache        1
1643 +show status like "Qcache_inserts";
1644 +Variable_name  Value
1645 +Qcache_inserts 1
1646 +show status like "Qcache_hits";
1647 +Variable_name  Value
1648 +Qcache_hits    38
1649 +select * from t1
1650 +/* *\/ */;
1651 +a
1652 +1
1653 +2
1654 +3
1655 +select * from t1
1656 +/* *\/ */;
1657 +a
1658 +1
1659 +2
1660 +3
1661 +show status like "Qcache_queries_in_cache";
1662 +Variable_name  Value
1663 +Qcache_queries_in_cache        1
1664 +show status like "Qcache_inserts";
1665 +Variable_name  Value
1666 +Qcache_inserts 1
1667 +show status like "Qcache_hits";
1668 +Variable_name  Value
1669 +Qcache_hits    40
1670 +-----------------------------------------------------
1671 +select * from t1
1672 +/* comment in the end */
1673 +
1674 +-----------------------------------------------------
1675 +show status like "Qcache_queries_in_cache";
1676 +Variable_name  Value
1677 +Qcache_queries_in_cache        1
1678 +show status like "Qcache_inserts";
1679 +Variable_name  Value
1680 +Qcache_inserts 1
1681 +show status like "Qcache_hits";
1682 +Variable_name  Value
1683 +Qcache_hits    40
1684 +select * from t1
1685 +/* comment in the end */
1686 +;
1687 +a
1688 +1
1689 +2
1690 +3
1691 +select * from t1
1692 +/* comment in the end */
1693 +;
1694 +a
1695 +1
1696 +2
1697 +3
1698 +show status like "Qcache_queries_in_cache";
1699 +Variable_name  Value
1700 +Qcache_queries_in_cache        1
1701 +show status like "Qcache_inserts";
1702 +Variable_name  Value
1703 +Qcache_inserts 1
1704 +show status like "Qcache_hits";
1705 +Variable_name  Value
1706 +Qcache_hits    42
1707 +-----------------------------------------------------
1708 +select * from t1 #comment in the end
1709 +-----------------------------------------------------
1710 +show status like "Qcache_queries_in_cache";
1711 +Variable_name  Value
1712 +Qcache_queries_in_cache        1
1713 +show status like "Qcache_inserts";
1714 +Variable_name  Value
1715 +Qcache_inserts 1
1716 +show status like "Qcache_hits";
1717 +Variable_name  Value
1718 +Qcache_hits    42
1719 +select * from t1 #comment in the end;
1720 +a
1721 +1
1722 +2
1723 +3
1724 +select * from t1 #comment in the end;
1725 +a
1726 +1
1727 +2
1728 +3
1729 +show status like "Qcache_queries_in_cache";
1730 +Variable_name  Value
1731 +Qcache_queries_in_cache        1
1732 +show status like "Qcache_inserts";
1733 +Variable_name  Value
1734 +Qcache_inserts 1
1735 +show status like "Qcache_hits";
1736 +Variable_name  Value
1737 +Qcache_hits    44
1738 +-----------------------------------------------------
1739 +select * from t1 #comment in the end
1740 +
1741 +-----------------------------------------------------
1742 +show status like "Qcache_queries_in_cache";
1743 +Variable_name  Value
1744 +Qcache_queries_in_cache        1
1745 +show status like "Qcache_inserts";
1746 +Variable_name  Value
1747 +Qcache_inserts 1
1748 +show status like "Qcache_hits";
1749 +Variable_name  Value
1750 +Qcache_hits    44
1751 +select * from t1 #comment in the end
1752 +;
1753 +a
1754 +1
1755 +2
1756 +3
1757 +select * from t1 #comment in the end
1758 +;
1759 +a
1760 +1
1761 +2
1762 +3
1763 +show status like "Qcache_queries_in_cache";
1764 +Variable_name  Value
1765 +Qcache_queries_in_cache        1
1766 +show status like "Qcache_inserts";
1767 +Variable_name  Value
1768 +Qcache_inserts 1
1769 +show status like "Qcache_hits";
1770 +Variable_name  Value
1771 +Qcache_hits    46
1772 +-----------------------------------------------------
1773 +select * from t1 -- comment in the end
1774 +-----------------------------------------------------
1775 +show status like "Qcache_queries_in_cache";
1776 +Variable_name  Value
1777 +Qcache_queries_in_cache        1
1778 +show status like "Qcache_inserts";
1779 +Variable_name  Value
1780 +Qcache_inserts 1
1781 +show status like "Qcache_hits";
1782 +Variable_name  Value
1783 +Qcache_hits    46
1784 +select * from t1 -- comment in the end;
1785 +a
1786 +1
1787 +2
1788 +3
1789 +select * from t1 -- comment in the end;
1790 +a
1791 +1
1792 +2
1793 +3
1794 +show status like "Qcache_queries_in_cache";
1795 +Variable_name  Value
1796 +Qcache_queries_in_cache        1
1797 +show status like "Qcache_inserts";
1798 +Variable_name  Value
1799 +Qcache_inserts 1
1800 +show status like "Qcache_hits";
1801 +Variable_name  Value
1802 +Qcache_hits    48
1803 +-----------------------------------------------------
1804 +select * from t1 -- comment in the end
1805 +
1806 +-----------------------------------------------------
1807 +show status like "Qcache_queries_in_cache";
1808 +Variable_name  Value
1809 +Qcache_queries_in_cache        1
1810 +show status like "Qcache_inserts";
1811 +Variable_name  Value
1812 +Qcache_inserts 1
1813 +show status like "Qcache_hits";
1814 +Variable_name  Value
1815 +Qcache_hits    48
1816 +select * from t1 -- comment in the end
1817 +;
1818 +a
1819 +1
1820 +2
1821 +3
1822 +select * from t1 -- comment in the end
1823 +;
1824 +a
1825 +1
1826 +2
1827 +3
1828 +show status like "Qcache_queries_in_cache";
1829 +Variable_name  Value
1830 +Qcache_queries_in_cache        1
1831 +show status like "Qcache_inserts";
1832 +Variable_name  Value
1833 +Qcache_inserts 1
1834 +show status like "Qcache_hits";
1835 +Variable_name  Value
1836 +Qcache_hits    50
1837 +-----------------------------------------------------
1838 +select ' \'  ' from t1
1839 +-----------------------------------------------------
1840 +show status like "Qcache_queries_in_cache";
1841 +Variable_name  Value
1842 +Qcache_queries_in_cache        1
1843 +show status like "Qcache_inserts";
1844 +Variable_name  Value
1845 +Qcache_inserts 1
1846 +show status like "Qcache_hits";
1847 +Variable_name  Value
1848 +Qcache_hits    50
1849 +select ' \'  ' from t1;
1850 +'  
1851 + '  
1852 + '  
1853 + '  
1854 +select ' \'  ' from t1;
1855 +'  
1856 + '  
1857 + '  
1858 + '  
1859 +show status like "Qcache_queries_in_cache";
1860 +Variable_name  Value
1861 +Qcache_queries_in_cache        2
1862 +show status like "Qcache_inserts";
1863 +Variable_name  Value
1864 +Qcache_inserts 2
1865 +show status like "Qcache_hits";
1866 +Variable_name  Value
1867 +Qcache_hits    51
1868 +DROP TABLE t1;
1869 +SET GLOBAL query_cache_size=default;
1870 +set global query_cache_strip_comments=OFF;
1871 --- /dev/null
1872 +++ b/mysql-test/r/percona_query_cache_with_comments_crash.result
1873 @@ -0,0 +1,21 @@
1874 +set GLOBAL query_cache_size=1355776;
1875 +drop table if exists t1;
1876 +create table t1 (a int not null);
1877 +insert into t1 values (1),(2),(3);
1878 +flush query cache;
1879 +flush query cache;
1880 +reset query cache;
1881 +flush status;
1882 +( select * from t1 );
1883 +a
1884 +1
1885 +2
1886 +3
1887 +/*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, @@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), @OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, @@SQL_QUOTE_SHOW_CREATE := 1 */;
1888 +/* only comment */;
1889 +# only comment
1890 +;
1891 +-- only comment
1892 +;
1893 +DROP TABLE t1;
1894 +SET GLOBAL query_cache_size= default;
1895 --- /dev/null
1896 +++ b/mysql-test/r/percona_query_cache_with_comments_disable.result
1897 @@ -0,0 +1,865 @@
1898 +set GLOBAL query_cache_size=1355776;
1899 +drop table if exists t1;
1900 +create table t1 (a int not null);
1901 +insert into t1 values (1),(2),(3);
1902 +flush query cache;
1903 +flush query cache;
1904 +reset query cache;
1905 +flush status;
1906 +flush query cache;
1907 +flush query cache;
1908 +reset query cache;
1909 +flush status;
1910 +/* with comment first */select * from t1;
1911 +a
1912 +1
1913 +2
1914 +3
1915 +-----------------------------------------------------
1916 +/* with comment first */select * from t1
1917 +-----------------------------------------------------
1918 +show status like "Qcache_queries_in_cache";
1919 +Variable_name  Value
1920 +Qcache_queries_in_cache        1
1921 +show status like "Qcache_inserts";
1922 +Variable_name  Value
1923 +Qcache_inserts 1
1924 +show status like "Qcache_hits";
1925 +Variable_name  Value
1926 +Qcache_hits    0
1927 +/* with comment first */select * from t1;
1928 +a
1929 +1
1930 +2
1931 +3
1932 +/* with comment first */select * from t1;
1933 +a
1934 +1
1935 +2
1936 +3
1937 +show status like "Qcache_queries_in_cache";
1938 +Variable_name  Value
1939 +Qcache_queries_in_cache        1
1940 +show status like "Qcache_inserts";
1941 +Variable_name  Value
1942 +Qcache_inserts 1
1943 +show status like "Qcache_hits";
1944 +Variable_name  Value
1945 +Qcache_hits    2
1946 +-----------------------------------------------------
1947 +# with comment first
1948 +select * from t1
1949 +-----------------------------------------------------
1950 +show status like "Qcache_queries_in_cache";
1951 +Variable_name  Value
1952 +Qcache_queries_in_cache        1
1953 +show status like "Qcache_inserts";
1954 +Variable_name  Value
1955 +Qcache_inserts 1
1956 +show status like "Qcache_hits";
1957 +Variable_name  Value
1958 +Qcache_hits    2
1959 +# with comment first
1960 +select * from t1;
1961 +a
1962 +1
1963 +2
1964 +3
1965 +# with comment first
1966 +select * from t1;
1967 +a
1968 +1
1969 +2
1970 +3
1971 +show status like "Qcache_queries_in_cache";
1972 +Variable_name  Value
1973 +Qcache_queries_in_cache        2
1974 +show status like "Qcache_inserts";
1975 +Variable_name  Value
1976 +Qcache_inserts 2
1977 +show status like "Qcache_hits";
1978 +Variable_name  Value
1979 +Qcache_hits    2
1980 +-----------------------------------------------------
1981 +-- with comment first
1982 +select * from t1
1983 +-----------------------------------------------------
1984 +show status like "Qcache_queries_in_cache";
1985 +Variable_name  Value
1986 +Qcache_queries_in_cache        2
1987 +show status like "Qcache_inserts";
1988 +Variable_name  Value
1989 +Qcache_inserts 2
1990 +show status like "Qcache_hits";
1991 +Variable_name  Value
1992 +Qcache_hits    2
1993 +-- with comment first
1994 +select * from t1;
1995 +a
1996 +1
1997 +2
1998 +3
1999 +-- with comment first
2000 +select * from t1;
2001 +a
2002 +1
2003 +2
2004 +3
2005 +show status like "Qcache_queries_in_cache";
2006 +Variable_name  Value
2007 +Qcache_queries_in_cache        3
2008 +show status like "Qcache_inserts";
2009 +Variable_name  Value
2010 +Qcache_inserts 3
2011 +show status like "Qcache_hits";
2012 +Variable_name  Value
2013 +Qcache_hits    2
2014 +-----------------------------------------------------
2015 +/* with comment first and "quote" */select * from t1
2016 +-----------------------------------------------------
2017 +show status like "Qcache_queries_in_cache";
2018 +Variable_name  Value
2019 +Qcache_queries_in_cache        3
2020 +show status like "Qcache_inserts";
2021 +Variable_name  Value
2022 +Qcache_inserts 3
2023 +show status like "Qcache_hits";
2024 +Variable_name  Value
2025 +Qcache_hits    2
2026 +/* with comment first and "quote" */select * from t1;
2027 +a
2028 +1
2029 +2
2030 +3
2031 +/* with comment first and "quote" */select * from t1;
2032 +a
2033 +1
2034 +2
2035 +3
2036 +show status like "Qcache_queries_in_cache";
2037 +Variable_name  Value
2038 +Qcache_queries_in_cache        4
2039 +show status like "Qcache_inserts";
2040 +Variable_name  Value
2041 +Qcache_inserts 4
2042 +show status like "Qcache_hits";
2043 +Variable_name  Value
2044 +Qcache_hits    3
2045 +-----------------------------------------------------
2046 +# with comment first and "quote"
2047 +select * from t1
2048 +-----------------------------------------------------
2049 +show status like "Qcache_queries_in_cache";
2050 +Variable_name  Value
2051 +Qcache_queries_in_cache        4
2052 +show status like "Qcache_inserts";
2053 +Variable_name  Value
2054 +Qcache_inserts 4
2055 +show status like "Qcache_hits";
2056 +Variable_name  Value
2057 +Qcache_hits    3
2058 +# with comment first and "quote"
2059 +select * from t1;
2060 +a
2061 +1
2062 +2
2063 +3
2064 +# with comment first and "quote"
2065 +select * from t1;
2066 +a
2067 +1
2068 +2
2069 +3
2070 +show status like "Qcache_queries_in_cache";
2071 +Variable_name  Value
2072 +Qcache_queries_in_cache        5
2073 +show status like "Qcache_inserts";
2074 +Variable_name  Value
2075 +Qcache_inserts 5
2076 +show status like "Qcache_hits";
2077 +Variable_name  Value
2078 +Qcache_hits    3
2079 +-----------------------------------------------------
2080 +-- with comment first and "quote" 
2081 +select * from t1
2082 +-----------------------------------------------------
2083 +show status like "Qcache_queries_in_cache";
2084 +Variable_name  Value
2085 +Qcache_queries_in_cache        5
2086 +show status like "Qcache_inserts";
2087 +Variable_name  Value
2088 +Qcache_inserts 5
2089 +show status like "Qcache_hits";
2090 +Variable_name  Value
2091 +Qcache_hits    3
2092 +-- with comment first and "quote" 
2093 +select * from t1;
2094 +a
2095 +1
2096 +2
2097 +3
2098 +-- with comment first and "quote" 
2099 +select * from t1;
2100 +a
2101 +1
2102 +2
2103 +3
2104 +show status like "Qcache_queries_in_cache";
2105 +Variable_name  Value
2106 +Qcache_queries_in_cache        6
2107 +show status like "Qcache_inserts";
2108 +Variable_name  Value
2109 +Qcache_inserts 6
2110 +show status like "Qcache_hits";
2111 +Variable_name  Value
2112 +Qcache_hits    3
2113 +-----------------------------------------------------
2114 +/* with comment and whitespaces first */select * from t1
2115 +-----------------------------------------------------
2116 +show status like "Qcache_queries_in_cache";
2117 +Variable_name  Value
2118 +Qcache_queries_in_cache        6
2119 +show status like "Qcache_inserts";
2120 +Variable_name  Value
2121 +Qcache_inserts 6
2122 +show status like "Qcache_hits";
2123 +Variable_name  Value
2124 +Qcache_hits    3
2125 +/* with comment and whitespaces first */select * from t1;
2126 +a
2127 +1
2128 +2
2129 +3
2130 +/* with comment and whitespaces first */select * from t1;
2131 +a
2132 +1
2133 +2
2134 +3
2135 +show status like "Qcache_queries_in_cache";
2136 +Variable_name  Value
2137 +Qcache_queries_in_cache        7
2138 +show status like "Qcache_inserts";
2139 +Variable_name  Value
2140 +Qcache_inserts 7
2141 +show status like "Qcache_hits";
2142 +Variable_name  Value
2143 +Qcache_hits    4
2144 +-----------------------------------------------------
2145 +# with comment and whitespaces first
2146 +select * from t1
2147 +-----------------------------------------------------
2148 +show status like "Qcache_queries_in_cache";
2149 +Variable_name  Value
2150 +Qcache_queries_in_cache        7
2151 +show status like "Qcache_inserts";
2152 +Variable_name  Value
2153 +Qcache_inserts 7
2154 +show status like "Qcache_hits";
2155 +Variable_name  Value
2156 +Qcache_hits    4
2157 +# with comment and whitespaces first
2158 +select * from t1;
2159 +a
2160 +1
2161 +2
2162 +3
2163 +# with comment and whitespaces first
2164 +select * from t1;
2165 +a
2166 +1
2167 +2
2168 +3
2169 +show status like "Qcache_queries_in_cache";
2170 +Variable_name  Value
2171 +Qcache_queries_in_cache        8
2172 +show status like "Qcache_inserts";
2173 +Variable_name  Value
2174 +Qcache_inserts 8
2175 +show status like "Qcache_hits";
2176 +Variable_name  Value
2177 +Qcache_hits    4
2178 +-----------------------------------------------------
2179 +-- with comment and whitespaces first
2180 +select * from t1
2181 +-----------------------------------------------------
2182 +show status like "Qcache_queries_in_cache";
2183 +Variable_name  Value
2184 +Qcache_queries_in_cache        8
2185 +show status like "Qcache_inserts";
2186 +Variable_name  Value
2187 +Qcache_inserts 8
2188 +show status like "Qcache_hits";
2189 +Variable_name  Value
2190 +Qcache_hits    4
2191 +-- with comment and whitespaces first
2192 +select * from t1;
2193 +a
2194 +1
2195 +2
2196 +3
2197 +-- with comment and whitespaces first
2198 +select * from t1;
2199 +a
2200 +1
2201 +2
2202 +3
2203 +show status like "Qcache_queries_in_cache";
2204 +Variable_name  Value
2205 +Qcache_queries_in_cache        9
2206 +show status like "Qcache_inserts";
2207 +Variable_name  Value
2208 +Qcache_inserts 9
2209 +show status like "Qcache_hits";
2210 +Variable_name  Value
2211 +Qcache_hits    4
2212 +-----------------------------------------------------
2213 +select * /* internal comment */ from t1
2214 +-----------------------------------------------------
2215 +show status like "Qcache_queries_in_cache";
2216 +Variable_name  Value
2217 +Qcache_queries_in_cache        9
2218 +show status like "Qcache_inserts";
2219 +Variable_name  Value
2220 +Qcache_inserts 9
2221 +show status like "Qcache_hits";
2222 +Variable_name  Value
2223 +Qcache_hits    4
2224 +select * /* internal comment */ from t1;
2225 +a
2226 +1
2227 +2
2228 +3
2229 +select * /* internal comment */ from t1;
2230 +a
2231 +1
2232 +2
2233 +3
2234 +show status like "Qcache_queries_in_cache";
2235 +Variable_name  Value
2236 +Qcache_queries_in_cache        10
2237 +show status like "Qcache_inserts";
2238 +Variable_name  Value
2239 +Qcache_inserts 10
2240 +show status like "Qcache_hits";
2241 +Variable_name  Value
2242 +Qcache_hits    5
2243 +-----------------------------------------------------
2244 +select */* internal comment */ from t1
2245 +-----------------------------------------------------
2246 +show status like "Qcache_queries_in_cache";
2247 +Variable_name  Value
2248 +Qcache_queries_in_cache        10
2249 +show status like "Qcache_inserts";
2250 +Variable_name  Value
2251 +Qcache_inserts 10
2252 +show status like "Qcache_hits";
2253 +Variable_name  Value
2254 +Qcache_hits    5
2255 +select */* internal comment */ from t1;
2256 +a
2257 +1
2258 +2
2259 +3
2260 +select */* internal comment */ from t1;
2261 +a
2262 +1
2263 +2
2264 +3
2265 +show status like "Qcache_queries_in_cache";
2266 +Variable_name  Value
2267 +Qcache_queries_in_cache        11
2268 +show status like "Qcache_inserts";
2269 +Variable_name  Value
2270 +Qcache_inserts 11
2271 +show status like "Qcache_hits";
2272 +Variable_name  Value
2273 +Qcache_hits    6
2274 +-----------------------------------------------------
2275 +select */* internal comment */from t1
2276 +-----------------------------------------------------
2277 +show status like "Qcache_queries_in_cache";
2278 +Variable_name  Value
2279 +Qcache_queries_in_cache        11
2280 +show status like "Qcache_inserts";
2281 +Variable_name  Value
2282 +Qcache_inserts 11
2283 +show status like "Qcache_hits";
2284 +Variable_name  Value
2285 +Qcache_hits    6
2286 +select */* internal comment */from t1;
2287 +a
2288 +1
2289 +2
2290 +3
2291 +select */* internal comment */from t1;
2292 +a
2293 +1
2294 +2
2295 +3
2296 +show status like "Qcache_queries_in_cache";
2297 +Variable_name  Value
2298 +Qcache_queries_in_cache        12
2299 +show status like "Qcache_inserts";
2300 +Variable_name  Value
2301 +Qcache_inserts 12
2302 +show status like "Qcache_hits";
2303 +Variable_name  Value
2304 +Qcache_hits    7
2305 +-----------------------------------------------------
2306 +select * /* internal comment with "quote" */ from t1
2307 +-----------------------------------------------------
2308 +show status like "Qcache_queries_in_cache";
2309 +Variable_name  Value
2310 +Qcache_queries_in_cache        12
2311 +show status like "Qcache_inserts";
2312 +Variable_name  Value
2313 +Qcache_inserts 12
2314 +show status like "Qcache_hits";
2315 +Variable_name  Value
2316 +Qcache_hits    7
2317 +select * /* internal comment with "quote" */ from t1;
2318 +a
2319 +1
2320 +2
2321 +3
2322 +select * /* internal comment with "quote" */ from t1;
2323 +a
2324 +1
2325 +2
2326 +3
2327 +show status like "Qcache_queries_in_cache";
2328 +Variable_name  Value
2329 +Qcache_queries_in_cache        13
2330 +show status like "Qcache_inserts";
2331 +Variable_name  Value
2332 +Qcache_inserts 13
2333 +show status like "Qcache_hits";
2334 +Variable_name  Value
2335 +Qcache_hits    8
2336 +-----------------------------------------------------
2337 +select */* internal comment with "quote" */ from t1
2338 +-----------------------------------------------------
2339 +show status like "Qcache_queries_in_cache";
2340 +Variable_name  Value
2341 +Qcache_queries_in_cache        13
2342 +show status like "Qcache_inserts";
2343 +Variable_name  Value
2344 +Qcache_inserts 13
2345 +show status like "Qcache_hits";
2346 +Variable_name  Value
2347 +Qcache_hits    8
2348 +select */* internal comment with "quote" */ from t1;
2349 +a
2350 +1
2351 +2
2352 +3
2353 +select */* internal comment with "quote" */ from t1;
2354 +a
2355 +1
2356 +2
2357 +3
2358 +show status like "Qcache_queries_in_cache";
2359 +Variable_name  Value
2360 +Qcache_queries_in_cache        14
2361 +show status like "Qcache_inserts";
2362 +Variable_name  Value
2363 +Qcache_inserts 14
2364 +show status like "Qcache_hits";
2365 +Variable_name  Value
2366 +Qcache_hits    9
2367 +-----------------------------------------------------
2368 +select */* internal comment with "quote" */from t1
2369 +-----------------------------------------------------
2370 +show status like "Qcache_queries_in_cache";
2371 +Variable_name  Value
2372 +Qcache_queries_in_cache        14
2373 +show status like "Qcache_inserts";
2374 +Variable_name  Value
2375 +Qcache_inserts 14
2376 +show status like "Qcache_hits";
2377 +Variable_name  Value
2378 +Qcache_hits    9
2379 +select */* internal comment with "quote" */from t1;
2380 +a
2381 +1
2382 +2
2383 +3
2384 +select */* internal comment with "quote" */from t1;
2385 +a
2386 +1
2387 +2
2388 +3
2389 +show status like "Qcache_queries_in_cache";
2390 +Variable_name  Value
2391 +Qcache_queries_in_cache        15
2392 +show status like "Qcache_inserts";
2393 +Variable_name  Value
2394 +Qcache_inserts 15
2395 +show status like "Qcache_hits";
2396 +Variable_name  Value
2397 +Qcache_hits    10
2398 +-----------------------------------------------------
2399 +select * from t1
2400 +
2401 +-----------------------------------------------------
2402 +show status like "Qcache_queries_in_cache";
2403 +Variable_name  Value
2404 +Qcache_queries_in_cache        15
2405 +show status like "Qcache_inserts";
2406 +Variable_name  Value
2407 +Qcache_inserts 15
2408 +show status like "Qcache_hits";
2409 +Variable_name  Value
2410 +Qcache_hits    10
2411 +select * from t1
2412 +;
2413 +a
2414 +1
2415 +2
2416 +3
2417 +select * from t1
2418 +;
2419 +a
2420 +1
2421 +2
2422 +3
2423 +show status like "Qcache_queries_in_cache";
2424 +Variable_name  Value
2425 +Qcache_queries_in_cache        16
2426 +show status like "Qcache_inserts";
2427 +Variable_name  Value
2428 +Qcache_inserts 16
2429 +show status like "Qcache_hits";
2430 +Variable_name  Value
2431 +Qcache_hits    11
2432 +-----------------------------------------------------
2433 +select * from t1 
2434 +-----------------------------------------------------
2435 +show status like "Qcache_queries_in_cache";
2436 +Variable_name  Value
2437 +Qcache_queries_in_cache        16
2438 +show status like "Qcache_inserts";
2439 +Variable_name  Value
2440 +Qcache_inserts 16
2441 +show status like "Qcache_hits";
2442 +Variable_name  Value
2443 +Qcache_hits    11
2444 +select * from t1 ;
2445 +a
2446 +1
2447 +2
2448 +3
2449 +select * from t1 ;
2450 +a
2451 +1
2452 +2
2453 +3
2454 +show status like "Qcache_queries_in_cache";
2455 +Variable_name  Value
2456 +Qcache_queries_in_cache        16
2457 +show status like "Qcache_inserts";
2458 +Variable_name  Value
2459 +Qcache_inserts 16
2460 +show status like "Qcache_hits";
2461 +Variable_name  Value
2462 +Qcache_hits    13
2463 +-----------------------------------------------------
2464 +select * from t1       
2465 +-----------------------------------------------------
2466 +show status like "Qcache_queries_in_cache";
2467 +Variable_name  Value
2468 +Qcache_queries_in_cache        16
2469 +show status like "Qcache_inserts";
2470 +Variable_name  Value
2471 +Qcache_inserts 16
2472 +show status like "Qcache_hits";
2473 +Variable_name  Value
2474 +Qcache_hits    13
2475 +select * from t1       ;
2476 +a
2477 +1
2478 +2
2479 +3
2480 +select * from t1       ;
2481 +a
2482 +1
2483 +2
2484 +3
2485 +show status like "Qcache_queries_in_cache";
2486 +Variable_name  Value
2487 +Qcache_queries_in_cache        16
2488 +show status like "Qcache_inserts";
2489 +Variable_name  Value
2490 +Qcache_inserts 16
2491 +show status like "Qcache_hits";
2492 +Variable_name  Value
2493 +Qcache_hits    15
2494 +-----------------------------------------------------
2495 +select * from t1
2496 +/* comment in the end */
2497 +-----------------------------------------------------
2498 +show status like "Qcache_queries_in_cache";
2499 +Variable_name  Value
2500 +Qcache_queries_in_cache        16
2501 +show status like "Qcache_inserts";
2502 +Variable_name  Value
2503 +Qcache_inserts 16
2504 +show status like "Qcache_hits";
2505 +Variable_name  Value
2506 +Qcache_hits    15
2507 +select * from t1
2508 +/* comment in the end */;
2509 +a
2510 +1
2511 +2
2512 +3
2513 +select * from t1
2514 +/* comment in the end */;
2515 +a
2516 +1
2517 +2
2518 +3
2519 +show status like "Qcache_queries_in_cache";
2520 +Variable_name  Value
2521 +Qcache_queries_in_cache        17
2522 +show status like "Qcache_inserts";
2523 +Variable_name  Value
2524 +Qcache_inserts 17
2525 +show status like "Qcache_hits";
2526 +Variable_name  Value
2527 +Qcache_hits    16
2528 +-----------------------------------------------------
2529 +select * from t1
2530 +/* *\/ */
2531 +-----------------------------------------------------
2532 +show status like "Qcache_queries_in_cache";
2533 +Variable_name  Value
2534 +Qcache_queries_in_cache        17
2535 +show status like "Qcache_inserts";
2536 +Variable_name  Value
2537 +Qcache_inserts 17
2538 +show status like "Qcache_hits";
2539 +Variable_name  Value
2540 +Qcache_hits    16
2541 +select * from t1
2542 +/* *\/ */;
2543 +a
2544 +1
2545 +2
2546 +3
2547 +select * from t1
2548 +/* *\/ */;
2549 +a
2550 +1
2551 +2
2552 +3
2553 +show status like "Qcache_queries_in_cache";
2554 +Variable_name  Value
2555 +Qcache_queries_in_cache        18
2556 +show status like "Qcache_inserts";
2557 +Variable_name  Value
2558 +Qcache_inserts 18
2559 +show status like "Qcache_hits";
2560 +Variable_name  Value
2561 +Qcache_hits    17
2562 +-----------------------------------------------------
2563 +select * from t1
2564 +/* comment in the end */
2565 +
2566 +-----------------------------------------------------
2567 +show status like "Qcache_queries_in_cache";
2568 +Variable_name  Value
2569 +Qcache_queries_in_cache        18
2570 +show status like "Qcache_inserts";
2571 +Variable_name  Value
2572 +Qcache_inserts 18
2573 +show status like "Qcache_hits";
2574 +Variable_name  Value
2575 +Qcache_hits    17
2576 +select * from t1
2577 +/* comment in the end */
2578 +;
2579 +a
2580 +1
2581 +2
2582 +3
2583 +select * from t1
2584 +/* comment in the end */
2585 +;
2586 +a
2587 +1
2588 +2
2589 +3
2590 +show status like "Qcache_queries_in_cache";
2591 +Variable_name  Value
2592 +Qcache_queries_in_cache        18
2593 +show status like "Qcache_inserts";
2594 +Variable_name  Value
2595 +Qcache_inserts 18
2596 +show status like "Qcache_hits";
2597 +Variable_name  Value
2598 +Qcache_hits    19
2599 +-----------------------------------------------------
2600 +select * from t1 #comment in the end
2601 +-----------------------------------------------------
2602 +show status like "Qcache_queries_in_cache";
2603 +Variable_name  Value
2604 +Qcache_queries_in_cache        18
2605 +show status like "Qcache_inserts";
2606 +Variable_name  Value
2607 +Qcache_inserts 18
2608 +show status like "Qcache_hits";
2609 +Variable_name  Value
2610 +Qcache_hits    19
2611 +select * from t1 #comment in the end;
2612 +a
2613 +1
2614 +2
2615 +3
2616 +select * from t1 #comment in the end;
2617 +a
2618 +1
2619 +2
2620 +3
2621 +show status like "Qcache_queries_in_cache";
2622 +Variable_name  Value
2623 +Qcache_queries_in_cache        19
2624 +show status like "Qcache_inserts";
2625 +Variable_name  Value
2626 +Qcache_inserts 19
2627 +show status like "Qcache_hits";
2628 +Variable_name  Value
2629 +Qcache_hits    20
2630 +-----------------------------------------------------
2631 +select * from t1 #comment in the end
2632 +
2633 +-----------------------------------------------------
2634 +show status like "Qcache_queries_in_cache";
2635 +Variable_name  Value
2636 +Qcache_queries_in_cache        19
2637 +show status like "Qcache_inserts";
2638 +Variable_name  Value
2639 +Qcache_inserts 19
2640 +show status like "Qcache_hits";
2641 +Variable_name  Value
2642 +Qcache_hits    20
2643 +select * from t1 #comment in the end
2644 +;
2645 +a
2646 +1
2647 +2
2648 +3
2649 +select * from t1 #comment in the end
2650 +;
2651 +a
2652 +1
2653 +2
2654 +3
2655 +show status like "Qcache_queries_in_cache";
2656 +Variable_name  Value
2657 +Qcache_queries_in_cache        19
2658 +show status like "Qcache_inserts";
2659 +Variable_name  Value
2660 +Qcache_inserts 19
2661 +show status like "Qcache_hits";
2662 +Variable_name  Value
2663 +Qcache_hits    22
2664 +-----------------------------------------------------
2665 +select * from t1 -- comment in the end
2666 +-----------------------------------------------------
2667 +show status like "Qcache_queries_in_cache";
2668 +Variable_name  Value
2669 +Qcache_queries_in_cache        19
2670 +show status like "Qcache_inserts";
2671 +Variable_name  Value
2672 +Qcache_inserts 19
2673 +show status like "Qcache_hits";
2674 +Variable_name  Value
2675 +Qcache_hits    22
2676 +select * from t1 -- comment in the end;
2677 +a
2678 +1
2679 +2
2680 +3
2681 +select * from t1 -- comment in the end;
2682 +a
2683 +1
2684 +2
2685 +3
2686 +show status like "Qcache_queries_in_cache";
2687 +Variable_name  Value
2688 +Qcache_queries_in_cache        20
2689 +show status like "Qcache_inserts";
2690 +Variable_name  Value
2691 +Qcache_inserts 20
2692 +show status like "Qcache_hits";
2693 +Variable_name  Value
2694 +Qcache_hits    23
2695 +-----------------------------------------------------
2696 +select * from t1 -- comment in the end
2697 +
2698 +-----------------------------------------------------
2699 +show status like "Qcache_queries_in_cache";
2700 +Variable_name  Value
2701 +Qcache_queries_in_cache        20
2702 +show status like "Qcache_inserts";
2703 +Variable_name  Value
2704 +Qcache_inserts 20
2705 +show status like "Qcache_hits";
2706 +Variable_name  Value
2707 +Qcache_hits    23
2708 +select * from t1 -- comment in the end
2709 +;
2710 +a
2711 +1
2712 +2
2713 +3
2714 +select * from t1 -- comment in the end
2715 +;
2716 +a
2717 +1
2718 +2
2719 +3
2720 +show status like "Qcache_queries_in_cache";
2721 +Variable_name  Value
2722 +Qcache_queries_in_cache        20
2723 +show status like "Qcache_inserts";
2724 +Variable_name  Value
2725 +Qcache_inserts 20
2726 +show status like "Qcache_hits";
2727 +Variable_name  Value
2728 +Qcache_hits    25
2729 +-----------------------------------------------------
2730 +select ' \'  ' from t1
2731 +-----------------------------------------------------
2732 +show status like "Qcache_queries_in_cache";
2733 +Variable_name  Value
2734 +Qcache_queries_in_cache        20
2735 +show status like "Qcache_inserts";
2736 +Variable_name  Value
2737 +Qcache_inserts 20
2738 +show status like "Qcache_hits";
2739 +Variable_name  Value
2740 +Qcache_hits    25
2741 +select ' \'  ' from t1;
2742 +'  
2743 + '  
2744 + '  
2745 + '  
2746 +select ' \'  ' from t1;
2747 +'  
2748 + '  
2749 + '  
2750 + '  
2751 +show status like "Qcache_queries_in_cache";
2752 +Variable_name  Value
2753 +Qcache_queries_in_cache        21
2754 +show status like "Qcache_inserts";
2755 +Variable_name  Value
2756 +Qcache_inserts 21
2757 +show status like "Qcache_hits";
2758 +Variable_name  Value
2759 +Qcache_hits    26
2760 +DROP TABLE t1;
2761 +SET GLOBAL query_cache_size=default;
2762 +set global query_cache_strip_comments=OFF;
2763 --- /dev/null
2764 +++ b/mysql-test/r/percona_query_cache_with_comments_prepared_statements.result
2765 @@ -0,0 +1,396 @@
2766 +set GLOBAL query_cache_size=1355776;
2767 +flush query cache;
2768 +flush query cache;
2769 +reset query cache;
2770 +flush status;
2771 +drop table if exists t1;
2772 +create table t1 (a int not null);
2773 +insert into t1 values (1),(2),(3);
2774 +set global query_cache_strip_comments=ON;
2775 +show status like "Qcache_queries_in_cache";
2776 +Variable_name  Value
2777 +Qcache_queries_in_cache        0
2778 +show status like "Qcache_inserts";
2779 +Variable_name  Value
2780 +Qcache_inserts 0
2781 +show status like "Qcache_hits";
2782 +Variable_name  Value
2783 +Qcache_hits    0
2784 +prepare stmt from '/* with comment */ select * from t1';
2785 +execute stmt;
2786 +a
2787 +1
2788 +2
2789 +3
2790 +show status like "Qcache_queries_in_cache";
2791 +Variable_name  Value
2792 +Qcache_queries_in_cache        1
2793 +show status like "Qcache_inserts";
2794 +Variable_name  Value
2795 +Qcache_inserts 1
2796 +show status like "Qcache_hits";
2797 +Variable_name  Value
2798 +Qcache_hits    0
2799 +execute stmt;
2800 +a
2801 +1
2802 +2
2803 +3
2804 +execute stmt;
2805 +a
2806 +1
2807 +2
2808 +3
2809 +execute stmt;
2810 +a
2811 +1
2812 +2
2813 +3
2814 +execute stmt;
2815 +a
2816 +1
2817 +2
2818 +3
2819 +execute stmt;
2820 +a
2821 +1
2822 +2
2823 +3
2824 +show status like "Qcache_queries_in_cache";
2825 +Variable_name  Value
2826 +Qcache_queries_in_cache        1
2827 +show status like "Qcache_inserts";
2828 +Variable_name  Value
2829 +Qcache_inserts 1
2830 +show status like "Qcache_hits";
2831 +Variable_name  Value
2832 +Qcache_hits    5
2833 +prepare stmt from 'select * from t1';
2834 +execute stmt;
2835 +a
2836 +1
2837 +2
2838 +3
2839 +show status like "Qcache_queries_in_cache";
2840 +Variable_name  Value
2841 +Qcache_queries_in_cache        1
2842 +show status like "Qcache_inserts";
2843 +Variable_name  Value
2844 +Qcache_inserts 1
2845 +show status like "Qcache_hits";
2846 +Variable_name  Value
2847 +Qcache_hits    6
2848 +prepare stmt from 'select * /*internal comment*/from t1';
2849 +execute stmt;
2850 +a
2851 +1
2852 +2
2853 +3
2854 +show status like "Qcache_queries_in_cache";
2855 +Variable_name  Value
2856 +Qcache_queries_in_cache        1
2857 +show status like "Qcache_inserts";
2858 +Variable_name  Value
2859 +Qcache_inserts 1
2860 +show status like "Qcache_hits";
2861 +Variable_name  Value
2862 +Qcache_hits    7
2863 +prepare stmt from 'select * /*internal comment*/ from t1';
2864 +execute stmt;
2865 +a
2866 +1
2867 +2
2868 +3
2869 +show status like "Qcache_queries_in_cache";
2870 +Variable_name  Value
2871 +Qcache_queries_in_cache        1
2872 +show status like "Qcache_inserts";
2873 +Variable_name  Value
2874 +Qcache_inserts 1
2875 +show status like "Qcache_hits";
2876 +Variable_name  Value
2877 +Qcache_hits    8
2878 +prepare stmt from 'select * from t1 /* at the end */';
2879 +execute stmt;
2880 +a
2881 +1
2882 +2
2883 +3
2884 +show status like "Qcache_queries_in_cache";
2885 +Variable_name  Value
2886 +Qcache_queries_in_cache        1
2887 +show status like "Qcache_inserts";
2888 +Variable_name  Value
2889 +Qcache_inserts 1
2890 +show status like "Qcache_hits";
2891 +Variable_name  Value
2892 +Qcache_hits    9
2893 +prepare stmt from 'select * from t1 /* with "quote" */';
2894 +execute stmt;
2895 +a
2896 +1
2897 +2
2898 +3
2899 +show status like "Qcache_queries_in_cache";
2900 +Variable_name  Value
2901 +Qcache_queries_in_cache        1
2902 +show status like "Qcache_inserts";
2903 +Variable_name  Value
2904 +Qcache_inserts 1
2905 +show status like "Qcache_hits";
2906 +Variable_name  Value
2907 +Qcache_hits    10
2908 +prepare stmt from 'select * from t1 /* with \'quote\' */';
2909 +execute stmt;
2910 +a
2911 +1
2912 +2
2913 +3
2914 +show status like "Qcache_queries_in_cache";
2915 +Variable_name  Value
2916 +Qcache_queries_in_cache        1
2917 +show status like "Qcache_inserts";
2918 +Variable_name  Value
2919 +Qcache_inserts 1
2920 +show status like "Qcache_hits";
2921 +Variable_name  Value
2922 +Qcache_hits    11
2923 +prepare stmt from 'select * from t1 # 123
2924 +';
2925 +execute stmt;
2926 +a
2927 +1
2928 +2
2929 +3
2930 +show status like "Qcache_queries_in_cache";
2931 +Variable_name  Value
2932 +Qcache_queries_in_cache        1
2933 +show status like "Qcache_inserts";
2934 +Variable_name  Value
2935 +Qcache_inserts 1
2936 +show status like "Qcache_hits";
2937 +Variable_name  Value
2938 +Qcache_hits    12
2939 +prepare stmt from 'select * from t1 # 123 with "quote"
2940 +';
2941 +execute stmt;
2942 +a
2943 +1
2944 +2
2945 +3
2946 +show status like "Qcache_queries_in_cache";
2947 +Variable_name  Value
2948 +Qcache_queries_in_cache        1
2949 +show status like "Qcache_inserts";
2950 +Variable_name  Value
2951 +Qcache_inserts 1
2952 +show status like "Qcache_hits";
2953 +Variable_name  Value
2954 +Qcache_hits    13
2955 +prepare stmt from 'select * from t1 # 123 with \'quote\'
2956 +';
2957 +execute stmt;
2958 +a
2959 +1
2960 +2
2961 +3
2962 +show status like "Qcache_queries_in_cache";
2963 +Variable_name  Value
2964 +Qcache_queries_in_cache        1
2965 +show status like "Qcache_inserts";
2966 +Variable_name  Value
2967 +Qcache_inserts 1
2968 +show status like "Qcache_hits";
2969 +Variable_name  Value
2970 +Qcache_hits    14
2971 +prepare stmt from 'select * from t1
2972 +# 123
2973 +';
2974 +execute stmt;
2975 +a
2976 +1
2977 +2
2978 +3
2979 +show status like "Qcache_queries_in_cache";
2980 +Variable_name  Value
2981 +Qcache_queries_in_cache        1
2982 +show status like "Qcache_inserts";
2983 +Variable_name  Value
2984 +Qcache_inserts 1
2985 +show status like "Qcache_hits";
2986 +Variable_name  Value
2987 +Qcache_hits    15
2988 +prepare stmt from '#456
2989 +select * from t1
2990 +# 123
2991 +';
2992 +execute stmt;
2993 +a
2994 +1
2995 +2
2996 +3
2997 +show status like "Qcache_queries_in_cache";
2998 +Variable_name  Value
2999 +Qcache_queries_in_cache        1
3000 +show status like "Qcache_inserts";
3001 +Variable_name  Value
3002 +Qcache_inserts 1
3003 +show status like "Qcache_hits";
3004 +Variable_name  Value
3005 +Qcache_hits    16
3006 +prepare stmt from 'select * from t1 -- 123
3007 +';
3008 +execute stmt;
3009 +a
3010 +1
3011 +2
3012 +3
3013 +show status like "Qcache_queries_in_cache";
3014 +Variable_name  Value
3015 +Qcache_queries_in_cache        1
3016 +show status like "Qcache_inserts";
3017 +Variable_name  Value
3018 +Qcache_inserts 1
3019 +show status like "Qcache_hits";
3020 +Variable_name  Value
3021 +Qcache_hits    17
3022 +prepare stmt from 'select * from t1
3023 +-- 123
3024 +';
3025 +execute stmt;
3026 +a
3027 +1
3028 +2
3029 +3
3030 +show status like "Qcache_queries_in_cache";
3031 +Variable_name  Value
3032 +Qcache_queries_in_cache        1
3033 +show status like "Qcache_inserts";
3034 +Variable_name  Value
3035 +Qcache_inserts 1
3036 +show status like "Qcache_hits";
3037 +Variable_name  Value
3038 +Qcache_hits    18
3039 +prepare stmt from '-- comment in first
3040 +select * from t1
3041 +# 123
3042 +';
3043 +execute stmt;
3044 +a
3045 +1
3046 +2
3047 +3
3048 +show status like "Qcache_queries_in_cache";
3049 +Variable_name  Value
3050 +Qcache_queries_in_cache        1
3051 +show status like "Qcache_inserts";
3052 +Variable_name  Value
3053 +Qcache_inserts 1
3054 +show status like "Qcache_hits";
3055 +Variable_name  Value
3056 +Qcache_hits    19
3057 +prepare stmt from '(#456(
3058 +select * from t1
3059 +# 123(
3060 +)';
3061 +execute stmt;
3062 +a
3063 +1
3064 +2
3065 +3
3066 +show status like "Qcache_queries_in_cache";
3067 +Variable_name  Value
3068 +Qcache_queries_in_cache        2
3069 +show status like "Qcache_inserts";
3070 +Variable_name  Value
3071 +Qcache_inserts 2
3072 +show status like "Qcache_hits";
3073 +Variable_name  Value
3074 +Qcache_hits    19
3075 +prepare stmt from '/*test*/(-- comment in first(
3076 +select * from t1
3077 +-- 123 asdasd
3078 +/* test */)';
3079 +execute stmt;
3080 +a
3081 +1
3082 +2
3083 +3
3084 +show status like "Qcache_queries_in_cache";
3085 +Variable_name  Value
3086 +Qcache_queries_in_cache        2
3087 +show status like "Qcache_inserts";
3088 +Variable_name  Value
3089 +Qcache_inserts 2
3090 +show status like "Qcache_hits";
3091 +Variable_name  Value
3092 +Qcache_hits    20
3093 +prepare stmt from 'select "test",a from t1';
3094 +execute stmt;
3095 +test   a
3096 +test   1
3097 +test   2
3098 +test   3
3099 +execute stmt;
3100 +test   a
3101 +test   1
3102 +test   2
3103 +test   3
3104 +show status like "Qcache_queries_in_cache";
3105 +Variable_name  Value
3106 +Qcache_queries_in_cache        3
3107 +show status like "Qcache_inserts";
3108 +Variable_name  Value
3109 +Qcache_inserts 3
3110 +show status like "Qcache_hits";
3111 +Variable_name  Value
3112 +Qcache_hits    21
3113 +prepare stmt from 'select "test /* internal \'comment\' */",a from t1';
3114 +execute stmt;
3115 +test /* internal 'comment' */  a
3116 +test /* internal 'comment' */  1
3117 +test /* internal 'comment' */  2
3118 +test /* internal 'comment' */  3
3119 +show status like "Qcache_queries_in_cache";
3120 +Variable_name  Value
3121 +Qcache_queries_in_cache        4
3122 +show status like "Qcache_inserts";
3123 +Variable_name  Value
3124 +Qcache_inserts 4
3125 +show status like "Qcache_hits";
3126 +Variable_name  Value
3127 +Qcache_hits    21
3128 +prepare stmt from 'select "test #internal comment" ,a from t1';
3129 +execute stmt;
3130 +test #internal comment a
3131 +test #internal comment 1
3132 +test #internal comment 2
3133 +test #internal comment 3
3134 +show status like "Qcache_queries_in_cache";
3135 +Variable_name  Value
3136 +Qcache_queries_in_cache        5
3137 +show status like "Qcache_inserts";
3138 +Variable_name  Value
3139 +Qcache_inserts 5
3140 +show status like "Qcache_hits";
3141 +Variable_name  Value
3142 +Qcache_hits    21
3143 +prepare stmt from 'select "test #internal comment" #external comment
3144 +,a from t1';
3145 +execute stmt;
3146 +test #internal comment a
3147 +test #internal comment 1
3148 +test #internal comment 2
3149 +test #internal comment 3
3150 +show status like "Qcache_queries_in_cache";
3151 +Variable_name  Value
3152 +Qcache_queries_in_cache        5
3153 +show status like "Qcache_inserts";
3154 +Variable_name  Value
3155 +Qcache_inserts 5
3156 +show status like "Qcache_hits";
3157 +Variable_name  Value
3158 +Qcache_hits    22
3159 +DROP TABLE t1;
3160 +SET GLOBAL query_cache_size= default;
3161 +set global query_cache_strip_comments=OFF;
3162 --- /dev/null
3163 +++ b/mysql-test/r/percona_status_wait_query_cache_mutex.result
3164 @@ -0,0 +1,27 @@
3165 +set GLOBAL query_cache_size=1355776;
3166 +flush query cache;
3167 +flush query cache;
3168 +reset query cache;
3169 +flush status;
3170 +DROP TABLE IF EXISTS t;
3171 +CREATE TABLE t(id INT, number INT);
3172 +INSERT INTO t VALUES (0,1);
3173 +INSERT INTO t VALUES (1,2);
3174 +INSERT INTO t VALUES (2,3);
3175 +SELECT number from t where id > 0;
3176 +number
3177 +2
3178 +3
3179 +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep";
3180 +SELECT number from t where id > 0;
3181 +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep";
3182 +SELECT number from t where id > 0;
3183 +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep";
3184 +SHOW PROCESSLIST;
3185 +Id     User    Host    db      Command Time    State   Info
3186 +Id     root    localhost       test    Sleep   Time            NULL
3187 +Id     root    localhost       test    Query   Time    Waiting on query cache mutex    SELECT number from t where id > 0
3188 +Id     root    localhost       test    Query   Time    Waiting on query cache mutex    SELECT number from t where id > 0
3189 +Id     root    localhost       test    Query   Time    NULL    SHOW PROCESSLIST
3190 +DROP TABLE t;
3191 +set GLOBAL query_cache_size=0;
3192 --- /dev/null
3193 +++ b/mysql-test/t/percona_query_cache_with_comments.test
3194 @@ -0,0 +1,5 @@
3195 +--disable_ps_protocol
3196 +set global query_cache_strip_comments=ON;
3197 +-- source include/percona_query_cache_with_comments_begin.inc
3198 +-- source include/percona_query_cache_with_comments.inc
3199 +-- source include/percona_query_cache_with_comments_end.inc
3200 --- /dev/null
3201 +++ b/mysql-test/t/percona_query_cache_with_comments_crash.test
3202 @@ -0,0 +1,22 @@
3203 +-- source include/have_query_cache.inc
3204 +set GLOBAL query_cache_size=1355776;
3205 +--disable_warnings
3206 +drop table if exists t1;
3207 +--enable_warnings
3208 +create table t1 (a int not null);
3209 +insert into t1 values (1),(2),(3);
3210 +flush query cache; # This crashed in some versions
3211 +flush query cache; # This crashed in some versions
3212 +reset query cache;
3213 +flush status;
3214 +( select * from t1 );
3215 +/*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, @@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), @OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, @@SQL_QUOTE_SHOW_CREATE := 1 */;
3216 +/* only comment */;
3217 +let query=# only comment
3218 +;
3219 +eval $query;
3220 +let query=-- only comment
3221 +;
3222 +eval $query;
3223 +DROP TABLE t1;
3224 +SET GLOBAL query_cache_size= default;
3225 --- /dev/null
3226 +++ b/mysql-test/t/percona_query_cache_with_comments_disable.test
3227 @@ -0,0 +1,3 @@
3228 +-- source include/percona_query_cache_with_comments_begin.inc
3229 +-- source include/percona_query_cache_with_comments.inc
3230 +-- source include/percona_query_cache_with_comments_end.inc
3231 --- /dev/null
3232 +++ b/mysql-test/t/percona_query_cache_with_comments_prepared_statements.test
3233 @@ -0,0 +1,208 @@
3234 +-- source include/have_query_cache.inc
3235 +
3236 +set GLOBAL query_cache_size=1355776;
3237 +
3238 +# Reset query cache variables.
3239 +flush query cache; # This crashed in some versions
3240 +flush query cache; # This crashed in some versions
3241 +reset query cache;
3242 +flush status;
3243 +--disable_warnings
3244 +drop table if exists t1;
3245 +--enable_warnings
3246 +
3247 +#
3248 +# First simple test
3249 +#
3250 +
3251 +create table t1 (a int not null);
3252 +insert into t1 values (1),(2),(3);
3253 +
3254 +set global query_cache_strip_comments=ON;
3255 +
3256 +show status like "Qcache_queries_in_cache";
3257 +show status like "Qcache_inserts";
3258 +show status like "Qcache_hits";
3259 +
3260 +prepare stmt from '/* with comment */ select * from t1';
3261 +execute stmt;
3262 +
3263 +show status like "Qcache_queries_in_cache";
3264 +show status like "Qcache_inserts";
3265 +show status like "Qcache_hits";
3266 +
3267 +execute stmt;
3268 +execute stmt;
3269 +execute stmt;
3270 +execute stmt;
3271 +execute stmt;
3272 +
3273 +show status like "Qcache_queries_in_cache";
3274 +show status like "Qcache_inserts";
3275 +show status like "Qcache_hits";
3276 +
3277 +prepare stmt from 'select * from t1';
3278 +execute stmt;
3279 +
3280 +show status like "Qcache_queries_in_cache";
3281 +show status like "Qcache_inserts";
3282 +show status like "Qcache_hits";
3283 +
3284 +prepare stmt from 'select * /*internal comment*/from t1';
3285 +execute stmt;
3286 +
3287 +show status like "Qcache_queries_in_cache";
3288 +show status like "Qcache_inserts";
3289 +show status like "Qcache_hits";
3290 +
3291 +prepare stmt from 'select * /*internal comment*/ from t1';
3292 +execute stmt;
3293 +
3294 +show status like "Qcache_queries_in_cache";
3295 +show status like "Qcache_inserts";
3296 +show status like "Qcache_hits";
3297 +
3298 +prepare stmt from 'select * from t1 /* at the end */';
3299 +execute stmt;
3300 +
3301 +show status like "Qcache_queries_in_cache";
3302 +show status like "Qcache_inserts";
3303 +show status like "Qcache_hits";
3304 +
3305 +prepare stmt from 'select * from t1 /* with "quote" */';
3306 +execute stmt;
3307 +
3308 +show status like "Qcache_queries_in_cache";
3309 +show status like "Qcache_inserts";
3310 +show status like "Qcache_hits";
3311 +
3312 +prepare stmt from 'select * from t1 /* with \'quote\' */';
3313 +execute stmt;
3314 +
3315 +show status like "Qcache_queries_in_cache";
3316 +show status like "Qcache_inserts";
3317 +show status like "Qcache_hits";
3318 +
3319 +prepare stmt from 'select * from t1 # 123
3320 +';
3321 +execute stmt;
3322 +
3323 +show status like "Qcache_queries_in_cache";
3324 +show status like "Qcache_inserts";
3325 +show status like "Qcache_hits";
3326 +
3327 +prepare stmt from 'select * from t1 # 123 with "quote"
3328 +';
3329 +execute stmt;
3330 +
3331 +show status like "Qcache_queries_in_cache";
3332 +show status like "Qcache_inserts";
3333 +show status like "Qcache_hits";
3334 +
3335 +prepare stmt from 'select * from t1 # 123 with \'quote\'
3336 +';
3337 +execute stmt;
3338 +
3339 +show status like "Qcache_queries_in_cache";
3340 +show status like "Qcache_inserts";
3341 +show status like "Qcache_hits";
3342 +
3343 +prepare stmt from 'select * from t1
3344 +# 123
3345 +';
3346 +execute stmt;
3347 +
3348 +show status like "Qcache_queries_in_cache";
3349 +show status like "Qcache_inserts";
3350 +show status like "Qcache_hits";
3351 +
3352 +prepare stmt from '#456
3353 +select * from t1
3354 +# 123
3355 +';
3356 +execute stmt;
3357 +
3358 +show status like "Qcache_queries_in_cache";
3359 +show status like "Qcache_inserts";
3360 +show status like "Qcache_hits";
3361 +
3362 +prepare stmt from 'select * from t1 -- 123
3363 +';
3364 +execute stmt;
3365 +
3366 +show status like "Qcache_queries_in_cache";
3367 +show status like "Qcache_inserts";
3368 +show status like "Qcache_hits";
3369 +
3370 +prepare stmt from 'select * from t1
3371 +-- 123
3372 +';
3373 +execute stmt;
3374 +
3375 +show status like "Qcache_queries_in_cache";
3376 +show status like "Qcache_inserts";
3377 +show status like "Qcache_hits";
3378 +
3379 +prepare stmt from '-- comment in first
3380 +select * from t1
3381 +# 123
3382 +';
3383 +execute stmt;
3384 +
3385 +show status like "Qcache_queries_in_cache";
3386 +show status like "Qcache_inserts";
3387 +show status like "Qcache_hits";
3388 +
3389 +prepare stmt from '(#456(
3390 +select * from t1
3391 +# 123(
3392 +)';
3393 +execute stmt;
3394 +
3395 +show status like "Qcache_queries_in_cache";
3396 +show status like "Qcache_inserts";
3397 +show status like "Qcache_hits";
3398 +
3399 +prepare stmt from '/*test*/(-- comment in first(
3400 +select * from t1
3401 +-- 123 asdasd
3402 +/* test */)';
3403 +execute stmt;
3404 +
3405 +show status like "Qcache_queries_in_cache";
3406 +show status like "Qcache_inserts";
3407 +show status like "Qcache_hits";
3408 +
3409 +prepare stmt from 'select "test",a from t1';
3410 +execute stmt;
3411 +execute stmt;
3412 +
3413 +show status like "Qcache_queries_in_cache";
3414 +show status like "Qcache_inserts";
3415 +show status like "Qcache_hits";
3416 +
3417 +prepare stmt from 'select "test /* internal \'comment\' */",a from t1';
3418 +execute stmt;
3419 +
3420 +show status like "Qcache_queries_in_cache";
3421 +show status like "Qcache_inserts";
3422 +show status like "Qcache_hits";
3423 +
3424 +prepare stmt from 'select "test #internal comment" ,a from t1';
3425 +execute stmt;
3426 +
3427 +show status like "Qcache_queries_in_cache";
3428 +show status like "Qcache_inserts";
3429 +show status like "Qcache_hits";
3430 +
3431 +prepare stmt from 'select "test #internal comment" #external comment
3432 +,a from t1';
3433 +execute stmt;
3434 +
3435 +show status like "Qcache_queries_in_cache";
3436 +show status like "Qcache_inserts";
3437 +show status like "Qcache_hits";
3438 +
3439 +DROP TABLE t1;
3440 +SET GLOBAL query_cache_size= default;
3441 +set global query_cache_strip_comments=OFF;
3442 --- /dev/null
3443 +++ b/mysql-test/t/percona_status_wait_query_cache_mutex.test
3444 @@ -0,0 +1,37 @@
3445 +--source include/have_query_cache.inc
3446 +--source include/have_debug.inc
3447 +set GLOBAL query_cache_size=1355776;
3448 +--source include/percona_query_cache_with_comments_clear.inc
3449 +
3450 +-- disable_warnings
3451 +DROP TABLE IF EXISTS t;
3452 +-- enable_warnings
3453 +CREATE TABLE t(id INT, number INT);
3454 +INSERT INTO t VALUES (0,1);
3455 +INSERT INTO t VALUES (1,2);
3456 +INSERT INTO t VALUES (2,3);
3457 +SELECT number from t where id > 0;
3458 +--connect (conn0,localhost,root,,)
3459 +--connect (conn1,localhost,root,,)
3460 +--connect (conn2,localhost,root,,)
3461 +
3462 +--connection conn0
3463 +--error 0, ER_UNKNOWN_SYSTEM_VARIABLE
3464 +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep";
3465 +SEND SELECT number from t where id > 0;
3466 +SLEEP 1.0;
3467 +
3468 +--connection conn1
3469 +--error 0, ER_UNKNOWN_SYSTEM_VARIABLE
3470 +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep";
3471 +SEND SELECT number from t where id > 0;
3472 +SLEEP 1.0;
3473 +
3474 +--connection conn2
3475 +--error 0, ER_UNKNOWN_SYSTEM_VARIABLE
3476 +SET SESSION debug="+d,status_wait_query_cache_mutex_sleep";
3477 +--replace_column 1 Id 6 Time
3478 +SHOW PROCESSLIST;
3479 +
3480 +DROP TABLE t;
3481 +set GLOBAL query_cache_size=0;
This page took 0.327722 seconds and 3 git commands to generate.