]> git.pld-linux.org Git - packages/mysql.git/blob - query_cache_enhance.patch
- add default-storage-engine sample
[packages/mysql.git] / query_cache_enhance.patch
1 # name       : query_cache_enhance.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,15 @@
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 +2010-11 - Ported to 5.5
26 --- a/sql/mysqld.cc
27 +++ b/sql/mysqld.cc
28 @@ -904,6 +904,7 @@
29  #endif
30  #ifdef HAVE_QUERY_CACHE
31  ulong query_cache_min_res_unit= QUERY_CACHE_MIN_RESULT_DATA_SIZE;
32 +my_bool opt_query_cache_strip_comments= FALSE;
33  Query_cache query_cache;
34  #endif
35  #ifdef HAVE_SMEM
36 --- a/sql/mysqld.h
37 +++ b/sql/mysqld.h
38 @@ -91,6 +91,7 @@
39  extern my_bool opt_log, opt_slow_log;
40  extern my_bool opt_backup_history_log;
41  extern my_bool opt_backup_progress_log;
42 +extern my_bool opt_query_cache_strip_comments;
43  extern ulonglong log_output_options;
44  extern ulong log_backup_output_options;
45  extern my_bool opt_log_queries_not_using_indexes;
46 --- a/sql/sql_cache.cc
47 +++ b/sql/sql_cache.cc
48 @@ -344,6 +344,496 @@
49  #include "probes_mysql.h"
50  #include "transaction.h"
51  
52 +
53 +namespace query_comments_parser
54 +{
55 +
56 +
57 +enum Kind
58 +{
59 +  /* 'Empty' symbol - epsilon in classic parsers */
60 +  Empty,
61 +  /*
62 +    Special symbols:
63 +      * exclamation comment: slash-star-exclamation comment-body star-slash
64 +      * single-line and multi-line comments
65 +  */
66 +  Special,
67 +  /* Whitespaces: ' ' \t \r \n */
68 +  WhiteSpace,
69 +  /*
70 +    1) C-style comment (slash-star comment-body star-slash)
71 +    2) signle-line comment:
72 +      * sharp comment (sharp comment-body new-line)
73 +      * minus-minus comment (minus-minus comment-body new-line)
74 +  */
75 +  Comment,
76 +  /* Not a special symbols (this symbols can't be before SELECT ). */
77 +  Another,
78 +  /* Error: not-closed quotes, not-closed C-style comment, end-of-query */
79 +  Error
80 +};
81 +
82 +
83 +/**
84 +  Analyze kind of prefix of input string.
85 +
86 +  @param where pointer to pointer to begin of string. After analyzing input
87 +  string function skip analyzed prefix and return pointer to the next part
88 +  of string in the @param where.
89 +
90 +  @return kind of analyzed prefix.
91 +*/
92 +static Kind analyze(const char **where, const char *const end)
93 +{
94 +  DBUG_ASSERT(where != NULL);
95 +  DBUG_ASSERT(*where != NULL);
96 +  const char*&to= *where;
97 +  /* if empty */
98 +  if (*to == '\0')
99 +  {
100 +    return Empty;
101 +  }
102 +
103 +  /* current symbol */
104 +  char current= *to;
105 +
106 +  switch (current)
107 +  {
108 +  case '\'':
109 +  case '"':
110 +    /* skip quote */
111 +    to++;
112 +    /* search pair */
113 +    while (true)
114 +    {
115 +      /* check for pair of quote */
116 +      if (*to == current)
117 +      {
118 +        /* skip second quote */
119 +        to++;
120 +        /* check for same symbol after second quote */
121 +        if (to < end && *to == current)
122 +        {
123 +          /* same symbol, skip it */
124 +          to++;
125 +          /* check for end-of-line */
126 +          if (to == end)
127 +          {
128 +            /* not found - not closed quote */
129 +            return Error;
130 +          }
131 +          else
132 +          {
133 +            /* continue search of pair */
134 +            continue;
135 +          }
136 +        }
137 +        else
138 +        {
139 +          return Another;
140 +        }
141 +      }
142 +      /* check for escaped symbols */
143 +      if (*to == '\\')
144 +      {
145 +        /* backslash, skip it */
146 +        to++;
147 +      }
148 +      /* check for end-of-line */
149 +      if (to == end)
150 +      {
151 +        /* not found - not closed quote */
152 +        return Error;
153 +      }
154 +      /* skip current symbol */
155 +      to++;
156 +    }
157 +  case '-':
158 +    /* Skip minus */
159 +    to++;
160 +    /* Check for second minus */
161 +    if (*to != '-')
162 +    {
163 +      /* Just minus */
164 +      return Another;
165 +    }
166 +    else
167 +    {
168 +      /*
169 +        Prefix is  minus-minus, next case-branch is processing
170 +        single line comments.
171 +      */
172 +    }
173 +  case '#':
174 +    /*
175 +      This is single-line comment, it started by "#" or "--".
176 +      Skip first symbol.
177 +    */
178 +    to++;
179 +    /* search new-line */
180 +    to= strchr(to, '\n');
181 +    if (NULL == to)
182 +    {
183 +      /* not found, end of the comment is the end of the query */
184 +      to= end;
185 +    }
186 +    else
187 +    {
188 +      /* skip end-of-line */
189 +      to++;
190 +    }
191 +    return Comment;
192 +  case '/':
193 +    /* skip slash */
194 +    to++;
195 +    /* check for star */
196 +    if (*to == '*')
197 +    {
198 +      /* skip star */
199 +      to++;
200 +      /* check for exclamation */
201 +      bool exclamation= (*to == '!');
202 +      /* search star-slash */
203 +      to= strstr(to, "*/");
204 +      if (NULL == to)
205 +      {
206 +        /* not found - not closed comment */
207 +        return Error;
208 +      }
209 +      else
210 +      {
211 +        /* found */
212 +        DBUG_ASSERT(to + 1 < end);
213 +        DBUG_ASSERT(0 == strncmp(to, "*/", 2));
214 +        /* skip star-slash */
215 +        to++;
216 +        to++;
217 +        return (exclamation ? Special : Comment);
218 +      }
219 +    }
220 +    else
221 +    {
222 +      /* just slash */
223 +      return Another;
224 +    }
225 +  case ' ':
226 +  case '\t':
227 +  case '\r':
228 +  case '\n':
229 +    {
230 +      /* skip space */
231 +      to++;
232 +      return WhiteSpace;
233 +    }
234 +  case '\\':
235 +    {
236 +      /* skip backslash */
237 +      to++;
238 +      if (to == end)
239 +      {
240 +        /*
241 +          query complete by backslash
242 +          probable error?
243 +        */
244 +        return Another;
245 +      }
246 +      else
247 +      {
248 +        /* skip after backslash symbol */
249 +        to++;
250 +        return Another;
251 +      }
252 +    }
253 +  case '(':
254 +  case ')':
255 +    {
256 +      /* skip parenthese */
257 +      to++;
258 +      return Special;
259 +    }
260 +  default:
261 +    {
262 +      /* skip symbol */
263 +      to++;
264 +      return Another;
265 +    }
266 +  };
267 +}
268 +
269 +
270 +static bool remove_comments_from_query(const char *const query,
271 +                                       const size_t       query_length,
272 +                                       char       *const result,
273 +                                       size_t            *result_length)
274 +{
275 +  /* pointer to begin of parsed block */
276 +  const char *from=  query;
277 +  const char *to=    query;
278 +  /* pointer to end of the query */
279 +  const char *const end= query + query_length;
280 +  /* pointer to last space */
281 +  const char *space= NULL;
282 +  /* current position in result buffer */
283 +  char *current= result;
284 +  while (true)
285 +  {
286 +    from= to;
287 +    switch (analyze(&to, end))
288 +    {
289 +    case Empty:
290 +      {
291 +        /*
292 +          parse completed
293 +          check for whitespace in the end
294 +        */
295 +        if (current == space)
296 +        {
297 +          /* drop whitespace in the end of query */
298 +          --current;
299 +        }
300 +        /* result is null-terminated string */
301 +        *current= 0;
302 +        /* set result length */
303 +        *result_length= current - result;
304 +        /* all right */
305 +        return true;
306 +      }
307 +    case Comment:
308 +      /* should just insert space instead of comment */
309 +    case WhiteSpace:
310 +      if (space == current || from == query)
311 +      {
312 +        /* previous symbol was space */
313 +      }
314 +      else
315 +      {
316 +        /* insert space to result buffer */
317 +        *current= ' ';
318 +        /* switch after inserted space */
319 +        current++;
320 +      }
321 +      /* remember last-after-space position */
322 +      space= current;
323 +      /* parse again */
324 +      continue;
325 +    case Special:
326 +    case Another:
327 +      {
328 +        /* calculate parsed block size */
329 +        size_t block_size= to - from;
330 +        /* copy parsed block to result */
331 +        memcpy(current, from, block_size);
332 +        /* switch result after copied block */
333 +        current+= block_size;
334 +        /* switch after parsed block */
335 +        from= to;
336 +        /* parse again */
337 +        continue;
338 +      }
339 +    case Error:
340 +    default:
341 +      {
342 +        /* bad source query */
343 +        return false;
344 +      }
345 +    }
346 +  }
347 +}
348 +
349 +
350 +static size_t skip_not_another(const char *const query, size_t query_length)
351 +{
352 +  const char *from= query;
353 +  const char *to=   query;
354 +  const char *const end= query + query_length;
355 +  while (true)
356 +  {
357 +    switch (analyze(&to, end))
358 +    {
359 +    case Error:
360 +      return 0;
361 +    case Empty:
362 +    case Another:
363 +      return (from - query);
364 +    default:
365 +      from= to;
366 +      continue;
367 +    };
368 +  }
369 +}
370 +
371 +
372 +static size_t skip_default(const char *const query, size_t /* query_length */)
373 +{
374 +  size_t query_position= 0;
375 +  /*
376 +    Skip '(' characters in queries like following:
377 +    (select a from t1) union (select a from t1);
378 +  */
379 +  while (query[query_position]=='(')
380 +    query_position++;
381 +  return query_position;
382 +}
383 +
384 +
385 +} /* namespace query_comments_parser */
386 +
387 +class Query_Switcher
388 +{
389 +private:
390 +  Query_Switcher(const Query_Switcher&);
391 +  Query_Switcher& operator=(const Query_Switcher&);
392 +
393 +
394 +public:
395 +  Query_Switcher(THD *thd) :
396 +    target_query(&(thd_query_string(thd)->str)),
397 +    target_length(&(thd_query_string(thd)->length)),
398 +    backup_query(thd->query()),
399 +    backup_length(thd->query_length())
400 +  {
401 +  }
402 +
403 +  Query_Switcher(char   **query,
404 +                 size_t  *length) :
405 +    target_query(query),
406 +    target_length(length),
407 +    backup_query(*query),
408 +    backup_length(*length)
409 +  {
410 +  }
411 +public:
412 +  void replace(Query_Without_Comments *query_without_comments)
413 +  {
414 +    *target_query=  query_without_comments->query();
415 +    *target_length= query_without_comments->length();
416 +  }
417 +  void restore()
418 +  {
419 +    *target_query=  backup_query;
420 +    *target_length= backup_length;
421 +  }
422 +private:
423 +  char*  *target_query;
424 +  size_t *target_length;
425 +public:
426 +  char *const  backup_query;
427 +  size_t const backup_length;
428 +};
429 +
430 +class Comments_Processor
431 +{
432 +private:
433 +  Comments_Processor(const Comments_Processor&);
434 +  Comments_Processor& operator=(const Comments_Processor&);
435 +
436 +
437 +public:
438 +  Comments_Processor(THD *thd) :
439 +    query_switcher        (thd),
440 +    db_length             (thd->db_length),
441 +    query_without_comments(&(thd->query_without_comments)),
442 +    enabled               (opt_query_cache_strip_comments),
443 +    restore               (false)
444 +  {
445 +  }
446 +
447 +
448 +  Comments_Processor(Query_Without_Comments *current_query_without_comments,
449 +                     char                  **query,
450 +                     size_t                 *length,
451 +                     const size_t            current_db_length) :
452 +    query_switcher        (query, length),
453 +    db_length             (current_db_length),
454 +    query_without_comments(current_query_without_comments),
455 +    enabled               (opt_query_cache_strip_comments),
456 +    restore               (false)
457 +  {
458 +  }
459 +
460 +
461 +  ~Comments_Processor()
462 +  {
463 +    restore_comments();
464 +  }
465 +
466 +
467 +  size_t prefix_length()
468 +  {
469 +    using query_comments_parser::skip_not_another;
470 +    using query_comments_parser::skip_default;
471 +    if (enabled)
472 +    {
473 +      return skip_not_another(query_switcher.backup_query,
474 +                              query_switcher.backup_length);
475 +    }
476 +    else
477 +    {
478 +      return skip_default(query_switcher.backup_query,
479 +                          query_switcher.backup_length);
480 +    }
481 +  }
482 +
483 +
484 +  bool remove_comments()
485 +  {
486 +    if (!enabled || restore)
487 +    {
488 +      return true;
489 +    }
490 +    /* Allocate memory for query rewrite */
491 +    if (!query_without_comments->allocate(query_switcher.backup_length,
492 +                                          db_length))
493 +    {
494 +      return false;
495 +    }
496 +    /* Remove comment from query */
497 +    size_t result_length;
498 +    using query_comments_parser::remove_comments_from_query;
499 +    if (!(restore= remove_comments_from_query(query_switcher.backup_query,
500 +                                              query_switcher.backup_length,
501 +                                              query_without_comments->query(),
502 +                                              &result_length)))
503 +    {
504 +      return false;
505 +    }
506 +    query_without_comments->set_length(result_length);
507 +    size_t db_length_from_query=
508 +        *((size_t*)(query_switcher.backup_query +
509 +                    query_switcher.backup_length + 1));
510 +    *((size_t*)(query_without_comments->query() +
511 +                result_length + 1))= db_length_from_query;
512 +    /* Replace original query by striped */
513 +    query_switcher.replace(query_without_comments);
514 +    return restore;
515 +  }
516 +
517 +
518 +  void restore_comments()
519 +  {
520 +    if (enabled && restore)
521 +    {
522 +      /* Replace striped query by original */
523 +      query_switcher.restore();
524 +
525 +      /* Clean query_without_comments */
526 +      query_without_comments->set_length(0);
527 +
528 +      /* Mark as restored */
529 +      restore= false;
530 +    }
531 +  }
532 +private:
533 +  Query_Switcher query_switcher;
534 +private:
535 +  const size_t db_length;
536 +private:
537 +  Query_Without_Comments *query_without_comments;
538 +  bool                    enabled;
539 +  bool                    restore;
540 +};
541 +
542  #ifdef EMBEDDED_LIBRARY
543  #include "emb_qcache.h"
544  #endif
545 @@ -454,7 +944,12 @@
546    Query_cache_wait_state wait_state(thd, __func__, __FILE__, __LINE__);
547    DBUG_ENTER("Query_cache::try_lock");
548  
549 +  const char *old_proc_info= thd->proc_info;
550 +  thd_proc_info(thd,"Waiting on query cache mutex");
551 +  DEBUG_SYNC(thd, "before_query_cache_mutex");
552    mysql_mutex_lock(&structure_guard_mutex);
553 +  DEBUG_SYNC(thd, "after_query_cache_mutex");
554 +  thd->proc_info = old_proc_info;
555    while (1)
556    {
557      if (m_cache_lock_status == Query_cache::UNLOCKED)
558 @@ -1274,6 +1769,8 @@
559        unlock();
560        DBUG_VOID_RETURN;
561      }
562 +    Comments_Processor comments_processor(thd);
563 +    comments_processor.remove_comments();
564  
565      /* Key is query + database + flag */
566      if (thd->db_length)
567 @@ -1440,7 +1937,7 @@
568  */
569  
570  int
571 -Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
572 +Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length_uint)
573  {
574    ulonglong engine_data;
575    Query_cache_query *query;
576 @@ -1452,6 +1949,11 @@
577    ulong tot_length;
578    Query_cache_query_flags flags;
579    DBUG_ENTER("Query_cache::send_result_to_client");
580 +  size_t query_length= query_length_uint;
581 +  Comments_Processor comments_processor(&(thd->query_without_comments),
582 +                                        &sql,
583 +                                        &query_length,
584 +                                        thd->db_length);
585  
586    /*
587      Testing 'query_cache_size' without a lock here is safe: the thing
588 @@ -1471,13 +1973,7 @@
589    }
590  
591    {
592 -    uint i= 0;
593 -    /*
594 -      Skip '(' characters in queries like following:
595 -      (select a from t1) union (select a from t1);
596 -    */
597 -    while (sql[i]=='(')
598 -      i++;
599 +    size_t i= comments_processor.prefix_length();
600  
601      /*
602        Test if the query is a SELECT
603 @@ -1487,10 +1983,11 @@
604        frequently appeared in real life, consequently we can
605        check all such queries, too.
606      */
607 -    if ((my_toupper(system_charset_info, sql[i])     != 'S' ||
608 -         my_toupper(system_charset_info, sql[i + 1]) != 'E' ||
609 -         my_toupper(system_charset_info, sql[i + 2]) != 'L') &&
610 -        sql[i] != '/')
611 +    if (!((i + 2 < query_length) &&
612 +          ((my_toupper(system_charset_info, sql[i])     == 'S' &&
613 +            my_toupper(system_charset_info, sql[i + 1]) == 'E' &&
614 +            my_toupper(system_charset_info, sql[i + 2]) == 'L') ||
615 +           sql[i] == '/')))
616      {
617        DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
618        goto err;
619 @@ -1543,6 +2040,7 @@
620      goto err_unlock;
621  
622    Query_cache_block *query_block;
623 +  comments_processor.remove_comments();
624  
625    tot_length= query_length + 1 + sizeof(size_t) + 
626                thd->db_length + QUERY_CACHE_FLAGS_SIZE;
627 @@ -1611,6 +2109,7 @@
628          (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE);
629    query_block = (Query_cache_block *)  my_hash_search(&queries, (uchar*) sql,
630                                                        tot_length);
631 +  comments_processor.restore_comments();
632    /* Quick abort on unlocked data */
633    if (query_block == 0 ||
634        query_block->query()->result() == 0 ||
635 --- a/sql/sql_class.h
636 +++ b/sql/sql_class.h
637 @@ -1485,6 +1485,74 @@
638  
639  extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
640  
641 +
642 +#ifdef HAVE_QUERY_CACHE
643 +
644 +
645 +/*
646 +  @class Query_Without_Comments
647 +  This class provides way for safety (re)allocation
648 +  a memory for a query without comments.
649 +*/
650 +class Query_Without_Comments
651 +{
652 +private:
653 +  /*
654 +    Denied copy and assigment for object of this class.
655 +  */
656 +  Query_Without_Comments(const Query_Without_Comments&);
657 +  Query_Without_Comments& operator=(const Query_Without_Comments&);
658 +
659 +
660 +public:
661 +  /*
662 +    Constructor is filling fields by zero (no allocation).
663 +  */
664 +  Query_Without_Comments();
665 +
666 +
667 +  /*
668 +    Destructor clean allocated memory
669 +  */
670 +  ~Query_Without_Comments();
671 +public:
672 +
673 +
674 +/*
675 +    (Re)allocate memory for query. Query length after that is 0.
676 +  */
677 +  bool allocate(size_t query_length, size_t db_length);
678 +
679 +
680 +  /*
681 +    Set result query length, when query
682 +    without comments is copied to buffer.
683 +  */
684 +  void set_length(size_t query_length);
685 +
686 +
687 +public:
688 +  /*
689 +    Result query.
690 +  */
691 +  char*  query();
692 +
693 +
694 +  /*
695 +    Result query length
696 +  */
697 +  size_t length();
698 +
699 +
700 +private:
701 +  char* buffer;
702 +  size_t q_length;
703 +  size_t b_length;
704 +};
705 +
706 +
707 +#endif /* HAVE_QUERY_CACHE */
708 +
709  /**
710    @class THD
711    For each client connection we create a separate thread with THD serving as
712 @@ -1542,6 +1610,7 @@
713    struct st_mysql_stmt *current_stmt;
714  #endif
715  #ifdef HAVE_QUERY_CACHE
716 +  Query_Without_Comments query_without_comments;
717    Query_cache_tls query_cache_tls;
718  #endif
719    NET    net;                          // client connection descriptor
720 --- a/sql/sys_vars.cc
721 +++ b/sql/sys_vars.cc
722 @@ -1815,6 +1815,11 @@
723         NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
724         ON_UPDATE(fix_query_cache_size));
725  
726 +static Sys_var_mybool Sys_query_cache_strip_comments(
727 +       "query_cache_strip_comments", "Enable and disable optimisation \"strip comment for query cache\" - optimisation strip all comments from query while search query result in query cache",
728 +       GLOBAL_VAR(opt_query_cache_strip_comments), CMD_LINE(OPT_ARG),
729 +       DEFAULT(FALSE));
730 +
731  static Sys_var_ulong Sys_query_cache_limit(
732         "query_cache_limit",
733         "Don't cache results that are bigger than this",
734 --- /dev/null
735 +++ b/mysql-test/include/percona_query_cache_with_comments.inc
736 @@ -0,0 +1,117 @@
737 +--source include/percona_query_cache_with_comments_clear.inc
738 +let $query=/* with comment first */select * from t1;
739 +eval $query;
740 +--source include/percona_query_cache_with_comments_eval.inc
741 +
742 +let $query=# with comment first
743 +select * from t1;
744 +--source include/percona_query_cache_with_comments_eval.inc
745 +
746 +let $query=-- with comment first
747 +select * from t1;
748 +--source include/percona_query_cache_with_comments_eval.inc
749 +
750 +let $query=/* with comment first and "quote" */select * from t1;
751 +--source include/percona_query_cache_with_comments_eval.inc
752 +
753 +let $query=# with comment first and "quote"
754 +select * from t1;
755 +--source include/percona_query_cache_with_comments_eval.inc
756 +
757 +let $query=-- with comment first and "quote" 
758 +select * from t1;
759 +--source include/percona_query_cache_with_comments_eval.inc
760 +
761 +let $query=
762 +    /* with comment and whitespaces first */select * from t1;
763 +--source include/percona_query_cache_with_comments_eval.inc
764 +
765 +let $query= 
766 +    # with comment and whitespaces first
767 +select * from t1;
768 +--source include/percona_query_cache_with_comments_eval.inc
769 +
770 +let $query=
771 +    -- with comment and whitespaces first
772 +select * from t1;
773 +--source include/percona_query_cache_with_comments_eval.inc
774 +
775 +let $internal=* internal comment *;
776 +
777 +let $query=select * /$internal/ from t1;
778 +--source include/percona_query_cache_with_comments_eval.inc
779 +let $query=select */$internal/ from t1;
780 +--source include/percona_query_cache_with_comments_eval.inc
781 +let $query=select */$internal/from t1;
782 +--source include/percona_query_cache_with_comments_eval.inc
783 +
784 +let $internal=* internal comment with "quote" *;
785 +
786 +let $query=select * /$internal/ from t1;
787 +--source include/percona_query_cache_with_comments_eval.inc
788 +let $query=select */$internal/ from t1;
789 +--source include/percona_query_cache_with_comments_eval.inc
790 +let $query=select */$internal/from t1;
791 +--source include/percona_query_cache_with_comments_eval.inc
792 +
793 +let $query=select * from t1
794 +;
795 +--source include/percona_query_cache_with_comments_eval.inc
796 +
797 +let $query=select * from t1 ;
798 +--source include/percona_query_cache_with_comments_eval.inc
799 +
800 +let $query=select * from t1    ;
801 +--source include/percona_query_cache_with_comments_eval.inc
802 +
803 +let $query=select * from t1
804 +/* comment in the end */;
805 +--source include/percona_query_cache_with_comments_eval.inc
806 +
807 +let $query=select * from t1
808 +/* *\/ */;
809 +--source include/percona_query_cache_with_comments_eval.inc
810 +
811 +let $query=select * from t1
812 +/* comment in the end */
813 +;
814 +--source include/percona_query_cache_with_comments_eval.inc
815 +
816 +let $query=select * from t1 #comment in the end;
817 +--source include/percona_query_cache_with_comments_eval.inc
818 +
819 +let $query=select * from t1 #comment in the end
820 +;
821 +--source include/percona_query_cache_with_comments_eval.inc
822 +
823 +let $query=select * from t1 -- comment in the end;
824 +--source include/percona_query_cache_with_comments_eval.inc
825 +
826 +let $query=select * from t1 -- comment in the end
827 +;
828 +--source include/percona_query_cache_with_comments_eval.inc
829 +
830 +let $query=select */* a comment \*/from t1;
831 +--source include/percona_query_cache_with_comments_eval.inc
832 +
833 +let $query=select *# a comment \\
834 +from t1;
835 +--source include/percona_query_cache_with_comments_eval.inc
836 +
837 +let $query=select *-- a comment \\
838 +from t1;
839 +--source include/percona_query_cache_with_comments_eval.inc
840 +
841 +let $query=select "\\\\"" /* not a comment */" from t1;
842 +--source include/percona_query_cache_with_comments_eval.inc
843 +
844 +let $query=select "\\\\"" /*! not a comment */" from t1;
845 +--source include/percona_query_cache_with_comments_eval.inc
846 +
847 +# following two queries related to bug #856404.
848 +# There are different queries, but opt_query_cache_strip_comments thinks that they are equal.
849 +let $query=select ' \'  ' from t1;
850 +--source include/percona_query_cache_with_comments_eval.inc
851 +
852 +let $query=select ' \' /* comment inside quotes with internal backslash quote */' from t1;
853 +--source include/percona_query_cache_with_comments_eval.inc
854 --- /dev/null
855 +++ b/mysql-test/include/percona_query_cache_with_comments_begin.inc
856 @@ -0,0 +1,12 @@
857 +-- source include/have_query_cache.inc
858 +
859 +set GLOBAL query_cache_size=1355776;
860 +
861 +--disable_warnings
862 +drop table if exists t1;
863 +--enable_warnings
864 +
865 +create table t1 (a int not null);
866 +insert into t1 values (1),(2),(3);
867 +
868 +--source include/percona_query_cache_with_comments_clear.inc
869 --- /dev/null
870 +++ b/mysql-test/include/percona_query_cache_with_comments_clear.inc
871 @@ -0,0 +1,5 @@
872 +# Reset query cache variables.
873 +flush query cache; # This crashed in some versions
874 +flush query cache; # This crashed in some versions
875 +reset query cache;
876 +flush status;
877 --- /dev/null
878 +++ b/mysql-test/include/percona_query_cache_with_comments_end.inc
879 @@ -0,0 +1,3 @@
880 +DROP TABLE t1;
881 +SET GLOBAL query_cache_size=default;
882 +set global query_cache_strip_comments=OFF;
883 --- /dev/null
884 +++ b/mysql-test/include/percona_query_cache_with_comments_eval.inc
885 @@ -0,0 +1,7 @@
886 +echo -----------------------------------------------------;
887 +echo $query;
888 +echo -----------------------------------------------------;
889 +--source include/percona_query_cache_with_comments_show.inc
890 +eval $query;
891 +eval $query;
892 +--source include/percona_query_cache_with_comments_show.inc
893 --- /dev/null
894 +++ b/mysql-test/include/percona_query_cache_with_comments_show.inc
895 @@ -0,0 +1,8 @@
896 +let $show=show status like "Qcache_queries_in_cache";
897 +eval $show;
898 +let $show=show status like "Qcache_inserts";
899 +eval $show;
900 +let $show=show status like "Qcache_hits";
901 +eval $show;
902 +
903 +
904 --- /dev/null
905 +++ b/mysql-test/r/percona_query_cache_with_comments.result
906 @@ -0,0 +1,1058 @@
907 +set global query_cache_strip_comments=ON;
908 +set GLOBAL query_cache_size=1355776;
909 +drop table if exists t1;
910 +create table t1 (a int not null);
911 +insert into t1 values (1),(2),(3);
912 +flush query cache;
913 +flush query cache;
914 +reset query cache;
915 +flush status;
916 +flush query cache;
917 +flush query cache;
918 +reset query cache;
919 +flush status;
920 +/* with comment first */select * from t1;
921 +a
922 +1
923 +2
924 +3
925 +-----------------------------------------------------
926 +/* with comment first */select * from t1
927 +-----------------------------------------------------
928 +show status like "Qcache_queries_in_cache";
929 +Variable_name  Value
930 +Qcache_queries_in_cache        1
931 +show status like "Qcache_inserts";
932 +Variable_name  Value
933 +Qcache_inserts 1
934 +show status like "Qcache_hits";
935 +Variable_name  Value
936 +Qcache_hits    0
937 +/* with comment first */select * from t1;
938 +a
939 +1
940 +2
941 +3
942 +/* with comment first */select * from t1;
943 +a
944 +1
945 +2
946 +3
947 +show status like "Qcache_queries_in_cache";
948 +Variable_name  Value
949 +Qcache_queries_in_cache        1
950 +show status like "Qcache_inserts";
951 +Variable_name  Value
952 +Qcache_inserts 1
953 +show status like "Qcache_hits";
954 +Variable_name  Value
955 +Qcache_hits    2
956 +-----------------------------------------------------
957 +# with comment first
958 +select * from t1
959 +-----------------------------------------------------
960 +show status like "Qcache_queries_in_cache";
961 +Variable_name  Value
962 +Qcache_queries_in_cache        1
963 +show status like "Qcache_inserts";
964 +Variable_name  Value
965 +Qcache_inserts 1
966 +show status like "Qcache_hits";
967 +Variable_name  Value
968 +Qcache_hits    2
969 +# with comment first
970 +select * from t1;
971 +a
972 +1
973 +2
974 +3
975 +# with comment first
976 +select * from t1;
977 +a
978 +1
979 +2
980 +3
981 +show status like "Qcache_queries_in_cache";
982 +Variable_name  Value
983 +Qcache_queries_in_cache        1
984 +show status like "Qcache_inserts";
985 +Variable_name  Value
986 +Qcache_inserts 1
987 +show status like "Qcache_hits";
988 +Variable_name  Value
989 +Qcache_hits    4
990 +-----------------------------------------------------
991 +-- with comment first
992 +select * from t1
993 +-----------------------------------------------------
994 +show status like "Qcache_queries_in_cache";
995 +Variable_name  Value
996 +Qcache_queries_in_cache        1
997 +show status like "Qcache_inserts";
998 +Variable_name  Value
999 +Qcache_inserts 1
1000 +show status like "Qcache_hits";
1001 +Variable_name  Value
1002 +Qcache_hits    4
1003 +-- with comment first
1004 +select * from t1;
1005 +a
1006 +1
1007 +2
1008 +3
1009 +-- with comment first
1010 +select * from t1;
1011 +a
1012 +1
1013 +2
1014 +3
1015 +show status like "Qcache_queries_in_cache";
1016 +Variable_name  Value
1017 +Qcache_queries_in_cache        1
1018 +show status like "Qcache_inserts";
1019 +Variable_name  Value
1020 +Qcache_inserts 1
1021 +show status like "Qcache_hits";
1022 +Variable_name  Value
1023 +Qcache_hits    6
1024 +-----------------------------------------------------
1025 +/* with comment first and "quote" */select * from t1
1026 +-----------------------------------------------------
1027 +show status like "Qcache_queries_in_cache";
1028 +Variable_name  Value
1029 +Qcache_queries_in_cache        1
1030 +show status like "Qcache_inserts";
1031 +Variable_name  Value
1032 +Qcache_inserts 1
1033 +show status like "Qcache_hits";
1034 +Variable_name  Value
1035 +Qcache_hits    6
1036 +/* with comment first and "quote" */select * from t1;
1037 +a
1038 +1
1039 +2
1040 +3
1041 +/* with comment first and "quote" */select * from t1;
1042 +a
1043 +1
1044 +2
1045 +3
1046 +show status like "Qcache_queries_in_cache";
1047 +Variable_name  Value
1048 +Qcache_queries_in_cache        1
1049 +show status like "Qcache_inserts";
1050 +Variable_name  Value
1051 +Qcache_inserts 1
1052 +show status like "Qcache_hits";
1053 +Variable_name  Value
1054 +Qcache_hits    8
1055 +-----------------------------------------------------
1056 +# with comment first and "quote"
1057 +select * from t1
1058 +-----------------------------------------------------
1059 +show status like "Qcache_queries_in_cache";
1060 +Variable_name  Value
1061 +Qcache_queries_in_cache        1
1062 +show status like "Qcache_inserts";
1063 +Variable_name  Value
1064 +Qcache_inserts 1
1065 +show status like "Qcache_hits";
1066 +Variable_name  Value
1067 +Qcache_hits    8
1068 +# with comment first and "quote"
1069 +select * from t1;
1070 +a
1071 +1
1072 +2
1073 +3
1074 +# with comment first and "quote"
1075 +select * from t1;
1076 +a
1077 +1
1078 +2
1079 +3
1080 +show status like "Qcache_queries_in_cache";
1081 +Variable_name  Value
1082 +Qcache_queries_in_cache        1
1083 +show status like "Qcache_inserts";
1084 +Variable_name  Value
1085 +Qcache_inserts 1
1086 +show status like "Qcache_hits";
1087 +Variable_name  Value
1088 +Qcache_hits    10
1089 +-----------------------------------------------------
1090 +-- with comment first and "quote" 
1091 +select * from t1
1092 +-----------------------------------------------------
1093 +show status like "Qcache_queries_in_cache";
1094 +Variable_name  Value
1095 +Qcache_queries_in_cache        1
1096 +show status like "Qcache_inserts";
1097 +Variable_name  Value
1098 +Qcache_inserts 1
1099 +show status like "Qcache_hits";
1100 +Variable_name  Value
1101 +Qcache_hits    10
1102 +-- with comment first and "quote" 
1103 +select * from t1;
1104 +a
1105 +1
1106 +2
1107 +3
1108 +-- with comment first and "quote" 
1109 +select * from t1;
1110 +a
1111 +1
1112 +2
1113 +3
1114 +show status like "Qcache_queries_in_cache";
1115 +Variable_name  Value
1116 +Qcache_queries_in_cache        1
1117 +show status like "Qcache_inserts";
1118 +Variable_name  Value
1119 +Qcache_inserts 1
1120 +show status like "Qcache_hits";
1121 +Variable_name  Value
1122 +Qcache_hits    12
1123 +-----------------------------------------------------
1124 +/* with comment and whitespaces first */select * from t1
1125 +-----------------------------------------------------
1126 +show status like "Qcache_queries_in_cache";
1127 +Variable_name  Value
1128 +Qcache_queries_in_cache        1
1129 +show status like "Qcache_inserts";
1130 +Variable_name  Value
1131 +Qcache_inserts 1
1132 +show status like "Qcache_hits";
1133 +Variable_name  Value
1134 +Qcache_hits    12
1135 +/* with comment and whitespaces first */select * from t1;
1136 +a
1137 +1
1138 +2
1139 +3
1140 +/* with comment and whitespaces first */select * from t1;
1141 +a
1142 +1
1143 +2
1144 +3
1145 +show status like "Qcache_queries_in_cache";
1146 +Variable_name  Value
1147 +Qcache_queries_in_cache        1
1148 +show status like "Qcache_inserts";
1149 +Variable_name  Value
1150 +Qcache_inserts 1
1151 +show status like "Qcache_hits";
1152 +Variable_name  Value
1153 +Qcache_hits    14
1154 +-----------------------------------------------------
1155 +# with comment and whitespaces first
1156 +select * from t1
1157 +-----------------------------------------------------
1158 +show status like "Qcache_queries_in_cache";
1159 +Variable_name  Value
1160 +Qcache_queries_in_cache        1
1161 +show status like "Qcache_inserts";
1162 +Variable_name  Value
1163 +Qcache_inserts 1
1164 +show status like "Qcache_hits";
1165 +Variable_name  Value
1166 +Qcache_hits    14
1167 +# with comment and whitespaces first
1168 +select * from t1;
1169 +a
1170 +1
1171 +2
1172 +3
1173 +# with comment and whitespaces first
1174 +select * from t1;
1175 +a
1176 +1
1177 +2
1178 +3
1179 +show status like "Qcache_queries_in_cache";
1180 +Variable_name  Value
1181 +Qcache_queries_in_cache        1
1182 +show status like "Qcache_inserts";
1183 +Variable_name  Value
1184 +Qcache_inserts 1
1185 +show status like "Qcache_hits";
1186 +Variable_name  Value
1187 +Qcache_hits    16
1188 +-----------------------------------------------------
1189 +-- with comment and whitespaces first
1190 +select * from t1
1191 +-----------------------------------------------------
1192 +show status like "Qcache_queries_in_cache";
1193 +Variable_name  Value
1194 +Qcache_queries_in_cache        1
1195 +show status like "Qcache_inserts";
1196 +Variable_name  Value
1197 +Qcache_inserts 1
1198 +show status like "Qcache_hits";
1199 +Variable_name  Value
1200 +Qcache_hits    16
1201 +-- with comment and whitespaces first
1202 +select * from t1;
1203 +a
1204 +1
1205 +2
1206 +3
1207 +-- with comment and whitespaces first
1208 +select * from t1;
1209 +a
1210 +1
1211 +2
1212 +3
1213 +show status like "Qcache_queries_in_cache";
1214 +Variable_name  Value
1215 +Qcache_queries_in_cache        1
1216 +show status like "Qcache_inserts";
1217 +Variable_name  Value
1218 +Qcache_inserts 1
1219 +show status like "Qcache_hits";
1220 +Variable_name  Value
1221 +Qcache_hits    18
1222 +-----------------------------------------------------
1223 +select * /* internal comment */ from t1
1224 +-----------------------------------------------------
1225 +show status like "Qcache_queries_in_cache";
1226 +Variable_name  Value
1227 +Qcache_queries_in_cache        1
1228 +show status like "Qcache_inserts";
1229 +Variable_name  Value
1230 +Qcache_inserts 1
1231 +show status like "Qcache_hits";
1232 +Variable_name  Value
1233 +Qcache_hits    18
1234 +select * /* internal comment */ from t1;
1235 +a
1236 +1
1237 +2
1238 +3
1239 +select * /* internal comment */ from t1;
1240 +a
1241 +1
1242 +2
1243 +3
1244 +show status like "Qcache_queries_in_cache";
1245 +Variable_name  Value
1246 +Qcache_queries_in_cache        1
1247 +show status like "Qcache_inserts";
1248 +Variable_name  Value
1249 +Qcache_inserts 1
1250 +show status like "Qcache_hits";
1251 +Variable_name  Value
1252 +Qcache_hits    20
1253 +-----------------------------------------------------
1254 +select */* internal comment */ 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    20
1265 +select */* internal comment */ from t1;
1266 +a
1267 +1
1268 +2
1269 +3
1270 +select */* internal comment */ from t1;
1271 +a
1272 +1
1273 +2
1274 +3
1275 +show status like "Qcache_queries_in_cache";
1276 +Variable_name  Value
1277 +Qcache_queries_in_cache        1
1278 +show status like "Qcache_inserts";
1279 +Variable_name  Value
1280 +Qcache_inserts 1
1281 +show status like "Qcache_hits";
1282 +Variable_name  Value
1283 +Qcache_hits    22
1284 +-----------------------------------------------------
1285 +select */* internal comment */from t1
1286 +-----------------------------------------------------
1287 +show status like "Qcache_queries_in_cache";
1288 +Variable_name  Value
1289 +Qcache_queries_in_cache        1
1290 +show status like "Qcache_inserts";
1291 +Variable_name  Value
1292 +Qcache_inserts 1
1293 +show status like "Qcache_hits";
1294 +Variable_name  Value
1295 +Qcache_hits    22
1296 +select */* internal comment */from t1;
1297 +a
1298 +1
1299 +2
1300 +3
1301 +select */* internal comment */from t1;
1302 +a
1303 +1
1304 +2
1305 +3
1306 +show status like "Qcache_queries_in_cache";
1307 +Variable_name  Value
1308 +Qcache_queries_in_cache        1
1309 +show status like "Qcache_inserts";
1310 +Variable_name  Value
1311 +Qcache_inserts 1
1312 +show status like "Qcache_hits";
1313 +Variable_name  Value
1314 +Qcache_hits    24
1315 +-----------------------------------------------------
1316 +select * /* internal comment with "quote" */ from t1
1317 +-----------------------------------------------------
1318 +show status like "Qcache_queries_in_cache";
1319 +Variable_name  Value
1320 +Qcache_queries_in_cache        1
1321 +show status like "Qcache_inserts";
1322 +Variable_name  Value
1323 +Qcache_inserts 1
1324 +show status like "Qcache_hits";
1325 +Variable_name  Value
1326 +Qcache_hits    24
1327 +select * /* internal comment with "quote" */ from t1;
1328 +a
1329 +1
1330 +2
1331 +3
1332 +select * /* internal comment with "quote" */ from t1;
1333 +a
1334 +1
1335 +2
1336 +3
1337 +show status like "Qcache_queries_in_cache";
1338 +Variable_name  Value
1339 +Qcache_queries_in_cache        1
1340 +show status like "Qcache_inserts";
1341 +Variable_name  Value
1342 +Qcache_inserts 1
1343 +show status like "Qcache_hits";
1344 +Variable_name  Value
1345 +Qcache_hits    26
1346 +-----------------------------------------------------
1347 +select */* internal comment with "quote" */ from t1
1348 +-----------------------------------------------------
1349 +show status like "Qcache_queries_in_cache";
1350 +Variable_name  Value
1351 +Qcache_queries_in_cache        1
1352 +show status like "Qcache_inserts";
1353 +Variable_name  Value
1354 +Qcache_inserts 1
1355 +show status like "Qcache_hits";
1356 +Variable_name  Value
1357 +Qcache_hits    26
1358 +select */* internal comment with "quote" */ from t1;
1359 +a
1360 +1
1361 +2
1362 +3
1363 +select */* internal comment with "quote" */ from t1;
1364 +a
1365 +1
1366 +2
1367 +3
1368 +show status like "Qcache_queries_in_cache";
1369 +Variable_name  Value
1370 +Qcache_queries_in_cache        1
1371 +show status like "Qcache_inserts";
1372 +Variable_name  Value
1373 +Qcache_inserts 1
1374 +show status like "Qcache_hits";
1375 +Variable_name  Value
1376 +Qcache_hits    28
1377 +-----------------------------------------------------
1378 +select */* internal comment with "quote" */from t1
1379 +-----------------------------------------------------
1380 +show status like "Qcache_queries_in_cache";
1381 +Variable_name  Value
1382 +Qcache_queries_in_cache        1
1383 +show status like "Qcache_inserts";
1384 +Variable_name  Value
1385 +Qcache_inserts 1
1386 +show status like "Qcache_hits";
1387 +Variable_name  Value
1388 +Qcache_hits    28
1389 +select */* internal comment with "quote" */from t1;
1390 +a
1391 +1
1392 +2
1393 +3
1394 +select */* internal comment with "quote" */from t1;
1395 +a
1396 +1
1397 +2
1398 +3
1399 +show status like "Qcache_queries_in_cache";
1400 +Variable_name  Value
1401 +Qcache_queries_in_cache        1
1402 +show status like "Qcache_inserts";
1403 +Variable_name  Value
1404 +Qcache_inserts 1
1405 +show status like "Qcache_hits";
1406 +Variable_name  Value
1407 +Qcache_hits    30
1408 +-----------------------------------------------------
1409 +select * from t1
1410 +
1411 +-----------------------------------------------------
1412 +show status like "Qcache_queries_in_cache";
1413 +Variable_name  Value
1414 +Qcache_queries_in_cache        1
1415 +show status like "Qcache_inserts";
1416 +Variable_name  Value
1417 +Qcache_inserts 1
1418 +show status like "Qcache_hits";
1419 +Variable_name  Value
1420 +Qcache_hits    30
1421 +select * from t1
1422 +;
1423 +a
1424 +1
1425 +2
1426 +3
1427 +select * from t1
1428 +;
1429 +a
1430 +1
1431 +2
1432 +3
1433 +show status like "Qcache_queries_in_cache";
1434 +Variable_name  Value
1435 +Qcache_queries_in_cache        1
1436 +show status like "Qcache_inserts";
1437 +Variable_name  Value
1438 +Qcache_inserts 1
1439 +show status like "Qcache_hits";
1440 +Variable_name  Value
1441 +Qcache_hits    32
1442 +-----------------------------------------------------
1443 +select * from t1 
1444 +-----------------------------------------------------
1445 +show status like "Qcache_queries_in_cache";
1446 +Variable_name  Value
1447 +Qcache_queries_in_cache        1
1448 +show status like "Qcache_inserts";
1449 +Variable_name  Value
1450 +Qcache_inserts 1
1451 +show status like "Qcache_hits";
1452 +Variable_name  Value
1453 +Qcache_hits    32
1454 +select * from t1 ;
1455 +a
1456 +1
1457 +2
1458 +3
1459 +select * from t1 ;
1460 +a
1461 +1
1462 +2
1463 +3
1464 +show status like "Qcache_queries_in_cache";
1465 +Variable_name  Value
1466 +Qcache_queries_in_cache        1
1467 +show status like "Qcache_inserts";
1468 +Variable_name  Value
1469 +Qcache_inserts 1
1470 +show status like "Qcache_hits";
1471 +Variable_name  Value
1472 +Qcache_hits    34
1473 +-----------------------------------------------------
1474 +select * from t1       
1475 +-----------------------------------------------------
1476 +show status like "Qcache_queries_in_cache";
1477 +Variable_name  Value
1478 +Qcache_queries_in_cache        1
1479 +show status like "Qcache_inserts";
1480 +Variable_name  Value
1481 +Qcache_inserts 1
1482 +show status like "Qcache_hits";
1483 +Variable_name  Value
1484 +Qcache_hits    34
1485 +select * from t1       ;
1486 +a
1487 +1
1488 +2
1489 +3
1490 +select * from t1       ;
1491 +a
1492 +1
1493 +2
1494 +3
1495 +show status like "Qcache_queries_in_cache";
1496 +Variable_name  Value
1497 +Qcache_queries_in_cache        1
1498 +show status like "Qcache_inserts";
1499 +Variable_name  Value
1500 +Qcache_inserts 1
1501 +show status like "Qcache_hits";
1502 +Variable_name  Value
1503 +Qcache_hits    36
1504 +-----------------------------------------------------
1505 +select * from t1
1506 +/* comment in the end */
1507 +-----------------------------------------------------
1508 +show status like "Qcache_queries_in_cache";
1509 +Variable_name  Value
1510 +Qcache_queries_in_cache        1
1511 +show status like "Qcache_inserts";
1512 +Variable_name  Value
1513 +Qcache_inserts 1
1514 +show status like "Qcache_hits";
1515 +Variable_name  Value
1516 +Qcache_hits    36
1517 +select * from t1
1518 +/* comment in the end */;
1519 +a
1520 +1
1521 +2
1522 +3
1523 +select * from t1
1524 +/* comment in the end */;
1525 +a
1526 +1
1527 +2
1528 +3
1529 +show status like "Qcache_queries_in_cache";
1530 +Variable_name  Value
1531 +Qcache_queries_in_cache        1
1532 +show status like "Qcache_inserts";
1533 +Variable_name  Value
1534 +Qcache_inserts 1
1535 +show status like "Qcache_hits";
1536 +Variable_name  Value
1537 +Qcache_hits    38
1538 +-----------------------------------------------------
1539 +select * from t1
1540 +/* *\/ */
1541 +-----------------------------------------------------
1542 +show status like "Qcache_queries_in_cache";
1543 +Variable_name  Value
1544 +Qcache_queries_in_cache        1
1545 +show status like "Qcache_inserts";
1546 +Variable_name  Value
1547 +Qcache_inserts 1
1548 +show status like "Qcache_hits";
1549 +Variable_name  Value
1550 +Qcache_hits    38
1551 +select * from t1
1552 +/* *\/ */;
1553 +a
1554 +1
1555 +2
1556 +3
1557 +select * from t1
1558 +/* *\/ */;
1559 +a
1560 +1
1561 +2
1562 +3
1563 +show status like "Qcache_queries_in_cache";
1564 +Variable_name  Value
1565 +Qcache_queries_in_cache        1
1566 +show status like "Qcache_inserts";
1567 +Variable_name  Value
1568 +Qcache_inserts 1
1569 +show status like "Qcache_hits";
1570 +Variable_name  Value
1571 +Qcache_hits    40
1572 +-----------------------------------------------------
1573 +select * from t1
1574 +/* comment in the end */
1575 +
1576 +-----------------------------------------------------
1577 +show status like "Qcache_queries_in_cache";
1578 +Variable_name  Value
1579 +Qcache_queries_in_cache        1
1580 +show status like "Qcache_inserts";
1581 +Variable_name  Value
1582 +Qcache_inserts 1
1583 +show status like "Qcache_hits";
1584 +Variable_name  Value
1585 +Qcache_hits    40
1586 +select * from t1
1587 +/* comment in the end */
1588 +;
1589 +a
1590 +1
1591 +2
1592 +3
1593 +select * from t1
1594 +/* comment in the end */
1595 +;
1596 +a
1597 +1
1598 +2
1599 +3
1600 +show status like "Qcache_queries_in_cache";
1601 +Variable_name  Value
1602 +Qcache_queries_in_cache        1
1603 +show status like "Qcache_inserts";
1604 +Variable_name  Value
1605 +Qcache_inserts 1
1606 +show status like "Qcache_hits";
1607 +Variable_name  Value
1608 +Qcache_hits    42
1609 +-----------------------------------------------------
1610 +select * from t1 #comment in the end
1611 +-----------------------------------------------------
1612 +show status like "Qcache_queries_in_cache";
1613 +Variable_name  Value
1614 +Qcache_queries_in_cache        1
1615 +show status like "Qcache_inserts";
1616 +Variable_name  Value
1617 +Qcache_inserts 1
1618 +show status like "Qcache_hits";
1619 +Variable_name  Value
1620 +Qcache_hits    42
1621 +select * from t1 #comment in the end;
1622 +a
1623 +1
1624 +2
1625 +3
1626 +select * from t1 #comment in the end;
1627 +a
1628 +1
1629 +2
1630 +3
1631 +show status like "Qcache_queries_in_cache";
1632 +Variable_name  Value
1633 +Qcache_queries_in_cache        1
1634 +show status like "Qcache_inserts";
1635 +Variable_name  Value
1636 +Qcache_inserts 1
1637 +show status like "Qcache_hits";
1638 +Variable_name  Value
1639 +Qcache_hits    44
1640 +-----------------------------------------------------
1641 +select * from t1 #comment in the end
1642 +
1643 +-----------------------------------------------------
1644 +show status like "Qcache_queries_in_cache";
1645 +Variable_name  Value
1646 +Qcache_queries_in_cache        1
1647 +show status like "Qcache_inserts";
1648 +Variable_name  Value
1649 +Qcache_inserts 1
1650 +show status like "Qcache_hits";
1651 +Variable_name  Value
1652 +Qcache_hits    44
1653 +select * from t1 #comment in the end
1654 +;
1655 +a
1656 +1
1657 +2
1658 +3
1659 +select * from t1 #comment in the end
1660 +;
1661 +a
1662 +1
1663 +2
1664 +3
1665 +show status like "Qcache_queries_in_cache";
1666 +Variable_name  Value
1667 +Qcache_queries_in_cache        1
1668 +show status like "Qcache_inserts";
1669 +Variable_name  Value
1670 +Qcache_inserts 1
1671 +show status like "Qcache_hits";
1672 +Variable_name  Value
1673 +Qcache_hits    46
1674 +-----------------------------------------------------
1675 +select * from t1 -- comment in the end
1676 +-----------------------------------------------------
1677 +show status like "Qcache_queries_in_cache";
1678 +Variable_name  Value
1679 +Qcache_queries_in_cache        1
1680 +show status like "Qcache_inserts";
1681 +Variable_name  Value
1682 +Qcache_inserts 1
1683 +show status like "Qcache_hits";
1684 +Variable_name  Value
1685 +Qcache_hits    46
1686 +select * from t1 -- comment in the end;
1687 +a
1688 +1
1689 +2
1690 +3
1691 +select * from t1 -- comment in the end;
1692 +a
1693 +1
1694 +2
1695 +3
1696 +show status like "Qcache_queries_in_cache";
1697 +Variable_name  Value
1698 +Qcache_queries_in_cache        1
1699 +show status like "Qcache_inserts";
1700 +Variable_name  Value
1701 +Qcache_inserts 1
1702 +show status like "Qcache_hits";
1703 +Variable_name  Value
1704 +Qcache_hits    48
1705 +-----------------------------------------------------
1706 +select * from t1 -- comment in the end
1707 +
1708 +-----------------------------------------------------
1709 +show status like "Qcache_queries_in_cache";
1710 +Variable_name  Value
1711 +Qcache_queries_in_cache        1
1712 +show status like "Qcache_inserts";
1713 +Variable_name  Value
1714 +Qcache_inserts 1
1715 +show status like "Qcache_hits";
1716 +Variable_name  Value
1717 +Qcache_hits    48
1718 +select * from t1 -- comment in the end
1719 +;
1720 +a
1721 +1
1722 +2
1723 +3
1724 +select * from t1 -- comment in the end
1725 +;
1726 +a
1727 +1
1728 +2
1729 +3
1730 +show status like "Qcache_queries_in_cache";
1731 +Variable_name  Value
1732 +Qcache_queries_in_cache        1
1733 +show status like "Qcache_inserts";
1734 +Variable_name  Value
1735 +Qcache_inserts 1
1736 +show status like "Qcache_hits";
1737 +Variable_name  Value
1738 +Qcache_hits    50
1739 +-----------------------------------------------------
1740 +select */* a comment \*/from t1
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    50
1751 +select */* a comment \*/from t1;
1752 +a
1753 +1
1754 +2
1755 +3
1756 +select */* a comment \*/from t1;
1757 +a
1758 +1
1759 +2
1760 +3
1761 +show status like "Qcache_queries_in_cache";
1762 +Variable_name  Value
1763 +Qcache_queries_in_cache        1
1764 +show status like "Qcache_inserts";
1765 +Variable_name  Value
1766 +Qcache_inserts 1
1767 +show status like "Qcache_hits";
1768 +Variable_name  Value
1769 +Qcache_hits    52
1770 +-----------------------------------------------------
1771 +select *# a comment \
1772 +from t1
1773 +-----------------------------------------------------
1774 +show status like "Qcache_queries_in_cache";
1775 +Variable_name  Value
1776 +Qcache_queries_in_cache        1
1777 +show status like "Qcache_inserts";
1778 +Variable_name  Value
1779 +Qcache_inserts 1
1780 +show status like "Qcache_hits";
1781 +Variable_name  Value
1782 +Qcache_hits    52
1783 +select *# a comment \
1784 +from t1;
1785 +a
1786 +1
1787 +2
1788 +3
1789 +select *# a comment \
1790 +from t1;
1791 +a
1792 +1
1793 +2
1794 +3
1795 +show status like "Qcache_queries_in_cache";
1796 +Variable_name  Value
1797 +Qcache_queries_in_cache        1
1798 +show status like "Qcache_inserts";
1799 +Variable_name  Value
1800 +Qcache_inserts 1
1801 +show status like "Qcache_hits";
1802 +Variable_name  Value
1803 +Qcache_hits    54
1804 +-----------------------------------------------------
1805 +select *-- a comment \
1806 +from t1
1807 +-----------------------------------------------------
1808 +show status like "Qcache_queries_in_cache";
1809 +Variable_name  Value
1810 +Qcache_queries_in_cache        1
1811 +show status like "Qcache_inserts";
1812 +Variable_name  Value
1813 +Qcache_inserts 1
1814 +show status like "Qcache_hits";
1815 +Variable_name  Value
1816 +Qcache_hits    54
1817 +select *-- a comment \
1818 +from t1;
1819 +a
1820 +1
1821 +2
1822 +3
1823 +select *-- a comment \
1824 +from t1;
1825 +a
1826 +1
1827 +2
1828 +3
1829 +show status like "Qcache_queries_in_cache";
1830 +Variable_name  Value
1831 +Qcache_queries_in_cache        1
1832 +show status like "Qcache_inserts";
1833 +Variable_name  Value
1834 +Qcache_inserts 1
1835 +show status like "Qcache_hits";
1836 +Variable_name  Value
1837 +Qcache_hits    56
1838 +-----------------------------------------------------
1839 +select "\\"" /* not a comment */" from t1
1840 +-----------------------------------------------------
1841 +show status like "Qcache_queries_in_cache";
1842 +Variable_name  Value
1843 +Qcache_queries_in_cache        1
1844 +show status like "Qcache_inserts";
1845 +Variable_name  Value
1846 +Qcache_inserts 1
1847 +show status like "Qcache_hits";
1848 +Variable_name  Value
1849 +Qcache_hits    56
1850 +select "\\"" /* not a comment */" from t1;
1851 +\" /* not a comment */
1852 +\" /* not a comment */
1853 +\" /* not a comment */
1854 +\" /* not a comment */
1855 +select "\\"" /* not a comment */" from t1;
1856 +\" /* not a comment */
1857 +\" /* not a comment */
1858 +\" /* not a comment */
1859 +\" /* not a comment */
1860 +show status like "Qcache_queries_in_cache";
1861 +Variable_name  Value
1862 +Qcache_queries_in_cache        2
1863 +show status like "Qcache_inserts";
1864 +Variable_name  Value
1865 +Qcache_inserts 2
1866 +show status like "Qcache_hits";
1867 +Variable_name  Value
1868 +Qcache_hits    57
1869 +-----------------------------------------------------
1870 +select "\\"" /*! not a comment */" from t1
1871 +-----------------------------------------------------
1872 +show status like "Qcache_queries_in_cache";
1873 +Variable_name  Value
1874 +Qcache_queries_in_cache        2
1875 +show status like "Qcache_inserts";
1876 +Variable_name  Value
1877 +Qcache_inserts 2
1878 +show status like "Qcache_hits";
1879 +Variable_name  Value
1880 +Qcache_hits    57
1881 +select "\\"" /*! not a comment */" from t1;
1882 +\" /*! not a comment */
1883 +\" /*! not a comment */
1884 +\" /*! not a comment */
1885 +\" /*! not a comment */
1886 +select "\\"" /*! not a comment */" from t1;
1887 +\" /*! not a comment */
1888 +\" /*! not a comment */
1889 +\" /*! not a comment */
1890 +\" /*! not a comment */
1891 +show status like "Qcache_queries_in_cache";
1892 +Variable_name  Value
1893 +Qcache_queries_in_cache        3
1894 +show status like "Qcache_inserts";
1895 +Variable_name  Value
1896 +Qcache_inserts 3
1897 +show status like "Qcache_hits";
1898 +Variable_name  Value
1899 +Qcache_hits    58
1900 +-----------------------------------------------------
1901 +select ' \'  ' from t1
1902 +-----------------------------------------------------
1903 +show status like "Qcache_queries_in_cache";
1904 +Variable_name  Value
1905 +Qcache_queries_in_cache        3
1906 +show status like "Qcache_inserts";
1907 +Variable_name  Value
1908 +Qcache_inserts 3
1909 +show status like "Qcache_hits";
1910 +Variable_name  Value
1911 +Qcache_hits    58
1912 +select ' \'  ' from t1;
1913 +'  
1914 + '  
1915 + '  
1916 + '  
1917 +select ' \'  ' from t1;
1918 +'  
1919 + '  
1920 + '  
1921 + '  
1922 +show status like "Qcache_queries_in_cache";
1923 +Variable_name  Value
1924 +Qcache_queries_in_cache        4
1925 +show status like "Qcache_inserts";
1926 +Variable_name  Value
1927 +Qcache_inserts 4
1928 +show status like "Qcache_hits";
1929 +Variable_name  Value
1930 +Qcache_hits    59
1931 +-----------------------------------------------------
1932 +select ' \' /* comment inside quotes with internal backslash quote */' from t1
1933 +-----------------------------------------------------
1934 +show status like "Qcache_queries_in_cache";
1935 +Variable_name  Value
1936 +Qcache_queries_in_cache        4
1937 +show status like "Qcache_inserts";
1938 +Variable_name  Value
1939 +Qcache_inserts 4
1940 +show status like "Qcache_hits";
1941 +Variable_name  Value
1942 +Qcache_hits    59
1943 +select ' \' /* comment inside quotes with internal backslash quote */' from t1;
1944 +' /* comment inside quotes with internal backslash quote */
1945 + ' /* comment inside quotes with internal backslash quote */
1946 + ' /* comment inside quotes with internal backslash quote */
1947 + ' /* comment inside quotes with internal backslash quote */
1948 +select ' \' /* comment inside quotes with internal backslash quote */' from t1;
1949 +' /* comment inside quotes with internal backslash quote */
1950 + ' /* comment inside quotes with internal backslash quote */
1951 + ' /* comment inside quotes with internal backslash quote */
1952 + ' /* comment inside quotes with internal backslash quote */
1953 +show status like "Qcache_queries_in_cache";
1954 +Variable_name  Value
1955 +Qcache_queries_in_cache        5
1956 +show status like "Qcache_inserts";
1957 +Variable_name  Value
1958 +Qcache_inserts 5
1959 +show status like "Qcache_hits";
1960 +Variable_name  Value
1961 +Qcache_hits    60
1962 +DROP TABLE t1;
1963 +SET GLOBAL query_cache_size=default;
1964 +set global query_cache_strip_comments=OFF;
1965 --- /dev/null
1966 +++ b/mysql-test/r/percona_query_cache_with_comments_crash.result
1967 @@ -0,0 +1,21 @@
1968 +set GLOBAL query_cache_size=1355776;
1969 +drop table if exists t1;
1970 +create table t1 (a int not null);
1971 +insert into t1 values (1),(2),(3);
1972 +flush query cache;
1973 +flush query cache;
1974 +reset query cache;
1975 +flush status;
1976 +( select * from t1 );
1977 +a
1978 +1
1979 +2
1980 +3
1981 +/*!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 */;
1982 +/* only comment */;
1983 +# only comment
1984 +;
1985 +-- only comment
1986 +;
1987 +DROP TABLE t1;
1988 +SET GLOBAL query_cache_size= default;
1989 --- /dev/null
1990 +++ b/mysql-test/r/percona_query_cache_with_comments_disable.result
1991 @@ -0,0 +1,1057 @@
1992 +set GLOBAL query_cache_size=1355776;
1993 +drop table if exists t1;
1994 +create table t1 (a int not null);
1995 +insert into t1 values (1),(2),(3);
1996 +flush query cache;
1997 +flush query cache;
1998 +reset query cache;
1999 +flush status;
2000 +flush query cache;
2001 +flush query cache;
2002 +reset query cache;
2003 +flush status;
2004 +/* with comment first */select * from t1;
2005 +a
2006 +1
2007 +2
2008 +3
2009 +-----------------------------------------------------
2010 +/* with comment first */select * from t1
2011 +-----------------------------------------------------
2012 +show status like "Qcache_queries_in_cache";
2013 +Variable_name  Value
2014 +Qcache_queries_in_cache        1
2015 +show status like "Qcache_inserts";
2016 +Variable_name  Value
2017 +Qcache_inserts 1
2018 +show status like "Qcache_hits";
2019 +Variable_name  Value
2020 +Qcache_hits    0
2021 +/* with comment first */select * from t1;
2022 +a
2023 +1
2024 +2
2025 +3
2026 +/* with comment first */select * from t1;
2027 +a
2028 +1
2029 +2
2030 +3
2031 +show status like "Qcache_queries_in_cache";
2032 +Variable_name  Value
2033 +Qcache_queries_in_cache        1
2034 +show status like "Qcache_inserts";
2035 +Variable_name  Value
2036 +Qcache_inserts 1
2037 +show status like "Qcache_hits";
2038 +Variable_name  Value
2039 +Qcache_hits    2
2040 +-----------------------------------------------------
2041 +# with comment first
2042 +select * from t1
2043 +-----------------------------------------------------
2044 +show status like "Qcache_queries_in_cache";
2045 +Variable_name  Value
2046 +Qcache_queries_in_cache        1
2047 +show status like "Qcache_inserts";
2048 +Variable_name  Value
2049 +Qcache_inserts 1
2050 +show status like "Qcache_hits";
2051 +Variable_name  Value
2052 +Qcache_hits    2
2053 +# with comment first
2054 +select * from t1;
2055 +a
2056 +1
2057 +2
2058 +3
2059 +# with comment first
2060 +select * from t1;
2061 +a
2062 +1
2063 +2
2064 +3
2065 +show status like "Qcache_queries_in_cache";
2066 +Variable_name  Value
2067 +Qcache_queries_in_cache        2
2068 +show status like "Qcache_inserts";
2069 +Variable_name  Value
2070 +Qcache_inserts 2
2071 +show status like "Qcache_hits";
2072 +Variable_name  Value
2073 +Qcache_hits    2
2074 +-----------------------------------------------------
2075 +-- with comment first
2076 +select * from t1
2077 +-----------------------------------------------------
2078 +show status like "Qcache_queries_in_cache";
2079 +Variable_name  Value
2080 +Qcache_queries_in_cache        2
2081 +show status like "Qcache_inserts";
2082 +Variable_name  Value
2083 +Qcache_inserts 2
2084 +show status like "Qcache_hits";
2085 +Variable_name  Value
2086 +Qcache_hits    2
2087 +-- with comment first
2088 +select * from t1;
2089 +a
2090 +1
2091 +2
2092 +3
2093 +-- with comment first
2094 +select * from t1;
2095 +a
2096 +1
2097 +2
2098 +3
2099 +show status like "Qcache_queries_in_cache";
2100 +Variable_name  Value
2101 +Qcache_queries_in_cache        3
2102 +show status like "Qcache_inserts";
2103 +Variable_name  Value
2104 +Qcache_inserts 3
2105 +show status like "Qcache_hits";
2106 +Variable_name  Value
2107 +Qcache_hits    2
2108 +-----------------------------------------------------
2109 +/* with comment first and "quote" */select * from t1
2110 +-----------------------------------------------------
2111 +show status like "Qcache_queries_in_cache";
2112 +Variable_name  Value
2113 +Qcache_queries_in_cache        3
2114 +show status like "Qcache_inserts";
2115 +Variable_name  Value
2116 +Qcache_inserts 3
2117 +show status like "Qcache_hits";
2118 +Variable_name  Value
2119 +Qcache_hits    2
2120 +/* with comment first and "quote" */select * from t1;
2121 +a
2122 +1
2123 +2
2124 +3
2125 +/* with comment first and "quote" */select * from t1;
2126 +a
2127 +1
2128 +2
2129 +3
2130 +show status like "Qcache_queries_in_cache";
2131 +Variable_name  Value
2132 +Qcache_queries_in_cache        4
2133 +show status like "Qcache_inserts";
2134 +Variable_name  Value
2135 +Qcache_inserts 4
2136 +show status like "Qcache_hits";
2137 +Variable_name  Value
2138 +Qcache_hits    3
2139 +-----------------------------------------------------
2140 +# with comment first and "quote"
2141 +select * from t1
2142 +-----------------------------------------------------
2143 +show status like "Qcache_queries_in_cache";
2144 +Variable_name  Value
2145 +Qcache_queries_in_cache        4
2146 +show status like "Qcache_inserts";
2147 +Variable_name  Value
2148 +Qcache_inserts 4
2149 +show status like "Qcache_hits";
2150 +Variable_name  Value
2151 +Qcache_hits    3
2152 +# with comment first and "quote"
2153 +select * from t1;
2154 +a
2155 +1
2156 +2
2157 +3
2158 +# with comment first and "quote"
2159 +select * from t1;
2160 +a
2161 +1
2162 +2
2163 +3
2164 +show status like "Qcache_queries_in_cache";
2165 +Variable_name  Value
2166 +Qcache_queries_in_cache        5
2167 +show status like "Qcache_inserts";
2168 +Variable_name  Value
2169 +Qcache_inserts 5
2170 +show status like "Qcache_hits";
2171 +Variable_name  Value
2172 +Qcache_hits    3
2173 +-----------------------------------------------------
2174 +-- with comment first and "quote" 
2175 +select * from t1
2176 +-----------------------------------------------------
2177 +show status like "Qcache_queries_in_cache";
2178 +Variable_name  Value
2179 +Qcache_queries_in_cache        5
2180 +show status like "Qcache_inserts";
2181 +Variable_name  Value
2182 +Qcache_inserts 5
2183 +show status like "Qcache_hits";
2184 +Variable_name  Value
2185 +Qcache_hits    3
2186 +-- with comment first and "quote" 
2187 +select * from t1;
2188 +a
2189 +1
2190 +2
2191 +3
2192 +-- with comment first and "quote" 
2193 +select * from t1;
2194 +a
2195 +1
2196 +2
2197 +3
2198 +show status like "Qcache_queries_in_cache";
2199 +Variable_name  Value
2200 +Qcache_queries_in_cache        6
2201 +show status like "Qcache_inserts";
2202 +Variable_name  Value
2203 +Qcache_inserts 6
2204 +show status like "Qcache_hits";
2205 +Variable_name  Value
2206 +Qcache_hits    3
2207 +-----------------------------------------------------
2208 +/* with comment and whitespaces first */select * from t1
2209 +-----------------------------------------------------
2210 +show status like "Qcache_queries_in_cache";
2211 +Variable_name  Value
2212 +Qcache_queries_in_cache        6
2213 +show status like "Qcache_inserts";
2214 +Variable_name  Value
2215 +Qcache_inserts 6
2216 +show status like "Qcache_hits";
2217 +Variable_name  Value
2218 +Qcache_hits    3
2219 +/* with comment and whitespaces first */select * from t1;
2220 +a
2221 +1
2222 +2
2223 +3
2224 +/* with comment and whitespaces first */select * from t1;
2225 +a
2226 +1
2227 +2
2228 +3
2229 +show status like "Qcache_queries_in_cache";
2230 +Variable_name  Value
2231 +Qcache_queries_in_cache        7
2232 +show status like "Qcache_inserts";
2233 +Variable_name  Value
2234 +Qcache_inserts 7
2235 +show status like "Qcache_hits";
2236 +Variable_name  Value
2237 +Qcache_hits    4
2238 +-----------------------------------------------------
2239 +# with comment and whitespaces first
2240 +select * from t1
2241 +-----------------------------------------------------
2242 +show status like "Qcache_queries_in_cache";
2243 +Variable_name  Value
2244 +Qcache_queries_in_cache        7
2245 +show status like "Qcache_inserts";
2246 +Variable_name  Value
2247 +Qcache_inserts 7
2248 +show status like "Qcache_hits";
2249 +Variable_name  Value
2250 +Qcache_hits    4
2251 +# with comment and whitespaces first
2252 +select * from t1;
2253 +a
2254 +1
2255 +2
2256 +3
2257 +# with comment and whitespaces first
2258 +select * from t1;
2259 +a
2260 +1
2261 +2
2262 +3
2263 +show status like "Qcache_queries_in_cache";
2264 +Variable_name  Value
2265 +Qcache_queries_in_cache        8
2266 +show status like "Qcache_inserts";
2267 +Variable_name  Value
2268 +Qcache_inserts 8
2269 +show status like "Qcache_hits";
2270 +Variable_name  Value
2271 +Qcache_hits    4
2272 +-----------------------------------------------------
2273 +-- with comment and whitespaces first
2274 +select * from t1
2275 +-----------------------------------------------------
2276 +show status like "Qcache_queries_in_cache";
2277 +Variable_name  Value
2278 +Qcache_queries_in_cache        8
2279 +show status like "Qcache_inserts";
2280 +Variable_name  Value
2281 +Qcache_inserts 8
2282 +show status like "Qcache_hits";
2283 +Variable_name  Value
2284 +Qcache_hits    4
2285 +-- with comment and whitespaces first
2286 +select * from t1;
2287 +a
2288 +1
2289 +2
2290 +3
2291 +-- with comment and whitespaces first
2292 +select * from t1;
2293 +a
2294 +1
2295 +2
2296 +3
2297 +show status like "Qcache_queries_in_cache";
2298 +Variable_name  Value
2299 +Qcache_queries_in_cache        9
2300 +show status like "Qcache_inserts";
2301 +Variable_name  Value
2302 +Qcache_inserts 9
2303 +show status like "Qcache_hits";
2304 +Variable_name  Value
2305 +Qcache_hits    4
2306 +-----------------------------------------------------
2307 +select * /* internal comment */ from t1
2308 +-----------------------------------------------------
2309 +show status like "Qcache_queries_in_cache";
2310 +Variable_name  Value
2311 +Qcache_queries_in_cache        9
2312 +show status like "Qcache_inserts";
2313 +Variable_name  Value
2314 +Qcache_inserts 9
2315 +show status like "Qcache_hits";
2316 +Variable_name  Value
2317 +Qcache_hits    4
2318 +select * /* internal comment */ from t1;
2319 +a
2320 +1
2321 +2
2322 +3
2323 +select * /* internal comment */ from t1;
2324 +a
2325 +1
2326 +2
2327 +3
2328 +show status like "Qcache_queries_in_cache";
2329 +Variable_name  Value
2330 +Qcache_queries_in_cache        10
2331 +show status like "Qcache_inserts";
2332 +Variable_name  Value
2333 +Qcache_inserts 10
2334 +show status like "Qcache_hits";
2335 +Variable_name  Value
2336 +Qcache_hits    5
2337 +-----------------------------------------------------
2338 +select */* internal comment */ from t1
2339 +-----------------------------------------------------
2340 +show status like "Qcache_queries_in_cache";
2341 +Variable_name  Value
2342 +Qcache_queries_in_cache        10
2343 +show status like "Qcache_inserts";
2344 +Variable_name  Value
2345 +Qcache_inserts 10
2346 +show status like "Qcache_hits";
2347 +Variable_name  Value
2348 +Qcache_hits    5
2349 +select */* internal comment */ from t1;
2350 +a
2351 +1
2352 +2
2353 +3
2354 +select */* internal comment */ from t1;
2355 +a
2356 +1
2357 +2
2358 +3
2359 +show status like "Qcache_queries_in_cache";
2360 +Variable_name  Value
2361 +Qcache_queries_in_cache        11
2362 +show status like "Qcache_inserts";
2363 +Variable_name  Value
2364 +Qcache_inserts 11
2365 +show status like "Qcache_hits";
2366 +Variable_name  Value
2367 +Qcache_hits    6
2368 +-----------------------------------------------------
2369 +select */* internal comment */from t1
2370 +-----------------------------------------------------
2371 +show status like "Qcache_queries_in_cache";
2372 +Variable_name  Value
2373 +Qcache_queries_in_cache        11
2374 +show status like "Qcache_inserts";
2375 +Variable_name  Value
2376 +Qcache_inserts 11
2377 +show status like "Qcache_hits";
2378 +Variable_name  Value
2379 +Qcache_hits    6
2380 +select */* internal comment */from t1;
2381 +a
2382 +1
2383 +2
2384 +3
2385 +select */* internal comment */from t1;
2386 +a
2387 +1
2388 +2
2389 +3
2390 +show status like "Qcache_queries_in_cache";
2391 +Variable_name  Value
2392 +Qcache_queries_in_cache        12
2393 +show status like "Qcache_inserts";
2394 +Variable_name  Value
2395 +Qcache_inserts 12
2396 +show status like "Qcache_hits";
2397 +Variable_name  Value
2398 +Qcache_hits    7
2399 +-----------------------------------------------------
2400 +select * /* internal comment with "quote" */ from t1
2401 +-----------------------------------------------------
2402 +show status like "Qcache_queries_in_cache";
2403 +Variable_name  Value
2404 +Qcache_queries_in_cache        12
2405 +show status like "Qcache_inserts";
2406 +Variable_name  Value
2407 +Qcache_inserts 12
2408 +show status like "Qcache_hits";
2409 +Variable_name  Value
2410 +Qcache_hits    7
2411 +select * /* internal comment with "quote" */ from t1;
2412 +a
2413 +1
2414 +2
2415 +3
2416 +select * /* internal comment with "quote" */ from t1;
2417 +a
2418 +1
2419 +2
2420 +3
2421 +show status like "Qcache_queries_in_cache";
2422 +Variable_name  Value
2423 +Qcache_queries_in_cache        13
2424 +show status like "Qcache_inserts";
2425 +Variable_name  Value
2426 +Qcache_inserts 13
2427 +show status like "Qcache_hits";
2428 +Variable_name  Value
2429 +Qcache_hits    8
2430 +-----------------------------------------------------
2431 +select */* internal comment with "quote" */ from t1
2432 +-----------------------------------------------------
2433 +show status like "Qcache_queries_in_cache";
2434 +Variable_name  Value
2435 +Qcache_queries_in_cache        13
2436 +show status like "Qcache_inserts";
2437 +Variable_name  Value
2438 +Qcache_inserts 13
2439 +show status like "Qcache_hits";
2440 +Variable_name  Value
2441 +Qcache_hits    8
2442 +select */* internal comment with "quote" */ from t1;
2443 +a
2444 +1
2445 +2
2446 +3
2447 +select */* internal comment with "quote" */ from t1;
2448 +a
2449 +1
2450 +2
2451 +3
2452 +show status like "Qcache_queries_in_cache";
2453 +Variable_name  Value
2454 +Qcache_queries_in_cache        14
2455 +show status like "Qcache_inserts";
2456 +Variable_name  Value
2457 +Qcache_inserts 14
2458 +show status like "Qcache_hits";
2459 +Variable_name  Value
2460 +Qcache_hits    9
2461 +-----------------------------------------------------
2462 +select */* internal comment with "quote" */from t1
2463 +-----------------------------------------------------
2464 +show status like "Qcache_queries_in_cache";
2465 +Variable_name  Value
2466 +Qcache_queries_in_cache        14
2467 +show status like "Qcache_inserts";
2468 +Variable_name  Value
2469 +Qcache_inserts 14
2470 +show status like "Qcache_hits";
2471 +Variable_name  Value
2472 +Qcache_hits    9
2473 +select */* internal comment with "quote" */from t1;
2474 +a
2475 +1
2476 +2
2477 +3
2478 +select */* internal comment with "quote" */from t1;
2479 +a
2480 +1
2481 +2
2482 +3
2483 +show status like "Qcache_queries_in_cache";
2484 +Variable_name  Value
2485 +Qcache_queries_in_cache        15
2486 +show status like "Qcache_inserts";
2487 +Variable_name  Value
2488 +Qcache_inserts 15
2489 +show status like "Qcache_hits";
2490 +Variable_name  Value
2491 +Qcache_hits    10
2492 +-----------------------------------------------------
2493 +select * from t1
2494 +
2495 +-----------------------------------------------------
2496 +show status like "Qcache_queries_in_cache";
2497 +Variable_name  Value
2498 +Qcache_queries_in_cache        15
2499 +show status like "Qcache_inserts";
2500 +Variable_name  Value
2501 +Qcache_inserts 15
2502 +show status like "Qcache_hits";
2503 +Variable_name  Value
2504 +Qcache_hits    10
2505 +select * from t1
2506 +;
2507 +a
2508 +1
2509 +2
2510 +3
2511 +select * from t1
2512 +;
2513 +a
2514 +1
2515 +2
2516 +3
2517 +show status like "Qcache_queries_in_cache";
2518 +Variable_name  Value
2519 +Qcache_queries_in_cache        16
2520 +show status like "Qcache_inserts";
2521 +Variable_name  Value
2522 +Qcache_inserts 16
2523 +show status like "Qcache_hits";
2524 +Variable_name  Value
2525 +Qcache_hits    11
2526 +-----------------------------------------------------
2527 +select * from t1 
2528 +-----------------------------------------------------
2529 +show status like "Qcache_queries_in_cache";
2530 +Variable_name  Value
2531 +Qcache_queries_in_cache        16
2532 +show status like "Qcache_inserts";
2533 +Variable_name  Value
2534 +Qcache_inserts 16
2535 +show status like "Qcache_hits";
2536 +Variable_name  Value
2537 +Qcache_hits    11
2538 +select * from t1 ;
2539 +a
2540 +1
2541 +2
2542 +3
2543 +select * from t1 ;
2544 +a
2545 +1
2546 +2
2547 +3
2548 +show status like "Qcache_queries_in_cache";
2549 +Variable_name  Value
2550 +Qcache_queries_in_cache        16
2551 +show status like "Qcache_inserts";
2552 +Variable_name  Value
2553 +Qcache_inserts 16
2554 +show status like "Qcache_hits";
2555 +Variable_name  Value
2556 +Qcache_hits    13
2557 +-----------------------------------------------------
2558 +select * from t1       
2559 +-----------------------------------------------------
2560 +show status like "Qcache_queries_in_cache";
2561 +Variable_name  Value
2562 +Qcache_queries_in_cache        16
2563 +show status like "Qcache_inserts";
2564 +Variable_name  Value
2565 +Qcache_inserts 16
2566 +show status like "Qcache_hits";
2567 +Variable_name  Value
2568 +Qcache_hits    13
2569 +select * from t1       ;
2570 +a
2571 +1
2572 +2
2573 +3
2574 +select * from t1       ;
2575 +a
2576 +1
2577 +2
2578 +3
2579 +show status like "Qcache_queries_in_cache";
2580 +Variable_name  Value
2581 +Qcache_queries_in_cache        16
2582 +show status like "Qcache_inserts";
2583 +Variable_name  Value
2584 +Qcache_inserts 16
2585 +show status like "Qcache_hits";
2586 +Variable_name  Value
2587 +Qcache_hits    15
2588 +-----------------------------------------------------
2589 +select * from t1
2590 +/* comment in the end */
2591 +-----------------------------------------------------
2592 +show status like "Qcache_queries_in_cache";
2593 +Variable_name  Value
2594 +Qcache_queries_in_cache        16
2595 +show status like "Qcache_inserts";
2596 +Variable_name  Value
2597 +Qcache_inserts 16
2598 +show status like "Qcache_hits";
2599 +Variable_name  Value
2600 +Qcache_hits    15
2601 +select * from t1
2602 +/* comment in the end */;
2603 +a
2604 +1
2605 +2
2606 +3
2607 +select * from t1
2608 +/* comment in the end */;
2609 +a
2610 +1
2611 +2
2612 +3
2613 +show status like "Qcache_queries_in_cache";
2614 +Variable_name  Value
2615 +Qcache_queries_in_cache        17
2616 +show status like "Qcache_inserts";
2617 +Variable_name  Value
2618 +Qcache_inserts 17
2619 +show status like "Qcache_hits";
2620 +Variable_name  Value
2621 +Qcache_hits    16
2622 +-----------------------------------------------------
2623 +select * from t1
2624 +/* *\/ */
2625 +-----------------------------------------------------
2626 +show status like "Qcache_queries_in_cache";
2627 +Variable_name  Value
2628 +Qcache_queries_in_cache        17
2629 +show status like "Qcache_inserts";
2630 +Variable_name  Value
2631 +Qcache_inserts 17
2632 +show status like "Qcache_hits";
2633 +Variable_name  Value
2634 +Qcache_hits    16
2635 +select * from t1
2636 +/* *\/ */;
2637 +a
2638 +1
2639 +2
2640 +3
2641 +select * from t1
2642 +/* *\/ */;
2643 +a
2644 +1
2645 +2
2646 +3
2647 +show status like "Qcache_queries_in_cache";
2648 +Variable_name  Value
2649 +Qcache_queries_in_cache        18
2650 +show status like "Qcache_inserts";
2651 +Variable_name  Value
2652 +Qcache_inserts 18
2653 +show status like "Qcache_hits";
2654 +Variable_name  Value
2655 +Qcache_hits    17
2656 +-----------------------------------------------------
2657 +select * from t1
2658 +/* comment in the end */
2659 +
2660 +-----------------------------------------------------
2661 +show status like "Qcache_queries_in_cache";
2662 +Variable_name  Value
2663 +Qcache_queries_in_cache        18
2664 +show status like "Qcache_inserts";
2665 +Variable_name  Value
2666 +Qcache_inserts 18
2667 +show status like "Qcache_hits";
2668 +Variable_name  Value
2669 +Qcache_hits    17
2670 +select * from t1
2671 +/* comment in the end */
2672 +;
2673 +a
2674 +1
2675 +2
2676 +3
2677 +select * from t1
2678 +/* comment in the end */
2679 +;
2680 +a
2681 +1
2682 +2
2683 +3
2684 +show status like "Qcache_queries_in_cache";
2685 +Variable_name  Value
2686 +Qcache_queries_in_cache        18
2687 +show status like "Qcache_inserts";
2688 +Variable_name  Value
2689 +Qcache_inserts 18
2690 +show status like "Qcache_hits";
2691 +Variable_name  Value
2692 +Qcache_hits    19
2693 +-----------------------------------------------------
2694 +select * from t1 #comment in the end
2695 +-----------------------------------------------------
2696 +show status like "Qcache_queries_in_cache";
2697 +Variable_name  Value
2698 +Qcache_queries_in_cache        18
2699 +show status like "Qcache_inserts";
2700 +Variable_name  Value
2701 +Qcache_inserts 18
2702 +show status like "Qcache_hits";
2703 +Variable_name  Value
2704 +Qcache_hits    19
2705 +select * from t1 #comment in the end;
2706 +a
2707 +1
2708 +2
2709 +3
2710 +select * from t1 #comment in the end;
2711 +a
2712 +1
2713 +2
2714 +3
2715 +show status like "Qcache_queries_in_cache";
2716 +Variable_name  Value
2717 +Qcache_queries_in_cache        19
2718 +show status like "Qcache_inserts";
2719 +Variable_name  Value
2720 +Qcache_inserts 19
2721 +show status like "Qcache_hits";
2722 +Variable_name  Value
2723 +Qcache_hits    20
2724 +-----------------------------------------------------
2725 +select * from t1 #comment in the end
2726 +
2727 +-----------------------------------------------------
2728 +show status like "Qcache_queries_in_cache";
2729 +Variable_name  Value
2730 +Qcache_queries_in_cache        19
2731 +show status like "Qcache_inserts";
2732 +Variable_name  Value
2733 +Qcache_inserts 19
2734 +show status like "Qcache_hits";
2735 +Variable_name  Value
2736 +Qcache_hits    20
2737 +select * from t1 #comment in the end
2738 +;
2739 +a
2740 +1
2741 +2
2742 +3
2743 +select * from t1 #comment in the end
2744 +;
2745 +a
2746 +1
2747 +2
2748 +3
2749 +show status like "Qcache_queries_in_cache";
2750 +Variable_name  Value
2751 +Qcache_queries_in_cache        19
2752 +show status like "Qcache_inserts";
2753 +Variable_name  Value
2754 +Qcache_inserts 19
2755 +show status like "Qcache_hits";
2756 +Variable_name  Value
2757 +Qcache_hits    22
2758 +-----------------------------------------------------
2759 +select * from t1 -- comment in the end
2760 +-----------------------------------------------------
2761 +show status like "Qcache_queries_in_cache";
2762 +Variable_name  Value
2763 +Qcache_queries_in_cache        19
2764 +show status like "Qcache_inserts";
2765 +Variable_name  Value
2766 +Qcache_inserts 19
2767 +show status like "Qcache_hits";
2768 +Variable_name  Value
2769 +Qcache_hits    22
2770 +select * from t1 -- comment in the end;
2771 +a
2772 +1
2773 +2
2774 +3
2775 +select * from t1 -- comment in the end;
2776 +a
2777 +1
2778 +2
2779 +3
2780 +show status like "Qcache_queries_in_cache";
2781 +Variable_name  Value
2782 +Qcache_queries_in_cache        20
2783 +show status like "Qcache_inserts";
2784 +Variable_name  Value
2785 +Qcache_inserts 20
2786 +show status like "Qcache_hits";
2787 +Variable_name  Value
2788 +Qcache_hits    23
2789 +-----------------------------------------------------
2790 +select * from t1 -- comment in the end
2791 +
2792 +-----------------------------------------------------
2793 +show status like "Qcache_queries_in_cache";
2794 +Variable_name  Value
2795 +Qcache_queries_in_cache        20
2796 +show status like "Qcache_inserts";
2797 +Variable_name  Value
2798 +Qcache_inserts 20
2799 +show status like "Qcache_hits";
2800 +Variable_name  Value
2801 +Qcache_hits    23
2802 +select * from t1 -- comment in the end
2803 +;
2804 +a
2805 +1
2806 +2
2807 +3
2808 +select * from t1 -- comment in the end
2809 +;
2810 +a
2811 +1
2812 +2
2813 +3
2814 +show status like "Qcache_queries_in_cache";
2815 +Variable_name  Value
2816 +Qcache_queries_in_cache        20
2817 +show status like "Qcache_inserts";
2818 +Variable_name  Value
2819 +Qcache_inserts 20
2820 +show status like "Qcache_hits";
2821 +Variable_name  Value
2822 +Qcache_hits    25
2823 +-----------------------------------------------------
2824 +select */* a comment \*/from t1
2825 +-----------------------------------------------------
2826 +show status like "Qcache_queries_in_cache";
2827 +Variable_name  Value
2828 +Qcache_queries_in_cache        20
2829 +show status like "Qcache_inserts";
2830 +Variable_name  Value
2831 +Qcache_inserts 20
2832 +show status like "Qcache_hits";
2833 +Variable_name  Value
2834 +Qcache_hits    25
2835 +select */* a comment \*/from t1;
2836 +a
2837 +1
2838 +2
2839 +3
2840 +select */* a comment \*/from t1;
2841 +a
2842 +1
2843 +2
2844 +3
2845 +show status like "Qcache_queries_in_cache";
2846 +Variable_name  Value
2847 +Qcache_queries_in_cache        21
2848 +show status like "Qcache_inserts";
2849 +Variable_name  Value
2850 +Qcache_inserts 21
2851 +show status like "Qcache_hits";
2852 +Variable_name  Value
2853 +Qcache_hits    26
2854 +-----------------------------------------------------
2855 +select *# a comment \
2856 +from t1
2857 +-----------------------------------------------------
2858 +show status like "Qcache_queries_in_cache";
2859 +Variable_name  Value
2860 +Qcache_queries_in_cache        21
2861 +show status like "Qcache_inserts";
2862 +Variable_name  Value
2863 +Qcache_inserts 21
2864 +show status like "Qcache_hits";
2865 +Variable_name  Value
2866 +Qcache_hits    26
2867 +select *# a comment \
2868 +from t1;
2869 +a
2870 +1
2871 +2
2872 +3
2873 +select *# a comment \
2874 +from t1;
2875 +a
2876 +1
2877 +2
2878 +3
2879 +show status like "Qcache_queries_in_cache";
2880 +Variable_name  Value
2881 +Qcache_queries_in_cache        22
2882 +show status like "Qcache_inserts";
2883 +Variable_name  Value
2884 +Qcache_inserts 22
2885 +show status like "Qcache_hits";
2886 +Variable_name  Value
2887 +Qcache_hits    27
2888 +-----------------------------------------------------
2889 +select *-- a comment \
2890 +from t1
2891 +-----------------------------------------------------
2892 +show status like "Qcache_queries_in_cache";
2893 +Variable_name  Value
2894 +Qcache_queries_in_cache        22
2895 +show status like "Qcache_inserts";
2896 +Variable_name  Value
2897 +Qcache_inserts 22
2898 +show status like "Qcache_hits";
2899 +Variable_name  Value
2900 +Qcache_hits    27
2901 +select *-- a comment \
2902 +from t1;
2903 +a
2904 +1
2905 +2
2906 +3
2907 +select *-- a comment \
2908 +from t1;
2909 +a
2910 +1
2911 +2
2912 +3
2913 +show status like "Qcache_queries_in_cache";
2914 +Variable_name  Value
2915 +Qcache_queries_in_cache        23
2916 +show status like "Qcache_inserts";
2917 +Variable_name  Value
2918 +Qcache_inserts 23
2919 +show status like "Qcache_hits";
2920 +Variable_name  Value
2921 +Qcache_hits    28
2922 +-----------------------------------------------------
2923 +select "\\"" /* not a comment */" from t1
2924 +-----------------------------------------------------
2925 +show status like "Qcache_queries_in_cache";
2926 +Variable_name  Value
2927 +Qcache_queries_in_cache        23
2928 +show status like "Qcache_inserts";
2929 +Variable_name  Value
2930 +Qcache_inserts 23
2931 +show status like "Qcache_hits";
2932 +Variable_name  Value
2933 +Qcache_hits    28
2934 +select "\\"" /* not a comment */" from t1;
2935 +\" /* not a comment */
2936 +\" /* not a comment */
2937 +\" /* not a comment */
2938 +\" /* not a comment */
2939 +select "\\"" /* not a comment */" from t1;
2940 +\" /* not a comment */
2941 +\" /* not a comment */
2942 +\" /* not a comment */
2943 +\" /* not a comment */
2944 +show status like "Qcache_queries_in_cache";
2945 +Variable_name  Value
2946 +Qcache_queries_in_cache        24
2947 +show status like "Qcache_inserts";
2948 +Variable_name  Value
2949 +Qcache_inserts 24
2950 +show status like "Qcache_hits";
2951 +Variable_name  Value
2952 +Qcache_hits    29
2953 +-----------------------------------------------------
2954 +select "\\"" /*! not a comment */" from t1
2955 +-----------------------------------------------------
2956 +show status like "Qcache_queries_in_cache";
2957 +Variable_name  Value
2958 +Qcache_queries_in_cache        24
2959 +show status like "Qcache_inserts";
2960 +Variable_name  Value
2961 +Qcache_inserts 24
2962 +show status like "Qcache_hits";
2963 +Variable_name  Value
2964 +Qcache_hits    29
2965 +select "\\"" /*! not a comment */" from t1;
2966 +\" /*! not a comment */
2967 +\" /*! not a comment */
2968 +\" /*! not a comment */
2969 +\" /*! not a comment */
2970 +select "\\"" /*! not a comment */" from t1;
2971 +\" /*! not a comment */
2972 +\" /*! not a comment */
2973 +\" /*! not a comment */
2974 +\" /*! not a comment */
2975 +show status like "Qcache_queries_in_cache";
2976 +Variable_name  Value
2977 +Qcache_queries_in_cache        25
2978 +show status like "Qcache_inserts";
2979 +Variable_name  Value
2980 +Qcache_inserts 25
2981 +show status like "Qcache_hits";
2982 +Variable_name  Value
2983 +Qcache_hits    30
2984 +-----------------------------------------------------
2985 +select ' \'  ' from t1
2986 +-----------------------------------------------------
2987 +show status like "Qcache_queries_in_cache";
2988 +Variable_name  Value
2989 +Qcache_queries_in_cache        25
2990 +show status like "Qcache_inserts";
2991 +Variable_name  Value
2992 +Qcache_inserts 25
2993 +show status like "Qcache_hits";
2994 +Variable_name  Value
2995 +Qcache_hits    30
2996 +select ' \'  ' from t1;
2997 +'  
2998 + '  
2999 + '  
3000 + '  
3001 +select ' \'  ' from t1;
3002 +'  
3003 + '  
3004 + '  
3005 + '  
3006 +show status like "Qcache_queries_in_cache";
3007 +Variable_name  Value
3008 +Qcache_queries_in_cache        26
3009 +show status like "Qcache_inserts";
3010 +Variable_name  Value
3011 +Qcache_inserts 26
3012 +show status like "Qcache_hits";
3013 +Variable_name  Value
3014 +Qcache_hits    31
3015 +-----------------------------------------------------
3016 +select ' \' /* comment inside quotes with internal backslash quote */' from t1
3017 +-----------------------------------------------------
3018 +show status like "Qcache_queries_in_cache";
3019 +Variable_name  Value
3020 +Qcache_queries_in_cache        26
3021 +show status like "Qcache_inserts";
3022 +Variable_name  Value
3023 +Qcache_inserts 26
3024 +show status like "Qcache_hits";
3025 +Variable_name  Value
3026 +Qcache_hits    31
3027 +select ' \' /* comment inside quotes with internal backslash quote */' from t1;
3028 +' /* comment inside quotes with internal backslash quote */
3029 + ' /* comment inside quotes with internal backslash quote */
3030 + ' /* comment inside quotes with internal backslash quote */
3031 + ' /* comment inside quotes with internal backslash quote */
3032 +select ' \' /* comment inside quotes with internal backslash quote */' from t1;
3033 +' /* comment inside quotes with internal backslash quote */
3034 + ' /* comment inside quotes with internal backslash quote */
3035 + ' /* comment inside quotes with internal backslash quote */
3036 + ' /* comment inside quotes with internal backslash quote */
3037 +show status like "Qcache_queries_in_cache";
3038 +Variable_name  Value
3039 +Qcache_queries_in_cache        27
3040 +show status like "Qcache_inserts";
3041 +Variable_name  Value
3042 +Qcache_inserts 27
3043 +show status like "Qcache_hits";
3044 +Variable_name  Value
3045 +Qcache_hits    32
3046 +DROP TABLE t1;
3047 +SET GLOBAL query_cache_size=default;
3048 +set global query_cache_strip_comments=OFF;
3049 --- /dev/null
3050 +++ b/mysql-test/r/percona_query_cache_with_comments_prepared_statements.result
3051 @@ -0,0 +1,396 @@
3052 +set GLOBAL query_cache_size=1355776;
3053 +flush query cache;
3054 +flush query cache;
3055 +reset query cache;
3056 +flush status;
3057 +drop table if exists t1;
3058 +create table t1 (a int not null);
3059 +insert into t1 values (1),(2),(3);
3060 +set global query_cache_strip_comments=ON;
3061 +show status like "Qcache_queries_in_cache";
3062 +Variable_name  Value
3063 +Qcache_queries_in_cache        0
3064 +show status like "Qcache_inserts";
3065 +Variable_name  Value
3066 +Qcache_inserts 0
3067 +show status like "Qcache_hits";
3068 +Variable_name  Value
3069 +Qcache_hits    0
3070 +prepare stmt from '/* with comment */ select * from t1';
3071 +execute stmt;
3072 +a
3073 +1
3074 +2
3075 +3
3076 +show status like "Qcache_queries_in_cache";
3077 +Variable_name  Value
3078 +Qcache_queries_in_cache        1
3079 +show status like "Qcache_inserts";
3080 +Variable_name  Value
3081 +Qcache_inserts 1
3082 +show status like "Qcache_hits";
3083 +Variable_name  Value
3084 +Qcache_hits    0
3085 +execute stmt;
3086 +a
3087 +1
3088 +2
3089 +3
3090 +execute stmt;
3091 +a
3092 +1
3093 +2
3094 +3
3095 +execute stmt;
3096 +a
3097 +1
3098 +2
3099 +3
3100 +execute stmt;
3101 +a
3102 +1
3103 +2
3104 +3
3105 +execute stmt;
3106 +a
3107 +1
3108 +2
3109 +3
3110 +show status like "Qcache_queries_in_cache";
3111 +Variable_name  Value
3112 +Qcache_queries_in_cache        1
3113 +show status like "Qcache_inserts";
3114 +Variable_name  Value
3115 +Qcache_inserts 1
3116 +show status like "Qcache_hits";
3117 +Variable_name  Value
3118 +Qcache_hits    5
3119 +prepare stmt from 'select * from t1';
3120 +execute stmt;
3121 +a
3122 +1
3123 +2
3124 +3
3125 +show status like "Qcache_queries_in_cache";
3126 +Variable_name  Value
3127 +Qcache_queries_in_cache        1
3128 +show status like "Qcache_inserts";
3129 +Variable_name  Value
3130 +Qcache_inserts 1
3131 +show status like "Qcache_hits";
3132 +Variable_name  Value
3133 +Qcache_hits    6
3134 +prepare stmt from 'select * /*internal comment*/from t1';
3135 +execute stmt;
3136 +a
3137 +1
3138 +2
3139 +3
3140 +show status like "Qcache_queries_in_cache";
3141 +Variable_name  Value
3142 +Qcache_queries_in_cache        1
3143 +show status like "Qcache_inserts";
3144 +Variable_name  Value
3145 +Qcache_inserts 1
3146 +show status like "Qcache_hits";
3147 +Variable_name  Value
3148 +Qcache_hits    7
3149 +prepare stmt from 'select * /*internal comment*/ from t1';
3150 +execute stmt;
3151 +a
3152 +1
3153 +2
3154 +3
3155 +show status like "Qcache_queries_in_cache";
3156 +Variable_name  Value
3157 +Qcache_queries_in_cache        1
3158 +show status like "Qcache_inserts";
3159 +Variable_name  Value
3160 +Qcache_inserts 1
3161 +show status like "Qcache_hits";
3162 +Variable_name  Value
3163 +Qcache_hits    8
3164 +prepare stmt from 'select * from t1 /* at the end */';
3165 +execute stmt;
3166 +a
3167 +1
3168 +2
3169 +3
3170 +show status like "Qcache_queries_in_cache";
3171 +Variable_name  Value
3172 +Qcache_queries_in_cache        1
3173 +show status like "Qcache_inserts";
3174 +Variable_name  Value
3175 +Qcache_inserts 1
3176 +show status like "Qcache_hits";
3177 +Variable_name  Value
3178 +Qcache_hits    9
3179 +prepare stmt from 'select * from t1 /* with "quote" */';
3180 +execute stmt;
3181 +a
3182 +1
3183 +2
3184 +3
3185 +show status like "Qcache_queries_in_cache";
3186 +Variable_name  Value
3187 +Qcache_queries_in_cache        1
3188 +show status like "Qcache_inserts";
3189 +Variable_name  Value
3190 +Qcache_inserts 1
3191 +show status like "Qcache_hits";
3192 +Variable_name  Value
3193 +Qcache_hits    10
3194 +prepare stmt from 'select * from t1 /* with \'quote\' */';
3195 +execute stmt;
3196 +a
3197 +1
3198 +2
3199 +3
3200 +show status like "Qcache_queries_in_cache";
3201 +Variable_name  Value
3202 +Qcache_queries_in_cache        1
3203 +show status like "Qcache_inserts";
3204 +Variable_name  Value
3205 +Qcache_inserts 1
3206 +show status like "Qcache_hits";
3207 +Variable_name  Value
3208 +Qcache_hits    11
3209 +prepare stmt from 'select * from t1 # 123
3210 +';
3211 +execute stmt;
3212 +a
3213 +1
3214 +2
3215 +3
3216 +show status like "Qcache_queries_in_cache";
3217 +Variable_name  Value
3218 +Qcache_queries_in_cache        1
3219 +show status like "Qcache_inserts";
3220 +Variable_name  Value
3221 +Qcache_inserts 1
3222 +show status like "Qcache_hits";
3223 +Variable_name  Value
3224 +Qcache_hits    12
3225 +prepare stmt from 'select * from t1 # 123 with "quote"
3226 +';
3227 +execute stmt;
3228 +a
3229 +1
3230 +2
3231 +3
3232 +show status like "Qcache_queries_in_cache";
3233 +Variable_name  Value
3234 +Qcache_queries_in_cache        1
3235 +show status like "Qcache_inserts";
3236 +Variable_name  Value
3237 +Qcache_inserts 1
3238 +show status like "Qcache_hits";
3239 +Variable_name  Value
3240 +Qcache_hits    13
3241 +prepare stmt from 'select * from t1 # 123 with \'quote\'
3242 +';
3243 +execute stmt;
3244 +a
3245 +1
3246 +2
3247 +3
3248 +show status like "Qcache_queries_in_cache";
3249 +Variable_name  Value
3250 +Qcache_queries_in_cache        1
3251 +show status like "Qcache_inserts";
3252 +Variable_name  Value
3253 +Qcache_inserts 1
3254 +show status like "Qcache_hits";
3255 +Variable_name  Value
3256 +Qcache_hits    14
3257 +prepare stmt from 'select * from t1
3258 +# 123
3259 +';
3260 +execute stmt;
3261 +a
3262 +1
3263 +2
3264 +3
3265 +show status like "Qcache_queries_in_cache";
3266 +Variable_name  Value
3267 +Qcache_queries_in_cache        1
3268 +show status like "Qcache_inserts";
3269 +Variable_name  Value
3270 +Qcache_inserts 1
3271 +show status like "Qcache_hits";
3272 +Variable_name  Value
3273 +Qcache_hits    15
3274 +prepare stmt from '#456
3275 +select * from t1
3276 +# 123
3277 +';
3278 +execute stmt;
3279 +a
3280 +1
3281 +2
3282 +3
3283 +show status like "Qcache_queries_in_cache";
3284 +Variable_name  Value
3285 +Qcache_queries_in_cache        1
3286 +show status like "Qcache_inserts";
3287 +Variable_name  Value
3288 +Qcache_inserts 1
3289 +show status like "Qcache_hits";
3290 +Variable_name  Value
3291 +Qcache_hits    16
3292 +prepare stmt from 'select * from t1 -- 123
3293 +';
3294 +execute stmt;
3295 +a
3296 +1
3297 +2
3298 +3
3299 +show status like "Qcache_queries_in_cache";
3300 +Variable_name  Value
3301 +Qcache_queries_in_cache        1
3302 +show status like "Qcache_inserts";
3303 +Variable_name  Value
3304 +Qcache_inserts 1
3305 +show status like "Qcache_hits";
3306 +Variable_name  Value
3307 +Qcache_hits    17
3308 +prepare stmt from 'select * from t1
3309 +-- 123
3310 +';
3311 +execute stmt;
3312 +a
3313 +1
3314 +2
3315 +3
3316 +show status like "Qcache_queries_in_cache";
3317 +Variable_name  Value
3318 +Qcache_queries_in_cache        1
3319 +show status like "Qcache_inserts";
3320 +Variable_name  Value
3321 +Qcache_inserts 1
3322 +show status like "Qcache_hits";
3323 +Variable_name  Value
3324 +Qcache_hits    18
3325 +prepare stmt from '-- comment in first
3326 +select * from t1
3327 +# 123
3328 +';
3329 +execute stmt;
3330 +a
3331 +1
3332 +2
3333 +3
3334 +show status like "Qcache_queries_in_cache";
3335 +Variable_name  Value
3336 +Qcache_queries_in_cache        1
3337 +show status like "Qcache_inserts";
3338 +Variable_name  Value
3339 +Qcache_inserts 1
3340 +show status like "Qcache_hits";
3341 +Variable_name  Value
3342 +Qcache_hits    19
3343 +prepare stmt from '(#456(
3344 +select * from t1
3345 +# 123(
3346 +)';
3347 +execute stmt;
3348 +a
3349 +1
3350 +2
3351 +3
3352 +show status like "Qcache_queries_in_cache";
3353 +Variable_name  Value
3354 +Qcache_queries_in_cache        2
3355 +show status like "Qcache_inserts";
3356 +Variable_name  Value
3357 +Qcache_inserts 2
3358 +show status like "Qcache_hits";
3359 +Variable_name  Value
3360 +Qcache_hits    19
3361 +prepare stmt from '/*test*/(-- comment in first(
3362 +select * from t1
3363 +-- 123 asdasd
3364 +/* test */)';
3365 +execute stmt;
3366 +a
3367 +1
3368 +2
3369 +3
3370 +show status like "Qcache_queries_in_cache";
3371 +Variable_name  Value
3372 +Qcache_queries_in_cache        2
3373 +show status like "Qcache_inserts";
3374 +Variable_name  Value
3375 +Qcache_inserts 2
3376 +show status like "Qcache_hits";
3377 +Variable_name  Value
3378 +Qcache_hits    20
3379 +prepare stmt from 'select "test",a from t1';
3380 +execute stmt;
3381 +test   a
3382 +test   1
3383 +test   2
3384 +test   3
3385 +execute stmt;
3386 +test   a
3387 +test   1
3388 +test   2
3389 +test   3
3390 +show status like "Qcache_queries_in_cache";
3391 +Variable_name  Value
3392 +Qcache_queries_in_cache        3
3393 +show status like "Qcache_inserts";
3394 +Variable_name  Value
3395 +Qcache_inserts 3
3396 +show status like "Qcache_hits";
3397 +Variable_name  Value
3398 +Qcache_hits    21
3399 +prepare stmt from 'select "test /* internal \'comment\' */",a from t1';
3400 +execute stmt;
3401 +test /* internal 'comment' */  a
3402 +test /* internal 'comment' */  1
3403 +test /* internal 'comment' */  2
3404 +test /* internal 'comment' */  3
3405 +show status like "Qcache_queries_in_cache";
3406 +Variable_name  Value
3407 +Qcache_queries_in_cache        4
3408 +show status like "Qcache_inserts";
3409 +Variable_name  Value
3410 +Qcache_inserts 4
3411 +show status like "Qcache_hits";
3412 +Variable_name  Value
3413 +Qcache_hits    21
3414 +prepare stmt from 'select "test #internal comment" ,a from t1';
3415 +execute stmt;
3416 +test #internal comment a
3417 +test #internal comment 1
3418 +test #internal comment 2
3419 +test #internal comment 3
3420 +show status like "Qcache_queries_in_cache";
3421 +Variable_name  Value
3422 +Qcache_queries_in_cache        5
3423 +show status like "Qcache_inserts";
3424 +Variable_name  Value
3425 +Qcache_inserts 5
3426 +show status like "Qcache_hits";
3427 +Variable_name  Value
3428 +Qcache_hits    21
3429 +prepare stmt from 'select "test #internal comment" #external comment
3430 +,a from t1';
3431 +execute stmt;
3432 +test #internal comment a
3433 +test #internal comment 1
3434 +test #internal comment 2
3435 +test #internal comment 3
3436 +show status like "Qcache_queries_in_cache";
3437 +Variable_name  Value
3438 +Qcache_queries_in_cache        5
3439 +show status like "Qcache_inserts";
3440 +Variable_name  Value
3441 +Qcache_inserts 5
3442 +show status like "Qcache_hits";
3443 +Variable_name  Value
3444 +Qcache_hits    22
3445 +DROP TABLE t1;
3446 +SET GLOBAL query_cache_size= default;
3447 +set global query_cache_strip_comments=OFF;
3448 --- /dev/null
3449 +++ b/mysql-test/t/percona_query_cache_with_comments.test
3450 @@ -0,0 +1,5 @@
3451 +--disable_ps_protocol
3452 +set global query_cache_strip_comments=ON;
3453 +-- source include/percona_query_cache_with_comments_begin.inc
3454 +-- source include/percona_query_cache_with_comments.inc
3455 +-- source include/percona_query_cache_with_comments_end.inc
3456 --- /dev/null
3457 +++ b/mysql-test/t/percona_query_cache_with_comments_crash.test
3458 @@ -0,0 +1,22 @@
3459 +-- source include/have_query_cache.inc
3460 +set GLOBAL query_cache_size=1355776;
3461 +--disable_warnings
3462 +drop table if exists t1;
3463 +--enable_warnings
3464 +create table t1 (a int not null);
3465 +insert into t1 values (1),(2),(3);
3466 +flush query cache; # This crashed in some versions
3467 +flush query cache; # This crashed in some versions
3468 +reset query cache;
3469 +flush status;
3470 +( select * from t1 );
3471 +/*!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 */;
3472 +/* only comment */;
3473 +let query=# only comment
3474 +;
3475 +eval $query;
3476 +let query=-- only comment
3477 +;
3478 +eval $query;
3479 +DROP TABLE t1;
3480 +SET GLOBAL query_cache_size= default;
3481 --- /dev/null
3482 +++ b/mysql-test/t/percona_query_cache_with_comments_disable.test
3483 @@ -0,0 +1,3 @@
3484 +-- source include/percona_query_cache_with_comments_begin.inc
3485 +-- source include/percona_query_cache_with_comments.inc
3486 +-- source include/percona_query_cache_with_comments_end.inc
3487 --- /dev/null
3488 +++ b/mysql-test/t/percona_query_cache_with_comments_prepared_statements.test
3489 @@ -0,0 +1,208 @@
3490 +-- source include/have_query_cache.inc
3491 +
3492 +set GLOBAL query_cache_size=1355776;
3493 +
3494 +# Reset query cache variables.
3495 +flush query cache; # This crashed in some versions
3496 +flush query cache; # This crashed in some versions
3497 +reset query cache;
3498 +flush status;
3499 +--disable_warnings
3500 +drop table if exists t1;
3501 +--enable_warnings
3502 +
3503 +#
3504 +# First simple test
3505 +#
3506 +
3507 +create table t1 (a int not null);
3508 +insert into t1 values (1),(2),(3);
3509 +
3510 +set global query_cache_strip_comments=ON;
3511 +
3512 +show status like "Qcache_queries_in_cache";
3513 +show status like "Qcache_inserts";
3514 +show status like "Qcache_hits";
3515 +
3516 +prepare stmt from '/* with comment */ select * from t1';
3517 +execute stmt;
3518 +
3519 +show status like "Qcache_queries_in_cache";
3520 +show status like "Qcache_inserts";
3521 +show status like "Qcache_hits";
3522 +
3523 +execute stmt;
3524 +execute stmt;
3525 +execute stmt;
3526 +execute stmt;
3527 +execute stmt;
3528 +
3529 +show status like "Qcache_queries_in_cache";
3530 +show status like "Qcache_inserts";
3531 +show status like "Qcache_hits";
3532 +
3533 +prepare stmt from 'select * from t1';
3534 +execute stmt;
3535 +
3536 +show status like "Qcache_queries_in_cache";
3537 +show status like "Qcache_inserts";
3538 +show status like "Qcache_hits";
3539 +
3540 +prepare stmt from 'select * /*internal comment*/from t1';
3541 +execute stmt;
3542 +
3543 +show status like "Qcache_queries_in_cache";
3544 +show status like "Qcache_inserts";
3545 +show status like "Qcache_hits";
3546 +
3547 +prepare stmt from 'select * /*internal comment*/ from t1';
3548 +execute stmt;
3549 +
3550 +show status like "Qcache_queries_in_cache";
3551 +show status like "Qcache_inserts";
3552 +show status like "Qcache_hits";
3553 +
3554 +prepare stmt from 'select * from t1 /* at the end */';
3555 +execute stmt;
3556 +
3557 +show status like "Qcache_queries_in_cache";
3558 +show status like "Qcache_inserts";
3559 +show status like "Qcache_hits";
3560 +
3561 +prepare stmt from 'select * from t1 /* with "quote" */';
3562 +execute stmt;
3563 +
3564 +show status like "Qcache_queries_in_cache";
3565 +show status like "Qcache_inserts";
3566 +show status like "Qcache_hits";
3567 +
3568 +prepare stmt from 'select * from t1 /* with \'quote\' */';
3569 +execute stmt;
3570 +
3571 +show status like "Qcache_queries_in_cache";
3572 +show status like "Qcache_inserts";
3573 +show status like "Qcache_hits";
3574 +
3575 +prepare stmt from 'select * from t1 # 123
3576 +';
3577 +execute stmt;
3578 +
3579 +show status like "Qcache_queries_in_cache";
3580 +show status like "Qcache_inserts";
3581 +show status like "Qcache_hits";
3582 +
3583 +prepare stmt from 'select * from t1 # 123 with "quote"
3584 +';
3585 +execute stmt;
3586 +
3587 +show status like "Qcache_queries_in_cache";
3588 +show status like "Qcache_inserts";
3589 +show status like "Qcache_hits";
3590 +
3591 +prepare stmt from 'select * from t1 # 123 with \'quote\'
3592 +';
3593 +execute stmt;
3594 +
3595 +show status like "Qcache_queries_in_cache";
3596 +show status like "Qcache_inserts";
3597 +show status like "Qcache_hits";
3598 +
3599 +prepare stmt from 'select * from t1
3600 +# 123
3601 +';
3602 +execute stmt;
3603 +
3604 +show status like "Qcache_queries_in_cache";
3605 +show status like "Qcache_inserts";
3606 +show status like "Qcache_hits";
3607 +
3608 +prepare stmt from '#456
3609 +select * from t1
3610 +# 123
3611 +';
3612 +execute stmt;
3613 +
3614 +show status like "Qcache_queries_in_cache";
3615 +show status like "Qcache_inserts";
3616 +show status like "Qcache_hits";
3617 +
3618 +prepare stmt from 'select * from t1 -- 123
3619 +';
3620 +execute stmt;
3621 +
3622 +show status like "Qcache_queries_in_cache";
3623 +show status like "Qcache_inserts";
3624 +show status like "Qcache_hits";
3625 +
3626 +prepare stmt from 'select * from t1
3627 +-- 123
3628 +';
3629 +execute stmt;
3630 +
3631 +show status like "Qcache_queries_in_cache";
3632 +show status like "Qcache_inserts";
3633 +show status like "Qcache_hits";
3634 +
3635 +prepare stmt from '-- comment in first
3636 +select * from t1
3637 +# 123
3638 +';
3639 +execute stmt;
3640 +
3641 +show status like "Qcache_queries_in_cache";
3642 +show status like "Qcache_inserts";
3643 +show status like "Qcache_hits";
3644 +
3645 +prepare stmt from '(#456(
3646 +select * from t1
3647 +# 123(
3648 +)';
3649 +execute stmt;
3650 +
3651 +show status like "Qcache_queries_in_cache";
3652 +show status like "Qcache_inserts";
3653 +show status like "Qcache_hits";
3654 +
3655 +prepare stmt from '/*test*/(-- comment in first(
3656 +select * from t1
3657 +-- 123 asdasd
3658 +/* test */)';
3659 +execute stmt;
3660 +
3661 +show status like "Qcache_queries_in_cache";
3662 +show status like "Qcache_inserts";
3663 +show status like "Qcache_hits";
3664 +
3665 +prepare stmt from 'select "test",a from t1';
3666 +execute stmt;
3667 +execute stmt;
3668 +
3669 +show status like "Qcache_queries_in_cache";
3670 +show status like "Qcache_inserts";
3671 +show status like "Qcache_hits";
3672 +
3673 +prepare stmt from 'select "test /* internal \'comment\' */",a from t1';
3674 +execute stmt;
3675 +
3676 +show status like "Qcache_queries_in_cache";
3677 +show status like "Qcache_inserts";
3678 +show status like "Qcache_hits";
3679 +
3680 +prepare stmt from 'select "test #internal comment" ,a from t1';
3681 +execute stmt;
3682 +
3683 +show status like "Qcache_queries_in_cache";
3684 +show status like "Qcache_inserts";
3685 +show status like "Qcache_hits";
3686 +
3687 +prepare stmt from 'select "test #internal comment" #external comment
3688 +,a from t1';
3689 +execute stmt;
3690 +
3691 +show status like "Qcache_queries_in_cache";
3692 +show status like "Qcache_inserts";
3693 +show status like "Qcache_hits";
3694 +
3695 +DROP TABLE t1;
3696 +SET GLOBAL query_cache_size= default;
3697 +set global query_cache_strip_comments=OFF;
3698 --- /dev/null
3699 +++ b/mysql-test/t/percona_status_wait_query_cache_mutex.test
3700 @@ -0,0 +1,35 @@
3701 +--source include/have_query_cache.inc
3702 +--source include/have_debug.inc
3703 +--source include/have_debug_sync.inc
3704 +SET GLOBAL query_cache_size=1355776;
3705 +--source include/percona_query_cache_with_comments_clear.inc
3706 +--let try_lock_mutex_query=SELECT "try_lock_mutex_query" as action
3707 +
3708 +--connect (mutex_locked_conn, localhost, root,,)
3709 +--connect (try_mutex_lock_conn, localhost, root,,)
3710 +
3711 +--connection mutex_locked_conn
3712 +SET DEBUG_SYNC='after_query_cache_mutex SIGNAL mutex_locked WAIT_FOR unlock_mutex';
3713 +send SELECT "mutex_locked_query" as action;
3714 +
3715 +--connection default
3716 +SET DEBUG_SYNC='now WAIT_FOR mutex_locked';
3717 +
3718 +--connection try_mutex_lock_conn
3719 +SET DEBUG_SYNC='before_query_cache_mutex SIGNAL try_lock_mutex';
3720 +send_eval $try_lock_mutex_query;
3721 +
3722 +--connection default
3723 +SET DEBUG_SYNC='now WAIT_FOR try_lock_mutex';
3724 +eval SELECT SQL_NO_CACHE state FROM INFORMATION_SCHEMA.PROCESSLIST WHERE info='$try_lock_mutex_query';
3725 +SET DEBUG_SYNC='now SIGNAL unlock_mutex';
3726 +
3727 +--connection mutex_locked_conn
3728 +reap;
3729 +--connection try_mutex_lock_conn
3730 +reap;
3731 +
3732 +--connection default
3733 +--disconnect mutex_locked_conn
3734 +--disconnect try_mutex_lock_conn
3735 +SET GLOBAL query_cache_size=0;
3736 --- a/mysql-test/r/mysqld--help-notwin.result
3737 +++ b/mysql-test/r/mysqld--help-notwin.result
3738 @@ -493,6 +493,10 @@
3739   The minimum size for blocks allocated by the query cache
3740   --query-cache-size=# 
3741   The memory allocated to store results from old queries
3742 + --query-cache-strip-comments 
3743 + Enable and disable optimisation "strip comment for query
3744 + cache" - optimisation strip all comments from query while
3745 + search query result in query cache
3746   --query-cache-type=name 
3747   OFF = Don't cache or retrieve results. ON = Cache all
3748   results except SELECT SQL_NO_CACHE ... queries. DEMAND =
3749 @@ -931,6 +935,7 @@
3750  query-cache-limit 1048576
3751  query-cache-min-res-unit 4096
3752  query-cache-size 0
3753 +query-cache-strip-comments FALSE
3754  query-cache-type ON
3755  query-cache-wlock-invalidate FALSE
3756  query-prealloc-size 8192
3757 --- /dev/null
3758 +++ b/mysql-test/r/percona_status_wait_query_cache_mutex.result
3759 @@ -0,0 +1,20 @@
3760 +SET GLOBAL query_cache_size=1355776;
3761 +flush query cache;
3762 +flush query cache;
3763 +reset query cache;
3764 +flush status;
3765 +SET DEBUG_SYNC='after_query_cache_mutex SIGNAL mutex_locked WAIT_FOR unlock_mutex';
3766 +SELECT "mutex_locked_query" as action;
3767 +SET DEBUG_SYNC='now WAIT_FOR mutex_locked';
3768 +SET DEBUG_SYNC='before_query_cache_mutex SIGNAL try_lock_mutex';
3769 +SELECT "try_lock_mutex_query" as action;
3770 +SET DEBUG_SYNC='now WAIT_FOR try_lock_mutex';
3771 +SELECT SQL_NO_CACHE state FROM INFORMATION_SCHEMA.PROCESSLIST WHERE info='SELECT "try_lock_mutex_query" as action';
3772 +state
3773 +Waiting on query cache mutex
3774 +SET DEBUG_SYNC='now SIGNAL unlock_mutex';
3775 +action
3776 +mutex_locked_query
3777 +action
3778 +try_lock_mutex_query
3779 +SET GLOBAL query_cache_size=0;
3780 --- /dev/null
3781 +++ b/mysql-test/r/percona_query_cache_with_comments_crash_2.result
3782 @@ -0,0 +1,8 @@
3783 +DROP TABLE IF EXISTS table17_int;
3784 +DROP TABLE IF EXISTS table30_int;
3785 +CREATE TABLE `table17_int` (pk integer auto_increment primary key, `col_char_10_not_null_key` char(10), `col_enum_not_null_key` int);
3786 +CREATE TABLE `table30_int` (pk integer auto_increment primary key, `col_enum_not_null_key` int);
3787 +SELECT X . `pk` FROM `table17_int` AS X LEFT JOIN `table30_int` AS Y USING ( `col_enum_not_null_key` ) WHERE X . `col_char_10_not_null_key` != '   you need to translate Views labels into other languages, consider installing the <a href=\" !path\">Internationalization</a> package\'s Views translation module.' LIMIT 7  /*Generated by THREAD_ID 1*/;
3788 +pk
3789 +DROP TABLE table17_int;
3790 +DROP TABLE table30_int;
3791 --- /dev/null
3792 +++ b/mysql-test/t/percona_query_cache_with_comments_crash_2-master.opt
3793 @@ -0,0 +1 @@
3794 +--query-cache-size=10M --query-cache-strip-comments
3795 --- /dev/null
3796 +++ b/mysql-test/t/percona_query_cache_with_comments_crash_2.test
3797 @@ -0,0 +1,9 @@
3798 +--disable_warnings
3799 +DROP TABLE IF EXISTS table17_int;
3800 +DROP TABLE IF EXISTS table30_int;
3801 +--enable_warnings
3802 +CREATE TABLE `table17_int` (pk integer auto_increment primary key, `col_char_10_not_null_key` char(10), `col_enum_not_null_key` int);
3803 +CREATE TABLE `table30_int` (pk integer auto_increment primary key, `col_enum_not_null_key` int);
3804 +SELECT X . `pk` FROM `table17_int` AS X LEFT JOIN `table30_int` AS Y USING ( `col_enum_not_null_key` ) WHERE X . `col_char_10_not_null_key` != '   you need to translate Views labels into other languages, consider installing the <a href=\" !path\">Internationalization</a> package\'s Views translation module.' LIMIT 7  /*Generated by THREAD_ID 1*/;
3805 +DROP TABLE table17_int;
3806 +DROP TABLE table30_int;
3807 --- a/sql/sql_class.cc
3808 +++ b/sql/sql_class.cc
3809 @@ -807,6 +807,99 @@
3810            sql_errno == ER_TRG_NO_DEFINER);
3811  }
3812  
3813 +#ifdef HAVE_QUERY_CACHE
3814 +
3815 +
3816 +Query_Without_Comments::Query_Without_Comments() :
3817 +  buffer(0),
3818 +  q_length(0),
3819 +  b_length(0)
3820 +{
3821 +}
3822 +
3823 +
3824 +Query_Without_Comments::~Query_Without_Comments()
3825 +{
3826 +  if(buffer)
3827 +  {
3828 +    my_free(buffer);
3829 +  }
3830 +}
3831 +
3832 +
3833 +bool Query_Without_Comments::allocate(size_t query_length, size_t db_length)
3834 +{
3835 +  DBUG_ENTER("Query_Without_Comments::allocate");
3836 +  DBUG_PRINT("info", ("old buffer: %p "
3837 +                      "old query: '%-.4096s' "
3838 +                      "old buffer length: %u "
3839 +                      "old query length: %u",
3840 +                      buffer,
3841 +                      buffer,
3842 +                      (uint) b_length,
3843 +                      (uint) q_length));
3844 +  /* save maximum query length for check in the set_length */
3845 +  q_length= query_length;
3846 +  /* according to sql_parse.cc memory allocation */
3847 +  size_t new_b_length= (query_length + 1) + sizeof(size_t) + db_length +
3848 +    QUERY_CACHE_FLAGS_SIZE;
3849 +  if (b_length < new_b_length)
3850 +  {
3851 +    b_length= new_b_length;
3852 +    if (buffer)
3853 +    {
3854 +      buffer= (char*) my_realloc(buffer, b_length, MYF(0));
3855 +    }
3856 +    else
3857 +    {
3858 +      buffer= (char *) my_malloc(b_length, MYF(0));
3859 +    }
3860 +  }
3861 +  buffer[0]= 0;
3862 +  DBUG_PRINT("info", ("buffer: %p "
3863 +                      "buffer length: %u "
3864 +                      "query maximum length: %u",
3865 +                      buffer,
3866 +                      (uint) b_length,
3867 +                      (uint) q_length));
3868 +  DBUG_RETURN(buffer);
3869 +}
3870 +
3871 +
3872 +void Query_Without_Comments::set_length(size_t query_length)
3873 +{
3874 +  DBUG_ENTER("Query_Without_Comments::set_length");
3875 +  DBUG_ASSERT(query_length <= q_length);
3876 +  buffer[query_length]= 0;
3877 +  DBUG_PRINT("info", ("buffer: %p "
3878 +                      "query: '%-.4096s' "
3879 +                      "buffer length: %u "
3880 +                      "query maximum length: %u "
3881 +                      "query length: %u",
3882 +                      buffer,
3883 +                      buffer,
3884 +                      (uint) b_length,
3885 +                      (uint) q_length,
3886 +                      (uint) query_length));
3887 +  q_length= query_length;
3888 +  DBUG_VOID_RETURN;
3889 +}
3890 +
3891 +
3892 +char* Query_Without_Comments::query()
3893 +{
3894 +  return buffer;
3895 +}
3896 +
3897 +
3898 +size_t Query_Without_Comments::length()
3899 +{
3900 +  return q_length;
3901 +}
3902 +
3903 +
3904 +#endif // HAVE_QUERY_CACHE
3905 +
3906  
3907  THD::THD()
3908     :Statement(&main_lex, &main_mem_root, STMT_CONVENTIONAL_EXECUTION,
This page took 0.315398 seconds and 3 git commands to generate.