1 # name : query_cache_with_comments.patch
2 # introduced : 11 or before
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
9 +++ b/patch_info/query_cache_enhance.patch
11 +File=query_cache_enhance.patch
12 +Name= query cache Percona's cumulative patch
14 +Author=Percona <info@percona.com>
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
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;
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;
47 +++ b/sql/query_strip_comments.h
49 +#ifndef _SQL_QUERY_STRIPC_COMMENTS_H_
50 +#define _SQL_QUERY_STRIPC_COMMENTS_H_
51 +#ifdef HAVE_QUERY_CACHE
53 +// implemented in sql_cache.cc
54 +class QueryStripComments
57 + QueryStripComments(const QueryStripComments&);
58 + QueryStripComments& operator=(const QueryStripComments&);
60 + QueryStripComments();
61 + ~QueryStripComments();
62 + void set(const char* a_query, uint a_query_length, uint a_additional_length);
64 + char* query() { return buffer; }
65 + uint query_length() { return length; }
70 + uint length /*query length, not buffer length*/;
73 +class QueryStripComments_Backup
76 + QueryStripComments_Backup(THD* a_thd,QueryStripComments* qsc);
77 + ~QueryStripComments_Backup();
84 +#endif // HAVE_QUERY_CACHE
85 +#endif // _SQL_QUERY_STRIPC_COMMENTS_H_
86 --- a/sql/sql_cache.cc
87 +++ b/sql/sql_cache.cc
89 #include "probes_mysql.h"
90 #include "transaction.h"
92 +#include "query_strip_comments.h"
95 + Number of bytes to be allocated in a query cache buffer in addition to the
96 + query string length.
98 + The query buffer layout is:
101 + <statement> The input statement(s)
102 + '\0' Terminating null char
103 + <db_length> Length of following current database name (size_t)
104 + <db_name> Name of current database
105 + <flags> Flags struct
107 +#define QUERY_BUFFER_ADDITIONAL_LENGTH(db_length) \
108 + (1 + sizeof(size_t) + db_length + QUERY_CACHE_FLAGS_SIZE)
110 +QueryStripComments::QueryStripComments()
116 +QueryStripComments::~QueryStripComments()
121 +inline bool query_strip_comments_is_white_space(char c)
123 + return ((' ' == c) || ('\t' == c) || ('\r' == c) || ('\n' ==c ));
125 +void QueryStripComments::set(const char* query, uint query_length, uint additional_length)
127 + uint new_buffer_length = query_length + additional_length;
128 + if(new_buffer_length > buffer_length)
131 + buffer = (char*)my_malloc(new_buffer_length,MYF(0));
133 + uint query_position = 0;
135 + // Skip whitespaces from begin
136 + while((query_position < query_length) && query_strip_comments_is_white_space(query[query_position]))
140 + long int last_space = -1;
141 + while(query_position < query_length)
143 + char current = query[query_position];
144 + bool insert_space = false; // insert space to buffer, (IMPORTANT) don't update query_position
150 + buffer[position++] = query[query_position++]; // copy current symbol
151 + while(query_position < query_length)
153 + if(current == query[query_position]) // found pair quote
157 + buffer[position++] = query[query_position++]; // copy current symbol
163 + if(((query_position + 2) < query_length) && ('*' == query[query_position+1]) && ('!' != query[query_position+2]))
165 + query_position += 2; // skip "/*"
168 + if('*' == query[query_position] && '/' == query[query_position+1]) // check for "*/"
170 + query_position += 2; // skip "*/"
171 + insert_space = true;
179 + while(query_position < query_length);
189 + if(query[query_position+1] == '-')
191 + ++query_position; // skip "-", and go to search of "\n"
202 + ++query_position; // skip current symbol (# or -)
203 + if('\n' == query[query_position]) // check for '\n'
205 + ++query_position; // skip '\n'
206 + insert_space = true;
210 + while(query_position < query_length);
221 + if(query_strip_comments_is_white_space(current))
223 + insert_space = true;
226 + break; // make gcc happy
230 + if((uint) (last_space + 1) != position)
232 + last_space = position;
233 + buffer[position++] = ' ';
236 + else if (query_position < query_length)
238 + buffer[position++] = query[query_position++];
241 + while((0 < position) && query_strip_comments_is_white_space(buffer[position - 1]))
245 + buffer[position] = 0;
248 +void QueryStripComments::cleanup()
258 +QueryStripComments_Backup::QueryStripComments_Backup(THD* a_thd,QueryStripComments* qsc)
260 + if(opt_query_cache_strip_comments)
263 + query = thd->query();
264 + length = thd->query_length();
265 + qsc->set(query, length, QUERY_BUFFER_ADDITIONAL_LENGTH(thd->db_length));
266 + *(size_t *) (qsc->query() + qsc->query_length() + 1)= thd->db_length;
267 + thd->set_query(qsc->query(),qsc->query_length());
276 +QueryStripComments_Backup::~QueryStripComments_Backup()
280 + thd->set_query(query,length);
284 #ifdef EMBEDDED_LIBRARY
285 #include "emb_qcache.h"
288 Query_cache_wait_state wait_state(thd, __func__, __FILE__, __LINE__);
289 DBUG_ENTER("Query_cache::try_lock");
291 + const char* old_proc_info= thd->proc_info;
292 + thd_proc_info(thd,"Waiting on query cache mutex");
293 + DEBUG_SYNC(thd, "before_query_cache_mutex");
294 mysql_mutex_lock(&structure_guard_mutex);
295 + DEBUG_SYNC(thd, "after_query_cache_mutex");
296 + thd->proc_info = old_proc_info;
299 if (m_cache_lock_status == Query_cache::UNLOCKED)
300 @@ -1274,6 +1471,8 @@
304 + QueryStripComments *query_strip_comments = &(thd->query_strip_comments);
305 + QueryStripComments_Backup backup(thd,query_strip_comments);
307 /* Key is query + database + flag */
309 @@ -1451,6 +1650,9 @@
310 Query_cache_block_table *block_table, *block_table_end;
312 Query_cache_query_flags flags;
313 + QueryStripComments *query_strip_comments = &(thd->query_strip_comments);
314 + char *sql_backup = sql;
315 + uint query_length_backup = query_length;
316 DBUG_ENTER("Query_cache::send_result_to_client");
319 @@ -1472,21 +1674,103 @@
324 - Skip '(' characters in queries like following:
325 - (select a from t1) union (select a from t1);
327 - while (sql[i]=='(')
329 + if(opt_query_cache_strip_comments)
331 + /* Skip all comments and non-letter symbols */
332 + uint& query_position = i;
334 + while(query_position < query_length)
336 + bool check = false;
337 + char current = query[query_position];
341 + if(((query_position + 2) < query_length) && ('*' == query[query_position+1]) && ('!' != query[query_position+2]))
343 + query_position += 2; // skip "/*"
346 + if('*' == query[query_position] && '/' == query[query_position+1]) // check for "*/" (without space)
348 + query_position += 2; // skip "*/" (without space)
356 + while(query_position < query_length);
357 + continue; // analyze current symbol
361 + if(query[query_position+1] == '-')
363 + ++query_position; // skip "-"
372 + ++query_position; // skip current symbol
373 + if('\n' == query[query_position]) // check for '\n'
375 + ++query_position; // skip '\n'
379 + while(query_position < query_length);
380 + continue; // analyze current symbol
390 + break; // make gcc happy
391 + } // switch(current)
394 + if(query_position + 2 < query_length)
401 + DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
406 + } // while(query_position < query_length)
408 + else // if(opt_query_cache_strip_comments)
411 + Skip '(' characters in queries like following:
412 + (select a from t1) union (select a from t1);
414 + while (sql[i]=='(')
418 - Test if the query is a SELECT
419 - (pre-space is removed in dispatch_command).
420 + } // if(opt_query_cache_strip_comments)
422 + Test if the query is a SELECT
423 + (pre-space is removed in dispatch_command).
425 - First '/' looks like comment before command it is not
426 - frequently appeared in real life, consequently we can
427 - check all such queries, too.
429 + First '/' looks like comment before command it is not
430 + frequently appeared in real life, consequently we can
431 + check all such queries, too.
433 if ((my_toupper(system_charset_info, sql[i]) != 'S' ||
434 my_toupper(system_charset_info, sql[i + 1]) != 'E' ||
435 my_toupper(system_charset_info, sql[i + 2]) != 'L') &&
436 @@ -1543,6 +1827,14 @@
439 Query_cache_block *query_block;
440 + if(opt_query_cache_strip_comments)
442 + query_strip_comments->set(sql, query_length,
443 + QUERY_BUFFER_ADDITIONAL_LENGTH(thd->db_length));
444 + sql = query_strip_comments->query();
445 + query_length = query_strip_comments->query_length();
446 + *(size_t *) (sql + query_length + 1)= thd->db_length;
449 tot_length= query_length + 1 + sizeof(size_t) +
450 thd->db_length + QUERY_CACHE_FLAGS_SIZE;
451 @@ -1611,6 +1903,8 @@
452 (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE);
453 query_block = (Query_cache_block *) my_hash_search(&queries, (uchar*) sql,
456 + query_length = query_length_backup;
457 /* Quick abort on unlocked data */
458 if (query_block == 0 ||
459 query_block->query()->result() == 0 ||
460 --- a/sql/sql_class.h
461 +++ b/sql/sql_class.h
463 #include "thr_lock.h" /* thr_lock_type, THR_LOCK_DATA,
466 +#ifdef HAVE_QUERY_CACHE
467 +#include "query_strip_comments.h"
468 +#endif // HAVE_QUERY_CACHE
470 class Reprepare_observer;
471 class Relay_log_info;
473 statement lifetime. FIXME: must be const
476 +#ifdef HAVE_QUERY_CACHE
477 + QueryStripComments query_strip_comments; // see sql_cache.cc
478 +#endif //HAVE_QUERY_CACHE
481 MARK_COLUMNS_NONE: Means mark_used_colums is not set and no indicator to
482 --- a/sql/sys_vars.cc
483 +++ b/sql/sys_vars.cc
484 @@ -1895,6 +1895,11 @@
485 NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
486 ON_UPDATE(fix_query_cache_size));
488 +static Sys_var_mybool Sys_query_cache_strip_comments(
489 + "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",
490 + GLOBAL_VAR(opt_query_cache_strip_comments), CMD_LINE(OPT_ARG),
493 static Sys_var_ulong Sys_query_cache_limit(
495 "Don't cache results that are bigger than this",
497 +++ b/mysql-test/include/percona_query_cache_with_comments.inc
499 +--source include/percona_query_cache_with_comments_clear.inc
500 +let $query=/* with comment first */select * from t1;
502 +--source include/percona_query_cache_with_comments_eval.inc
504 +let $query=# with comment first
506 +--source include/percona_query_cache_with_comments_eval.inc
508 +let $query=-- with comment first
510 +--source include/percona_query_cache_with_comments_eval.inc
512 +let $query=/* with comment first and "quote" */select * from t1;
513 +--source include/percona_query_cache_with_comments_eval.inc
515 +let $query=# with comment first and "quote"
517 +--source include/percona_query_cache_with_comments_eval.inc
519 +let $query=-- with comment first and "quote"
521 +--source include/percona_query_cache_with_comments_eval.inc
524 + /* with comment and whitespaces first */select * from t1;
525 +--source include/percona_query_cache_with_comments_eval.inc
528 + # with comment and whitespaces first
530 +--source include/percona_query_cache_with_comments_eval.inc
533 + -- with comment and whitespaces first
535 +--source include/percona_query_cache_with_comments_eval.inc
537 +let $internal=* internal comment *;
539 +let $query=select * /$internal/ from t1;
540 +--source include/percona_query_cache_with_comments_eval.inc
541 +let $query=select */$internal/ from t1;
542 +--source include/percona_query_cache_with_comments_eval.inc
543 +let $query=select */$internal/from t1;
544 +--source include/percona_query_cache_with_comments_eval.inc
546 +let $internal=* internal comment with "quote" *;
548 +let $query=select * /$internal/ from t1;
549 +--source include/percona_query_cache_with_comments_eval.inc
550 +let $query=select */$internal/ from t1;
551 +--source include/percona_query_cache_with_comments_eval.inc
552 +let $query=select */$internal/from t1;
553 +--source include/percona_query_cache_with_comments_eval.inc
555 +let $query=select * from t1
557 +--source include/percona_query_cache_with_comments_eval.inc
559 +let $query=select * from t1 ;
560 +--source include/percona_query_cache_with_comments_eval.inc
562 +let $query=select * from t1 ;
563 +--source include/percona_query_cache_with_comments_eval.inc
565 +let $query=select * from t1
566 +/* comment in the end */;
567 +--source include/percona_query_cache_with_comments_eval.inc
569 +let $query=select * from t1
571 +--source include/percona_query_cache_with_comments_eval.inc
573 +let $query=select * from t1
574 +/* comment in the end */
576 +--source include/percona_query_cache_with_comments_eval.inc
578 +let $query=select * from t1 #comment in the end;
579 +--source include/percona_query_cache_with_comments_eval.inc
581 +let $query=select * from t1 #comment in the end
583 +--source include/percona_query_cache_with_comments_eval.inc
585 +let $query=select * from t1 -- comment in the end;
586 +--source include/percona_query_cache_with_comments_eval.inc
588 +let $query=select * from t1 -- comment in the end
590 +--source include/percona_query_cache_with_comments_eval.inc
592 +let $query=select ' \' ' from t1;
593 +--source include/percona_query_cache_with_comments_eval.inc
595 +++ b/mysql-test/include/percona_query_cache_with_comments_begin.inc
597 +-- source include/have_query_cache.inc
599 +set GLOBAL query_cache_size=1355776;
602 +drop table if exists t1;
605 +create table t1 (a int not null);
606 +insert into t1 values (1),(2),(3);
608 +--source include/percona_query_cache_with_comments_clear.inc
610 +++ b/mysql-test/include/percona_query_cache_with_comments_clear.inc
612 +# Reset query cache variables.
613 +flush query cache; # This crashed in some versions
614 +flush query cache; # This crashed in some versions
618 +++ b/mysql-test/include/percona_query_cache_with_comments_end.inc
621 +SET GLOBAL query_cache_size=default;
622 +set global query_cache_strip_comments=OFF;
624 +++ b/mysql-test/include/percona_query_cache_with_comments_eval.inc
626 +echo -----------------------------------------------------;
628 +echo -----------------------------------------------------;
629 +--source include/percona_query_cache_with_comments_show.inc
632 +--source include/percona_query_cache_with_comments_show.inc
634 +++ b/mysql-test/include/percona_query_cache_with_comments_show.inc
636 +let $show=show status like "Qcache_queries_in_cache";
638 +let $show=show status like "Qcache_inserts";
640 +let $show=show status like "Qcache_hits";
645 +++ b/mysql-test/r/percona_query_cache_with_comments.result
647 +set global query_cache_strip_comments=ON;
648 +set GLOBAL query_cache_size=1355776;
649 +drop table if exists t1;
650 +create table t1 (a int not null);
651 +insert into t1 values (1),(2),(3);
660 +/* with comment first */select * from t1;
665 +-----------------------------------------------------
666 +/* with comment first */select * from t1
667 +-----------------------------------------------------
668 +show status like "Qcache_queries_in_cache";
670 +Qcache_queries_in_cache 1
671 +show status like "Qcache_inserts";
674 +show status like "Qcache_hits";
677 +/* with comment first */select * from t1;
682 +/* with comment first */select * from t1;
687 +show status like "Qcache_queries_in_cache";
689 +Qcache_queries_in_cache 1
690 +show status like "Qcache_inserts";
693 +show status like "Qcache_hits";
696 +-----------------------------------------------------
697 +# with comment first
699 +-----------------------------------------------------
700 +show status like "Qcache_queries_in_cache";
702 +Qcache_queries_in_cache 1
703 +show status like "Qcache_inserts";
706 +show status like "Qcache_hits";
709 +# with comment first
715 +# with comment first
721 +show status like "Qcache_queries_in_cache";
723 +Qcache_queries_in_cache 1
724 +show status like "Qcache_inserts";
727 +show status like "Qcache_hits";
730 +-----------------------------------------------------
731 +-- with comment first
733 +-----------------------------------------------------
734 +show status like "Qcache_queries_in_cache";
736 +Qcache_queries_in_cache 1
737 +show status like "Qcache_inserts";
740 +show status like "Qcache_hits";
743 +-- with comment first
749 +-- with comment first
755 +show status like "Qcache_queries_in_cache";
757 +Qcache_queries_in_cache 1
758 +show status like "Qcache_inserts";
761 +show status like "Qcache_hits";
764 +-----------------------------------------------------
765 +/* with comment first and "quote" */select * from t1
766 +-----------------------------------------------------
767 +show status like "Qcache_queries_in_cache";
769 +Qcache_queries_in_cache 1
770 +show status like "Qcache_inserts";
773 +show status like "Qcache_hits";
776 +/* with comment first and "quote" */select * from t1;
781 +/* with comment first and "quote" */select * from t1;
786 +show status like "Qcache_queries_in_cache";
788 +Qcache_queries_in_cache 1
789 +show status like "Qcache_inserts";
792 +show status like "Qcache_hits";
795 +-----------------------------------------------------
796 +# with comment first and "quote"
798 +-----------------------------------------------------
799 +show status like "Qcache_queries_in_cache";
801 +Qcache_queries_in_cache 1
802 +show status like "Qcache_inserts";
805 +show status like "Qcache_hits";
808 +# with comment first and "quote"
814 +# with comment first and "quote"
820 +show status like "Qcache_queries_in_cache";
822 +Qcache_queries_in_cache 1
823 +show status like "Qcache_inserts";
826 +show status like "Qcache_hits";
829 +-----------------------------------------------------
830 +-- with comment first and "quote"
832 +-----------------------------------------------------
833 +show status like "Qcache_queries_in_cache";
835 +Qcache_queries_in_cache 1
836 +show status like "Qcache_inserts";
839 +show status like "Qcache_hits";
842 +-- with comment first and "quote"
848 +-- with comment first and "quote"
854 +show status like "Qcache_queries_in_cache";
856 +Qcache_queries_in_cache 1
857 +show status like "Qcache_inserts";
860 +show status like "Qcache_hits";
863 +-----------------------------------------------------
864 +/* with comment and whitespaces first */select * from t1
865 +-----------------------------------------------------
866 +show status like "Qcache_queries_in_cache";
868 +Qcache_queries_in_cache 1
869 +show status like "Qcache_inserts";
872 +show status like "Qcache_hits";
875 +/* with comment and whitespaces first */select * from t1;
880 +/* with comment and whitespaces first */select * from t1;
885 +show status like "Qcache_queries_in_cache";
887 +Qcache_queries_in_cache 1
888 +show status like "Qcache_inserts";
891 +show status like "Qcache_hits";
894 +-----------------------------------------------------
895 +# with comment and whitespaces first
897 +-----------------------------------------------------
898 +show status like "Qcache_queries_in_cache";
900 +Qcache_queries_in_cache 1
901 +show status like "Qcache_inserts";
904 +show status like "Qcache_hits";
907 +# with comment and whitespaces first
913 +# with comment and whitespaces first
919 +show status like "Qcache_queries_in_cache";
921 +Qcache_queries_in_cache 1
922 +show status like "Qcache_inserts";
925 +show status like "Qcache_hits";
928 +-----------------------------------------------------
929 +-- with comment and whitespaces first
931 +-----------------------------------------------------
932 +show status like "Qcache_queries_in_cache";
934 +Qcache_queries_in_cache 1
935 +show status like "Qcache_inserts";
938 +show status like "Qcache_hits";
941 +-- with comment and whitespaces first
947 +-- with comment and whitespaces first
953 +show status like "Qcache_queries_in_cache";
955 +Qcache_queries_in_cache 1
956 +show status like "Qcache_inserts";
959 +show status like "Qcache_hits";
962 +-----------------------------------------------------
963 +select * /* internal comment */ from t1
964 +-----------------------------------------------------
965 +show status like "Qcache_queries_in_cache";
967 +Qcache_queries_in_cache 1
968 +show status like "Qcache_inserts";
971 +show status like "Qcache_hits";
974 +select * /* internal comment */ from t1;
979 +select * /* internal comment */ from t1;
984 +show status like "Qcache_queries_in_cache";
986 +Qcache_queries_in_cache 1
987 +show status like "Qcache_inserts";
990 +show status like "Qcache_hits";
993 +-----------------------------------------------------
994 +select */* internal comment */ from t1
995 +-----------------------------------------------------
996 +show status like "Qcache_queries_in_cache";
998 +Qcache_queries_in_cache 1
999 +show status like "Qcache_inserts";
1000 +Variable_name Value
1002 +show status like "Qcache_hits";
1003 +Variable_name Value
1005 +select */* internal comment */ from t1;
1010 +select */* internal comment */ from t1;
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
1021 +show status like "Qcache_hits";
1022 +Variable_name Value
1024 +-----------------------------------------------------
1025 +select */* internal comment */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
1033 +show status like "Qcache_hits";
1034 +Variable_name Value
1036 +select */* internal comment */from t1;
1041 +select */* internal comment */from t1;
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
1052 +show status like "Qcache_hits";
1053 +Variable_name Value
1055 +-----------------------------------------------------
1056 +select * /* internal comment with "quote" */ from t1
1057 +-----------------------------------------------------
1058 +show status like "Qcache_queries_in_cache";
1059 +Variable_name Value
1060 +Qcache_queries_in_cache 1
1061 +show status like "Qcache_inserts";
1062 +Variable_name Value
1064 +show status like "Qcache_hits";
1065 +Variable_name Value
1067 +select * /* internal comment with "quote" */ from t1;
1072 +select * /* internal comment with "quote" */ from t1;
1077 +show status like "Qcache_queries_in_cache";
1078 +Variable_name Value
1079 +Qcache_queries_in_cache 1
1080 +show status like "Qcache_inserts";
1081 +Variable_name Value
1083 +show status like "Qcache_hits";
1084 +Variable_name Value
1086 +-----------------------------------------------------
1087 +select */* internal comment with "quote" */ from t1
1088 +-----------------------------------------------------
1089 +show status like "Qcache_queries_in_cache";
1090 +Variable_name Value
1091 +Qcache_queries_in_cache 1
1092 +show status like "Qcache_inserts";
1093 +Variable_name Value
1095 +show status like "Qcache_hits";
1096 +Variable_name Value
1098 +select */* internal comment with "quote" */ from t1;
1103 +select */* internal comment with "quote" */ from t1;
1108 +show status like "Qcache_queries_in_cache";
1109 +Variable_name Value
1110 +Qcache_queries_in_cache 1
1111 +show status like "Qcache_inserts";
1112 +Variable_name Value
1114 +show status like "Qcache_hits";
1115 +Variable_name Value
1117 +-----------------------------------------------------
1118 +select */* internal comment with "quote" */from t1
1119 +-----------------------------------------------------
1120 +show status like "Qcache_queries_in_cache";
1121 +Variable_name Value
1122 +Qcache_queries_in_cache 1
1123 +show status like "Qcache_inserts";
1124 +Variable_name Value
1126 +show status like "Qcache_hits";
1127 +Variable_name Value
1129 +select */* internal comment with "quote" */from t1;
1134 +select */* internal comment with "quote" */from t1;
1139 +show status like "Qcache_queries_in_cache";
1140 +Variable_name Value
1141 +Qcache_queries_in_cache 1
1142 +show status like "Qcache_inserts";
1143 +Variable_name Value
1145 +show status like "Qcache_hits";
1146 +Variable_name Value
1148 +-----------------------------------------------------
1151 +-----------------------------------------------------
1152 +show status like "Qcache_queries_in_cache";
1153 +Variable_name Value
1154 +Qcache_queries_in_cache 1
1155 +show status like "Qcache_inserts";
1156 +Variable_name Value
1158 +show status like "Qcache_hits";
1159 +Variable_name Value
1173 +show status like "Qcache_queries_in_cache";
1174 +Variable_name Value
1175 +Qcache_queries_in_cache 1
1176 +show status like "Qcache_inserts";
1177 +Variable_name Value
1179 +show status like "Qcache_hits";
1180 +Variable_name Value
1182 +-----------------------------------------------------
1184 +-----------------------------------------------------
1185 +show status like "Qcache_queries_in_cache";
1186 +Variable_name Value
1187 +Qcache_queries_in_cache 1
1188 +show status like "Qcache_inserts";
1189 +Variable_name Value
1191 +show status like "Qcache_hits";
1192 +Variable_name Value
1204 +show status like "Qcache_queries_in_cache";
1205 +Variable_name Value
1206 +Qcache_queries_in_cache 1
1207 +show status like "Qcache_inserts";
1208 +Variable_name Value
1210 +show status like "Qcache_hits";
1211 +Variable_name Value
1213 +-----------------------------------------------------
1215 +-----------------------------------------------------
1216 +show status like "Qcache_queries_in_cache";
1217 +Variable_name Value
1218 +Qcache_queries_in_cache 1
1219 +show status like "Qcache_inserts";
1220 +Variable_name Value
1222 +show status like "Qcache_hits";
1223 +Variable_name Value
1235 +show status like "Qcache_queries_in_cache";
1236 +Variable_name Value
1237 +Qcache_queries_in_cache 1
1238 +show status like "Qcache_inserts";
1239 +Variable_name Value
1241 +show status like "Qcache_hits";
1242 +Variable_name Value
1244 +-----------------------------------------------------
1246 +/* comment in the end */
1247 +-----------------------------------------------------
1248 +show status like "Qcache_queries_in_cache";
1249 +Variable_name Value
1250 +Qcache_queries_in_cache 1
1251 +show status like "Qcache_inserts";
1252 +Variable_name Value
1254 +show status like "Qcache_hits";
1255 +Variable_name Value
1258 +/* comment in the end */;
1264 +/* comment in the end */;
1269 +show status like "Qcache_queries_in_cache";
1270 +Variable_name Value
1271 +Qcache_queries_in_cache 1
1272 +show status like "Qcache_inserts";
1273 +Variable_name Value
1275 +show status like "Qcache_hits";
1276 +Variable_name Value
1278 +-----------------------------------------------------
1281 +-----------------------------------------------------
1282 +show status like "Qcache_queries_in_cache";
1283 +Variable_name Value
1284 +Qcache_queries_in_cache 1
1285 +show status like "Qcache_inserts";
1286 +Variable_name Value
1288 +show status like "Qcache_hits";
1289 +Variable_name Value
1303 +show status like "Qcache_queries_in_cache";
1304 +Variable_name Value
1305 +Qcache_queries_in_cache 1
1306 +show status like "Qcache_inserts";
1307 +Variable_name Value
1309 +show status like "Qcache_hits";
1310 +Variable_name Value
1312 +-----------------------------------------------------
1314 +/* comment in the end */
1316 +-----------------------------------------------------
1317 +show status like "Qcache_queries_in_cache";
1318 +Variable_name Value
1319 +Qcache_queries_in_cache 1
1320 +show status like "Qcache_inserts";
1321 +Variable_name Value
1323 +show status like "Qcache_hits";
1324 +Variable_name Value
1327 +/* comment in the end */
1334 +/* comment in the end */
1340 +show status like "Qcache_queries_in_cache";
1341 +Variable_name Value
1342 +Qcache_queries_in_cache 1
1343 +show status like "Qcache_inserts";
1344 +Variable_name Value
1346 +show status like "Qcache_hits";
1347 +Variable_name Value
1349 +-----------------------------------------------------
1350 +select * from t1 #comment in the end
1351 +-----------------------------------------------------
1352 +show status like "Qcache_queries_in_cache";
1353 +Variable_name Value
1354 +Qcache_queries_in_cache 1
1355 +show status like "Qcache_inserts";
1356 +Variable_name Value
1358 +show status like "Qcache_hits";
1359 +Variable_name Value
1361 +select * from t1 #comment in the end;
1366 +select * from t1 #comment in the end;
1371 +show status like "Qcache_queries_in_cache";
1372 +Variable_name Value
1373 +Qcache_queries_in_cache 1
1374 +show status like "Qcache_inserts";
1375 +Variable_name Value
1377 +show status like "Qcache_hits";
1378 +Variable_name Value
1380 +-----------------------------------------------------
1381 +select * from t1 #comment in the end
1383 +-----------------------------------------------------
1384 +show status like "Qcache_queries_in_cache";
1385 +Variable_name Value
1386 +Qcache_queries_in_cache 1
1387 +show status like "Qcache_inserts";
1388 +Variable_name Value
1390 +show status like "Qcache_hits";
1391 +Variable_name Value
1393 +select * from t1 #comment in the end
1399 +select * from t1 #comment in the end
1405 +show status like "Qcache_queries_in_cache";
1406 +Variable_name Value
1407 +Qcache_queries_in_cache 1
1408 +show status like "Qcache_inserts";
1409 +Variable_name Value
1411 +show status like "Qcache_hits";
1412 +Variable_name Value
1414 +-----------------------------------------------------
1415 +select * from t1 -- comment in the end
1416 +-----------------------------------------------------
1417 +show status like "Qcache_queries_in_cache";
1418 +Variable_name Value
1419 +Qcache_queries_in_cache 1
1420 +show status like "Qcache_inserts";
1421 +Variable_name Value
1423 +show status like "Qcache_hits";
1424 +Variable_name Value
1426 +select * from t1 -- comment in the end;
1431 +select * from t1 -- comment in the end;
1436 +show status like "Qcache_queries_in_cache";
1437 +Variable_name Value
1438 +Qcache_queries_in_cache 1
1439 +show status like "Qcache_inserts";
1440 +Variable_name Value
1442 +show status like "Qcache_hits";
1443 +Variable_name Value
1445 +-----------------------------------------------------
1446 +select * from t1 -- comment in the end
1448 +-----------------------------------------------------
1449 +show status like "Qcache_queries_in_cache";
1450 +Variable_name Value
1451 +Qcache_queries_in_cache 1
1452 +show status like "Qcache_inserts";
1453 +Variable_name Value
1455 +show status like "Qcache_hits";
1456 +Variable_name Value
1458 +select * from t1 -- comment in the end
1464 +select * from t1 -- comment in the end
1470 +show status like "Qcache_queries_in_cache";
1471 +Variable_name Value
1472 +Qcache_queries_in_cache 1
1473 +show status like "Qcache_inserts";
1474 +Variable_name Value
1476 +show status like "Qcache_hits";
1477 +Variable_name Value
1479 +-----------------------------------------------------
1480 +select ' \' ' from t1
1481 +-----------------------------------------------------
1482 +show status like "Qcache_queries_in_cache";
1483 +Variable_name Value
1484 +Qcache_queries_in_cache 1
1485 +show status like "Qcache_inserts";
1486 +Variable_name Value
1488 +show status like "Qcache_hits";
1489 +Variable_name Value
1491 +select ' \' ' from t1;
1496 +select ' \' ' from t1;
1501 +show status like "Qcache_queries_in_cache";
1502 +Variable_name Value
1503 +Qcache_queries_in_cache 2
1504 +show status like "Qcache_inserts";
1505 +Variable_name Value
1507 +show status like "Qcache_hits";
1508 +Variable_name Value
1511 +SET GLOBAL query_cache_size=default;
1512 +set global query_cache_strip_comments=OFF;
1514 +++ b/mysql-test/r/percona_query_cache_with_comments_crash.result
1516 +set GLOBAL query_cache_size=1355776;
1517 +drop table if exists t1;
1518 +create table t1 (a int not null);
1519 +insert into t1 values (1),(2),(3);
1524 +( select * from t1 );
1529 +/*!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 */;
1530 +/* only comment */;
1536 +SET GLOBAL query_cache_size= default;
1538 +++ b/mysql-test/r/percona_query_cache_with_comments_disable.result
1540 +set GLOBAL query_cache_size=1355776;
1541 +drop table if exists t1;
1542 +create table t1 (a int not null);
1543 +insert into t1 values (1),(2),(3);
1552 +/* with comment first */select * from t1;
1557 +-----------------------------------------------------
1558 +/* with comment first */select * from t1
1559 +-----------------------------------------------------
1560 +show status like "Qcache_queries_in_cache";
1561 +Variable_name Value
1562 +Qcache_queries_in_cache 1
1563 +show status like "Qcache_inserts";
1564 +Variable_name Value
1566 +show status like "Qcache_hits";
1567 +Variable_name Value
1569 +/* with comment first */select * from t1;
1574 +/* with comment first */select * from t1;
1579 +show status like "Qcache_queries_in_cache";
1580 +Variable_name Value
1581 +Qcache_queries_in_cache 1
1582 +show status like "Qcache_inserts";
1583 +Variable_name Value
1585 +show status like "Qcache_hits";
1586 +Variable_name Value
1588 +-----------------------------------------------------
1589 +# with comment first
1591 +-----------------------------------------------------
1592 +show status like "Qcache_queries_in_cache";
1593 +Variable_name Value
1594 +Qcache_queries_in_cache 1
1595 +show status like "Qcache_inserts";
1596 +Variable_name Value
1598 +show status like "Qcache_hits";
1599 +Variable_name Value
1601 +# with comment first
1607 +# with comment first
1613 +show status like "Qcache_queries_in_cache";
1614 +Variable_name Value
1615 +Qcache_queries_in_cache 2
1616 +show status like "Qcache_inserts";
1617 +Variable_name Value
1619 +show status like "Qcache_hits";
1620 +Variable_name Value
1622 +-----------------------------------------------------
1623 +-- with comment first
1625 +-----------------------------------------------------
1626 +show status like "Qcache_queries_in_cache";
1627 +Variable_name Value
1628 +Qcache_queries_in_cache 2
1629 +show status like "Qcache_inserts";
1630 +Variable_name Value
1632 +show status like "Qcache_hits";
1633 +Variable_name Value
1635 +-- with comment first
1641 +-- with comment first
1647 +show status like "Qcache_queries_in_cache";
1648 +Variable_name Value
1649 +Qcache_queries_in_cache 3
1650 +show status like "Qcache_inserts";
1651 +Variable_name Value
1653 +show status like "Qcache_hits";
1654 +Variable_name Value
1656 +-----------------------------------------------------
1657 +/* with comment first and "quote" */select * from t1
1658 +-----------------------------------------------------
1659 +show status like "Qcache_queries_in_cache";
1660 +Variable_name Value
1661 +Qcache_queries_in_cache 3
1662 +show status like "Qcache_inserts";
1663 +Variable_name Value
1665 +show status like "Qcache_hits";
1666 +Variable_name Value
1668 +/* with comment first and "quote" */select * from t1;
1673 +/* with comment first and "quote" */select * from t1;
1678 +show status like "Qcache_queries_in_cache";
1679 +Variable_name Value
1680 +Qcache_queries_in_cache 4
1681 +show status like "Qcache_inserts";
1682 +Variable_name Value
1684 +show status like "Qcache_hits";
1685 +Variable_name Value
1687 +-----------------------------------------------------
1688 +# with comment first and "quote"
1690 +-----------------------------------------------------
1691 +show status like "Qcache_queries_in_cache";
1692 +Variable_name Value
1693 +Qcache_queries_in_cache 4
1694 +show status like "Qcache_inserts";
1695 +Variable_name Value
1697 +show status like "Qcache_hits";
1698 +Variable_name Value
1700 +# with comment first and "quote"
1706 +# with comment first and "quote"
1712 +show status like "Qcache_queries_in_cache";
1713 +Variable_name Value
1714 +Qcache_queries_in_cache 5
1715 +show status like "Qcache_inserts";
1716 +Variable_name Value
1718 +show status like "Qcache_hits";
1719 +Variable_name Value
1721 +-----------------------------------------------------
1722 +-- with comment first and "quote"
1724 +-----------------------------------------------------
1725 +show status like "Qcache_queries_in_cache";
1726 +Variable_name Value
1727 +Qcache_queries_in_cache 5
1728 +show status like "Qcache_inserts";
1729 +Variable_name Value
1731 +show status like "Qcache_hits";
1732 +Variable_name Value
1734 +-- with comment first and "quote"
1740 +-- with comment first and "quote"
1746 +show status like "Qcache_queries_in_cache";
1747 +Variable_name Value
1748 +Qcache_queries_in_cache 6
1749 +show status like "Qcache_inserts";
1750 +Variable_name Value
1752 +show status like "Qcache_hits";
1753 +Variable_name Value
1755 +-----------------------------------------------------
1756 +/* with comment and whitespaces first */select * from t1
1757 +-----------------------------------------------------
1758 +show status like "Qcache_queries_in_cache";
1759 +Variable_name Value
1760 +Qcache_queries_in_cache 6
1761 +show status like "Qcache_inserts";
1762 +Variable_name Value
1764 +show status like "Qcache_hits";
1765 +Variable_name Value
1767 +/* with comment and whitespaces first */select * from t1;
1772 +/* with comment and whitespaces first */select * from t1;
1777 +show status like "Qcache_queries_in_cache";
1778 +Variable_name Value
1779 +Qcache_queries_in_cache 7
1780 +show status like "Qcache_inserts";
1781 +Variable_name Value
1783 +show status like "Qcache_hits";
1784 +Variable_name Value
1786 +-----------------------------------------------------
1787 +# with comment and whitespaces first
1789 +-----------------------------------------------------
1790 +show status like "Qcache_queries_in_cache";
1791 +Variable_name Value
1792 +Qcache_queries_in_cache 7
1793 +show status like "Qcache_inserts";
1794 +Variable_name Value
1796 +show status like "Qcache_hits";
1797 +Variable_name Value
1799 +# with comment and whitespaces first
1805 +# with comment and whitespaces first
1811 +show status like "Qcache_queries_in_cache";
1812 +Variable_name Value
1813 +Qcache_queries_in_cache 8
1814 +show status like "Qcache_inserts";
1815 +Variable_name Value
1817 +show status like "Qcache_hits";
1818 +Variable_name Value
1820 +-----------------------------------------------------
1821 +-- with comment and whitespaces first
1823 +-----------------------------------------------------
1824 +show status like "Qcache_queries_in_cache";
1825 +Variable_name Value
1826 +Qcache_queries_in_cache 8
1827 +show status like "Qcache_inserts";
1828 +Variable_name Value
1830 +show status like "Qcache_hits";
1831 +Variable_name Value
1833 +-- with comment and whitespaces first
1839 +-- with comment and whitespaces first
1845 +show status like "Qcache_queries_in_cache";
1846 +Variable_name Value
1847 +Qcache_queries_in_cache 9
1848 +show status like "Qcache_inserts";
1849 +Variable_name Value
1851 +show status like "Qcache_hits";
1852 +Variable_name Value
1854 +-----------------------------------------------------
1855 +select * /* internal comment */ from t1
1856 +-----------------------------------------------------
1857 +show status like "Qcache_queries_in_cache";
1858 +Variable_name Value
1859 +Qcache_queries_in_cache 9
1860 +show status like "Qcache_inserts";
1861 +Variable_name Value
1863 +show status like "Qcache_hits";
1864 +Variable_name Value
1866 +select * /* internal comment */ from t1;
1871 +select * /* internal comment */ from t1;
1876 +show status like "Qcache_queries_in_cache";
1877 +Variable_name Value
1878 +Qcache_queries_in_cache 10
1879 +show status like "Qcache_inserts";
1880 +Variable_name Value
1882 +show status like "Qcache_hits";
1883 +Variable_name Value
1885 +-----------------------------------------------------
1886 +select */* internal comment */ from t1
1887 +-----------------------------------------------------
1888 +show status like "Qcache_queries_in_cache";
1889 +Variable_name Value
1890 +Qcache_queries_in_cache 10
1891 +show status like "Qcache_inserts";
1892 +Variable_name Value
1894 +show status like "Qcache_hits";
1895 +Variable_name Value
1897 +select */* internal comment */ from t1;
1902 +select */* internal comment */ from t1;
1907 +show status like "Qcache_queries_in_cache";
1908 +Variable_name Value
1909 +Qcache_queries_in_cache 11
1910 +show status like "Qcache_inserts";
1911 +Variable_name Value
1913 +show status like "Qcache_hits";
1914 +Variable_name Value
1916 +-----------------------------------------------------
1917 +select */* internal comment */from t1
1918 +-----------------------------------------------------
1919 +show status like "Qcache_queries_in_cache";
1920 +Variable_name Value
1921 +Qcache_queries_in_cache 11
1922 +show status like "Qcache_inserts";
1923 +Variable_name Value
1925 +show status like "Qcache_hits";
1926 +Variable_name Value
1928 +select */* internal comment */from t1;
1933 +select */* internal comment */from t1;
1938 +show status like "Qcache_queries_in_cache";
1939 +Variable_name Value
1940 +Qcache_queries_in_cache 12
1941 +show status like "Qcache_inserts";
1942 +Variable_name Value
1944 +show status like "Qcache_hits";
1945 +Variable_name Value
1947 +-----------------------------------------------------
1948 +select * /* internal comment with "quote" */ from t1
1949 +-----------------------------------------------------
1950 +show status like "Qcache_queries_in_cache";
1951 +Variable_name Value
1952 +Qcache_queries_in_cache 12
1953 +show status like "Qcache_inserts";
1954 +Variable_name Value
1956 +show status like "Qcache_hits";
1957 +Variable_name Value
1959 +select * /* internal comment with "quote" */ from t1;
1964 +select * /* internal comment with "quote" */ from t1;
1969 +show status like "Qcache_queries_in_cache";
1970 +Variable_name Value
1971 +Qcache_queries_in_cache 13
1972 +show status like "Qcache_inserts";
1973 +Variable_name Value
1975 +show status like "Qcache_hits";
1976 +Variable_name Value
1978 +-----------------------------------------------------
1979 +select */* internal comment with "quote" */ from t1
1980 +-----------------------------------------------------
1981 +show status like "Qcache_queries_in_cache";
1982 +Variable_name Value
1983 +Qcache_queries_in_cache 13
1984 +show status like "Qcache_inserts";
1985 +Variable_name Value
1987 +show status like "Qcache_hits";
1988 +Variable_name Value
1990 +select */* internal comment with "quote" */ from t1;
1995 +select */* internal comment with "quote" */ from t1;
2000 +show status like "Qcache_queries_in_cache";
2001 +Variable_name Value
2002 +Qcache_queries_in_cache 14
2003 +show status like "Qcache_inserts";
2004 +Variable_name Value
2006 +show status like "Qcache_hits";
2007 +Variable_name Value
2009 +-----------------------------------------------------
2010 +select */* internal comment with "quote" */from t1
2011 +-----------------------------------------------------
2012 +show status like "Qcache_queries_in_cache";
2013 +Variable_name Value
2014 +Qcache_queries_in_cache 14
2015 +show status like "Qcache_inserts";
2016 +Variable_name Value
2018 +show status like "Qcache_hits";
2019 +Variable_name Value
2021 +select */* internal comment with "quote" */from t1;
2026 +select */* internal comment with "quote" */from t1;
2031 +show status like "Qcache_queries_in_cache";
2032 +Variable_name Value
2033 +Qcache_queries_in_cache 15
2034 +show status like "Qcache_inserts";
2035 +Variable_name Value
2037 +show status like "Qcache_hits";
2038 +Variable_name Value
2040 +-----------------------------------------------------
2043 +-----------------------------------------------------
2044 +show status like "Qcache_queries_in_cache";
2045 +Variable_name Value
2046 +Qcache_queries_in_cache 15
2047 +show status like "Qcache_inserts";
2048 +Variable_name Value
2050 +show status like "Qcache_hits";
2051 +Variable_name Value
2065 +show status like "Qcache_queries_in_cache";
2066 +Variable_name Value
2067 +Qcache_queries_in_cache 16
2068 +show status like "Qcache_inserts";
2069 +Variable_name Value
2071 +show status like "Qcache_hits";
2072 +Variable_name Value
2074 +-----------------------------------------------------
2076 +-----------------------------------------------------
2077 +show status like "Qcache_queries_in_cache";
2078 +Variable_name Value
2079 +Qcache_queries_in_cache 16
2080 +show status like "Qcache_inserts";
2081 +Variable_name Value
2083 +show status like "Qcache_hits";
2084 +Variable_name Value
2096 +show status like "Qcache_queries_in_cache";
2097 +Variable_name Value
2098 +Qcache_queries_in_cache 16
2099 +show status like "Qcache_inserts";
2100 +Variable_name Value
2102 +show status like "Qcache_hits";
2103 +Variable_name Value
2105 +-----------------------------------------------------
2107 +-----------------------------------------------------
2108 +show status like "Qcache_queries_in_cache";
2109 +Variable_name Value
2110 +Qcache_queries_in_cache 16
2111 +show status like "Qcache_inserts";
2112 +Variable_name Value
2114 +show status like "Qcache_hits";
2115 +Variable_name Value
2127 +show status like "Qcache_queries_in_cache";
2128 +Variable_name Value
2129 +Qcache_queries_in_cache 16
2130 +show status like "Qcache_inserts";
2131 +Variable_name Value
2133 +show status like "Qcache_hits";
2134 +Variable_name Value
2136 +-----------------------------------------------------
2138 +/* comment in the end */
2139 +-----------------------------------------------------
2140 +show status like "Qcache_queries_in_cache";
2141 +Variable_name Value
2142 +Qcache_queries_in_cache 16
2143 +show status like "Qcache_inserts";
2144 +Variable_name Value
2146 +show status like "Qcache_hits";
2147 +Variable_name Value
2150 +/* comment in the end */;
2156 +/* comment in the end */;
2161 +show status like "Qcache_queries_in_cache";
2162 +Variable_name Value
2163 +Qcache_queries_in_cache 17
2164 +show status like "Qcache_inserts";
2165 +Variable_name Value
2167 +show status like "Qcache_hits";
2168 +Variable_name Value
2170 +-----------------------------------------------------
2173 +-----------------------------------------------------
2174 +show status like "Qcache_queries_in_cache";
2175 +Variable_name Value
2176 +Qcache_queries_in_cache 17
2177 +show status like "Qcache_inserts";
2178 +Variable_name Value
2180 +show status like "Qcache_hits";
2181 +Variable_name Value
2195 +show status like "Qcache_queries_in_cache";
2196 +Variable_name Value
2197 +Qcache_queries_in_cache 18
2198 +show status like "Qcache_inserts";
2199 +Variable_name Value
2201 +show status like "Qcache_hits";
2202 +Variable_name Value
2204 +-----------------------------------------------------
2206 +/* comment in the end */
2208 +-----------------------------------------------------
2209 +show status like "Qcache_queries_in_cache";
2210 +Variable_name Value
2211 +Qcache_queries_in_cache 18
2212 +show status like "Qcache_inserts";
2213 +Variable_name Value
2215 +show status like "Qcache_hits";
2216 +Variable_name Value
2219 +/* comment in the end */
2226 +/* comment in the end */
2232 +show status like "Qcache_queries_in_cache";
2233 +Variable_name Value
2234 +Qcache_queries_in_cache 18
2235 +show status like "Qcache_inserts";
2236 +Variable_name Value
2238 +show status like "Qcache_hits";
2239 +Variable_name Value
2241 +-----------------------------------------------------
2242 +select * from t1 #comment in the end
2243 +-----------------------------------------------------
2244 +show status like "Qcache_queries_in_cache";
2245 +Variable_name Value
2246 +Qcache_queries_in_cache 18
2247 +show status like "Qcache_inserts";
2248 +Variable_name Value
2250 +show status like "Qcache_hits";
2251 +Variable_name Value
2253 +select * from t1 #comment in the end;
2258 +select * from t1 #comment in the end;
2263 +show status like "Qcache_queries_in_cache";
2264 +Variable_name Value
2265 +Qcache_queries_in_cache 19
2266 +show status like "Qcache_inserts";
2267 +Variable_name Value
2269 +show status like "Qcache_hits";
2270 +Variable_name Value
2272 +-----------------------------------------------------
2273 +select * from t1 #comment in the end
2275 +-----------------------------------------------------
2276 +show status like "Qcache_queries_in_cache";
2277 +Variable_name Value
2278 +Qcache_queries_in_cache 19
2279 +show status like "Qcache_inserts";
2280 +Variable_name Value
2282 +show status like "Qcache_hits";
2283 +Variable_name Value
2285 +select * from t1 #comment in the end
2291 +select * from t1 #comment in the end
2297 +show status like "Qcache_queries_in_cache";
2298 +Variable_name Value
2299 +Qcache_queries_in_cache 19
2300 +show status like "Qcache_inserts";
2301 +Variable_name Value
2303 +show status like "Qcache_hits";
2304 +Variable_name Value
2306 +-----------------------------------------------------
2307 +select * from t1 -- comment in the end
2308 +-----------------------------------------------------
2309 +show status like "Qcache_queries_in_cache";
2310 +Variable_name Value
2311 +Qcache_queries_in_cache 19
2312 +show status like "Qcache_inserts";
2313 +Variable_name Value
2315 +show status like "Qcache_hits";
2316 +Variable_name Value
2318 +select * from t1 -- comment in the end;
2323 +select * from t1 -- comment in the end;
2328 +show status like "Qcache_queries_in_cache";
2329 +Variable_name Value
2330 +Qcache_queries_in_cache 20
2331 +show status like "Qcache_inserts";
2332 +Variable_name Value
2334 +show status like "Qcache_hits";
2335 +Variable_name Value
2337 +-----------------------------------------------------
2338 +select * from t1 -- comment in the end
2340 +-----------------------------------------------------
2341 +show status like "Qcache_queries_in_cache";
2342 +Variable_name Value
2343 +Qcache_queries_in_cache 20
2344 +show status like "Qcache_inserts";
2345 +Variable_name Value
2347 +show status like "Qcache_hits";
2348 +Variable_name Value
2350 +select * from t1 -- comment in the end
2356 +select * from t1 -- comment in the end
2362 +show status like "Qcache_queries_in_cache";
2363 +Variable_name Value
2364 +Qcache_queries_in_cache 20
2365 +show status like "Qcache_inserts";
2366 +Variable_name Value
2368 +show status like "Qcache_hits";
2369 +Variable_name Value
2371 +-----------------------------------------------------
2372 +select ' \' ' from t1
2373 +-----------------------------------------------------
2374 +show status like "Qcache_queries_in_cache";
2375 +Variable_name Value
2376 +Qcache_queries_in_cache 20
2377 +show status like "Qcache_inserts";
2378 +Variable_name Value
2380 +show status like "Qcache_hits";
2381 +Variable_name Value
2383 +select ' \' ' from t1;
2388 +select ' \' ' from t1;
2393 +show status like "Qcache_queries_in_cache";
2394 +Variable_name Value
2395 +Qcache_queries_in_cache 21
2396 +show status like "Qcache_inserts";
2397 +Variable_name Value
2399 +show status like "Qcache_hits";
2400 +Variable_name Value
2403 +SET GLOBAL query_cache_size=default;
2404 +set global query_cache_strip_comments=OFF;
2406 +++ b/mysql-test/r/percona_query_cache_with_comments_prepared_statements.result
2408 +set GLOBAL query_cache_size=1355776;
2413 +drop table if exists t1;
2414 +create table t1 (a int not null);
2415 +insert into t1 values (1),(2),(3);
2416 +set global query_cache_strip_comments=ON;
2417 +show status like "Qcache_queries_in_cache";
2418 +Variable_name Value
2419 +Qcache_queries_in_cache 0
2420 +show status like "Qcache_inserts";
2421 +Variable_name Value
2423 +show status like "Qcache_hits";
2424 +Variable_name Value
2426 +prepare stmt from '/* with comment */ select * from t1';
2432 +show status like "Qcache_queries_in_cache";
2433 +Variable_name Value
2434 +Qcache_queries_in_cache 1
2435 +show status like "Qcache_inserts";
2436 +Variable_name Value
2438 +show status like "Qcache_hits";
2439 +Variable_name Value
2466 +show status like "Qcache_queries_in_cache";
2467 +Variable_name Value
2468 +Qcache_queries_in_cache 1
2469 +show status like "Qcache_inserts";
2470 +Variable_name Value
2472 +show status like "Qcache_hits";
2473 +Variable_name Value
2475 +prepare stmt from 'select * from t1';
2481 +show status like "Qcache_queries_in_cache";
2482 +Variable_name Value
2483 +Qcache_queries_in_cache 1
2484 +show status like "Qcache_inserts";
2485 +Variable_name Value
2487 +show status like "Qcache_hits";
2488 +Variable_name Value
2490 +prepare stmt from 'select * /*internal comment*/from t1';
2496 +show status like "Qcache_queries_in_cache";
2497 +Variable_name Value
2498 +Qcache_queries_in_cache 1
2499 +show status like "Qcache_inserts";
2500 +Variable_name Value
2502 +show status like "Qcache_hits";
2503 +Variable_name Value
2505 +prepare stmt from 'select * /*internal comment*/ from t1';
2511 +show status like "Qcache_queries_in_cache";
2512 +Variable_name Value
2513 +Qcache_queries_in_cache 1
2514 +show status like "Qcache_inserts";
2515 +Variable_name Value
2517 +show status like "Qcache_hits";
2518 +Variable_name Value
2520 +prepare stmt from 'select * from t1 /* at the end */';
2526 +show status like "Qcache_queries_in_cache";
2527 +Variable_name Value
2528 +Qcache_queries_in_cache 1
2529 +show status like "Qcache_inserts";
2530 +Variable_name Value
2532 +show status like "Qcache_hits";
2533 +Variable_name Value
2535 +prepare stmt from 'select * from t1 /* with "quote" */';
2541 +show status like "Qcache_queries_in_cache";
2542 +Variable_name Value
2543 +Qcache_queries_in_cache 1
2544 +show status like "Qcache_inserts";
2545 +Variable_name Value
2547 +show status like "Qcache_hits";
2548 +Variable_name Value
2550 +prepare stmt from 'select * from t1 /* with \'quote\' */';
2556 +show status like "Qcache_queries_in_cache";
2557 +Variable_name Value
2558 +Qcache_queries_in_cache 1
2559 +show status like "Qcache_inserts";
2560 +Variable_name Value
2562 +show status like "Qcache_hits";
2563 +Variable_name Value
2565 +prepare stmt from 'select * from t1 # 123
2572 +show status like "Qcache_queries_in_cache";
2573 +Variable_name Value
2574 +Qcache_queries_in_cache 1
2575 +show status like "Qcache_inserts";
2576 +Variable_name Value
2578 +show status like "Qcache_hits";
2579 +Variable_name Value
2581 +prepare stmt from 'select * from t1 # 123 with "quote"
2588 +show status like "Qcache_queries_in_cache";
2589 +Variable_name Value
2590 +Qcache_queries_in_cache 1
2591 +show status like "Qcache_inserts";
2592 +Variable_name Value
2594 +show status like "Qcache_hits";
2595 +Variable_name Value
2597 +prepare stmt from 'select * from t1 # 123 with \'quote\'
2604 +show status like "Qcache_queries_in_cache";
2605 +Variable_name Value
2606 +Qcache_queries_in_cache 1
2607 +show status like "Qcache_inserts";
2608 +Variable_name Value
2610 +show status like "Qcache_hits";
2611 +Variable_name Value
2613 +prepare stmt from 'select * from t1
2621 +show status like "Qcache_queries_in_cache";
2622 +Variable_name Value
2623 +Qcache_queries_in_cache 1
2624 +show status like "Qcache_inserts";
2625 +Variable_name Value
2627 +show status like "Qcache_hits";
2628 +Variable_name Value
2630 +prepare stmt from '#456
2639 +show status like "Qcache_queries_in_cache";
2640 +Variable_name Value
2641 +Qcache_queries_in_cache 1
2642 +show status like "Qcache_inserts";
2643 +Variable_name Value
2645 +show status like "Qcache_hits";
2646 +Variable_name Value
2648 +prepare stmt from 'select * from t1 -- 123
2655 +show status like "Qcache_queries_in_cache";
2656 +Variable_name Value
2657 +Qcache_queries_in_cache 1
2658 +show status like "Qcache_inserts";
2659 +Variable_name Value
2661 +show status like "Qcache_hits";
2662 +Variable_name Value
2664 +prepare stmt from 'select * from t1
2672 +show status like "Qcache_queries_in_cache";
2673 +Variable_name Value
2674 +Qcache_queries_in_cache 1
2675 +show status like "Qcache_inserts";
2676 +Variable_name Value
2678 +show status like "Qcache_hits";
2679 +Variable_name Value
2681 +prepare stmt from '-- comment in first
2690 +show status like "Qcache_queries_in_cache";
2691 +Variable_name Value
2692 +Qcache_queries_in_cache 1
2693 +show status like "Qcache_inserts";
2694 +Variable_name Value
2696 +show status like "Qcache_hits";
2697 +Variable_name Value
2699 +prepare stmt from '(#456(
2708 +show status like "Qcache_queries_in_cache";
2709 +Variable_name Value
2710 +Qcache_queries_in_cache 2
2711 +show status like "Qcache_inserts";
2712 +Variable_name Value
2714 +show status like "Qcache_hits";
2715 +Variable_name Value
2717 +prepare stmt from '/*test*/(-- comment in first(
2726 +show status like "Qcache_queries_in_cache";
2727 +Variable_name Value
2728 +Qcache_queries_in_cache 2
2729 +show status like "Qcache_inserts";
2730 +Variable_name Value
2732 +show status like "Qcache_hits";
2733 +Variable_name Value
2735 +prepare stmt from 'select "test",a from t1';
2746 +show status like "Qcache_queries_in_cache";
2747 +Variable_name Value
2748 +Qcache_queries_in_cache 3
2749 +show status like "Qcache_inserts";
2750 +Variable_name Value
2752 +show status like "Qcache_hits";
2753 +Variable_name Value
2755 +prepare stmt from 'select "test /* internal \'comment\' */",a from t1';
2757 +test /* internal 'comment' */ a
2758 +test /* internal 'comment' */ 1
2759 +test /* internal 'comment' */ 2
2760 +test /* internal 'comment' */ 3
2761 +show status like "Qcache_queries_in_cache";
2762 +Variable_name Value
2763 +Qcache_queries_in_cache 4
2764 +show status like "Qcache_inserts";
2765 +Variable_name Value
2767 +show status like "Qcache_hits";
2768 +Variable_name Value
2770 +prepare stmt from 'select "test #internal comment" ,a from t1';
2772 +test #internal comment a
2773 +test #internal comment 1
2774 +test #internal comment 2
2775 +test #internal comment 3
2776 +show status like "Qcache_queries_in_cache";
2777 +Variable_name Value
2778 +Qcache_queries_in_cache 5
2779 +show status like "Qcache_inserts";
2780 +Variable_name Value
2782 +show status like "Qcache_hits";
2783 +Variable_name Value
2785 +prepare stmt from 'select "test #internal comment" #external comment
2788 +test #internal comment a
2789 +test #internal comment 1
2790 +test #internal comment 2
2791 +test #internal comment 3
2792 +show status like "Qcache_queries_in_cache";
2793 +Variable_name Value
2794 +Qcache_queries_in_cache 5
2795 +show status like "Qcache_inserts";
2796 +Variable_name Value
2798 +show status like "Qcache_hits";
2799 +Variable_name Value
2802 +SET GLOBAL query_cache_size= default;
2803 +set global query_cache_strip_comments=OFF;
2805 +++ b/mysql-test/t/percona_query_cache_with_comments.test
2807 +--disable_ps_protocol
2808 +set global query_cache_strip_comments=ON;
2809 +-- source include/percona_query_cache_with_comments_begin.inc
2810 +-- source include/percona_query_cache_with_comments.inc
2811 +-- source include/percona_query_cache_with_comments_end.inc
2813 +++ b/mysql-test/t/percona_query_cache_with_comments_crash.test
2815 +-- source include/have_query_cache.inc
2816 +set GLOBAL query_cache_size=1355776;
2818 +drop table if exists t1;
2820 +create table t1 (a int not null);
2821 +insert into t1 values (1),(2),(3);
2822 +flush query cache; # This crashed in some versions
2823 +flush query cache; # This crashed in some versions
2826 +( select * from t1 );
2827 +/*!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 */;
2828 +/* only comment */;
2829 +let query=# only comment
2832 +let query=-- only comment
2836 +SET GLOBAL query_cache_size= default;
2838 +++ b/mysql-test/t/percona_query_cache_with_comments_disable.test
2840 +-- source include/percona_query_cache_with_comments_begin.inc
2841 +-- source include/percona_query_cache_with_comments.inc
2842 +-- source include/percona_query_cache_with_comments_end.inc
2844 +++ b/mysql-test/t/percona_query_cache_with_comments_prepared_statements.test
2846 +-- source include/have_query_cache.inc
2848 +set GLOBAL query_cache_size=1355776;
2850 +# Reset query cache variables.
2851 +flush query cache; # This crashed in some versions
2852 +flush query cache; # This crashed in some versions
2856 +drop table if exists t1;
2860 +# First simple test
2863 +create table t1 (a int not null);
2864 +insert into t1 values (1),(2),(3);
2866 +set global query_cache_strip_comments=ON;
2868 +show status like "Qcache_queries_in_cache";
2869 +show status like "Qcache_inserts";
2870 +show status like "Qcache_hits";
2872 +prepare stmt from '/* with comment */ select * from t1';
2875 +show status like "Qcache_queries_in_cache";
2876 +show status like "Qcache_inserts";
2877 +show status like "Qcache_hits";
2885 +show status like "Qcache_queries_in_cache";
2886 +show status like "Qcache_inserts";
2887 +show status like "Qcache_hits";
2889 +prepare stmt from 'select * from t1';
2892 +show status like "Qcache_queries_in_cache";
2893 +show status like "Qcache_inserts";
2894 +show status like "Qcache_hits";
2896 +prepare stmt from 'select * /*internal comment*/from t1';
2899 +show status like "Qcache_queries_in_cache";
2900 +show status like "Qcache_inserts";
2901 +show status like "Qcache_hits";
2903 +prepare stmt from 'select * /*internal comment*/ from t1';
2906 +show status like "Qcache_queries_in_cache";
2907 +show status like "Qcache_inserts";
2908 +show status like "Qcache_hits";
2910 +prepare stmt from 'select * from t1 /* at the end */';
2913 +show status like "Qcache_queries_in_cache";
2914 +show status like "Qcache_inserts";
2915 +show status like "Qcache_hits";
2917 +prepare stmt from 'select * from t1 /* with "quote" */';
2920 +show status like "Qcache_queries_in_cache";
2921 +show status like "Qcache_inserts";
2922 +show status like "Qcache_hits";
2924 +prepare stmt from 'select * from t1 /* with \'quote\' */';
2927 +show status like "Qcache_queries_in_cache";
2928 +show status like "Qcache_inserts";
2929 +show status like "Qcache_hits";
2931 +prepare stmt from 'select * from t1 # 123
2935 +show status like "Qcache_queries_in_cache";
2936 +show status like "Qcache_inserts";
2937 +show status like "Qcache_hits";
2939 +prepare stmt from 'select * from t1 # 123 with "quote"
2943 +show status like "Qcache_queries_in_cache";
2944 +show status like "Qcache_inserts";
2945 +show status like "Qcache_hits";
2947 +prepare stmt from 'select * from t1 # 123 with \'quote\'
2951 +show status like "Qcache_queries_in_cache";
2952 +show status like "Qcache_inserts";
2953 +show status like "Qcache_hits";
2955 +prepare stmt from 'select * from t1
2960 +show status like "Qcache_queries_in_cache";
2961 +show status like "Qcache_inserts";
2962 +show status like "Qcache_hits";
2964 +prepare stmt from '#456
2970 +show status like "Qcache_queries_in_cache";
2971 +show status like "Qcache_inserts";
2972 +show status like "Qcache_hits";
2974 +prepare stmt from 'select * from t1 -- 123
2978 +show status like "Qcache_queries_in_cache";
2979 +show status like "Qcache_inserts";
2980 +show status like "Qcache_hits";
2982 +prepare stmt from 'select * from t1
2987 +show status like "Qcache_queries_in_cache";
2988 +show status like "Qcache_inserts";
2989 +show status like "Qcache_hits";
2991 +prepare stmt from '-- comment in first
2997 +show status like "Qcache_queries_in_cache";
2998 +show status like "Qcache_inserts";
2999 +show status like "Qcache_hits";
3001 +prepare stmt from '(#456(
3007 +show status like "Qcache_queries_in_cache";
3008 +show status like "Qcache_inserts";
3009 +show status like "Qcache_hits";
3011 +prepare stmt from '/*test*/(-- comment in first(
3017 +show status like "Qcache_queries_in_cache";
3018 +show status like "Qcache_inserts";
3019 +show status like "Qcache_hits";
3021 +prepare stmt from 'select "test",a from t1';
3025 +show status like "Qcache_queries_in_cache";
3026 +show status like "Qcache_inserts";
3027 +show status like "Qcache_hits";
3029 +prepare stmt from 'select "test /* internal \'comment\' */",a from t1';
3032 +show status like "Qcache_queries_in_cache";
3033 +show status like "Qcache_inserts";
3034 +show status like "Qcache_hits";
3036 +prepare stmt from 'select "test #internal comment" ,a from t1';
3039 +show status like "Qcache_queries_in_cache";
3040 +show status like "Qcache_inserts";
3041 +show status like "Qcache_hits";
3043 +prepare stmt from 'select "test #internal comment" #external comment
3047 +show status like "Qcache_queries_in_cache";
3048 +show status like "Qcache_inserts";
3049 +show status like "Qcache_hits";
3052 +SET GLOBAL query_cache_size= default;
3053 +set global query_cache_strip_comments=OFF;
3055 +++ b/mysql-test/t/percona_status_wait_query_cache_mutex.test
3057 +--source include/have_query_cache.inc
3058 +--source include/have_debug.inc
3059 +--source include/have_debug_sync.inc
3060 +SET GLOBAL query_cache_size=1355776;
3061 +--source include/percona_query_cache_with_comments_clear.inc
3062 +--let try_lock_mutex_query=SELECT "try_lock_mutex_query" as action
3064 +--connect (mutex_locked_conn, localhost, root,,)
3065 +--connect (try_mutex_lock_conn, localhost, root,,)
3067 +--connection mutex_locked_conn
3068 +SET DEBUG_SYNC='after_query_cache_mutex SIGNAL mutex_locked WAIT_FOR unlock_mutex';
3069 +send SELECT "mutex_locked_query" as action;
3071 +--connection default
3072 +SET DEBUG_SYNC='now WAIT_FOR mutex_locked';
3074 +--connection try_mutex_lock_conn
3075 +SET DEBUG_SYNC='before_query_cache_mutex SIGNAL try_lock_mutex';
3076 +send_eval $try_lock_mutex_query;
3078 +--connection default
3079 +SET DEBUG_SYNC='now WAIT_FOR try_lock_mutex';
3080 +eval SELECT SQL_NO_CACHE state FROM INFORMATION_SCHEMA.PROCESSLIST WHERE info='$try_lock_mutex_query';
3081 +SET DEBUG_SYNC='now SIGNAL unlock_mutex';
3083 +--connection mutex_locked_conn
3085 +--connection try_mutex_lock_conn
3088 +--connection default
3089 +--disconnect mutex_locked_conn
3090 +--disconnect try_mutex_lock_conn
3091 +SET GLOBAL query_cache_size=0;
3092 --- a/mysql-test/r/mysqld--help-notwin.result
3093 +++ b/mysql-test/r/mysqld--help-notwin.result
3094 @@ -500,6 +500,10 @@
3095 The minimum size for blocks allocated by the query cache
3096 --query-cache-size=#
3097 The memory allocated to store results from old queries
3098 + --query-cache-strip-comments
3099 + Enable and disable optimisation "strip comment for query
3100 + cache" - optimisation strip all comments from query while
3101 + search query result in query cache
3102 --query-cache-type=name
3103 OFF = Don't cache or retrieve results. ON = Cache all
3104 results except SELECT SQL_NO_CACHE ... queries. DEMAND =
3106 query-cache-limit 1048576
3107 query-cache-min-res-unit 4096
3109 +query-cache-strip-comments FALSE
3111 query-cache-wlock-invalidate FALSE
3112 query-prealloc-size 8192
3114 +++ b/mysql-test/r/percona_status_wait_query_cache_mutex.result
3116 +SET GLOBAL query_cache_size=1355776;
3121 +SET DEBUG_SYNC='after_query_cache_mutex SIGNAL mutex_locked WAIT_FOR unlock_mutex';
3122 +SELECT "mutex_locked_query" as action;
3123 +SET DEBUG_SYNC='now WAIT_FOR mutex_locked';
3124 +SET DEBUG_SYNC='before_query_cache_mutex SIGNAL try_lock_mutex';
3125 +SELECT "try_lock_mutex_query" as action;
3126 +SET DEBUG_SYNC='now WAIT_FOR try_lock_mutex';
3127 +SELECT SQL_NO_CACHE state FROM INFORMATION_SCHEMA.PROCESSLIST WHERE info='SELECT "try_lock_mutex_query" as action';
3129 +Waiting on query cache mutex
3130 +SET DEBUG_SYNC='now SIGNAL unlock_mutex';
3134 +try_lock_mutex_query
3135 +SET GLOBAL query_cache_size=0;
3137 +++ b/mysql-test/r/percona_bug856404.result
3139 +DROP TABLE IF EXISTS table17_int;
3140 +DROP TABLE IF EXISTS table30_int;
3141 +CREATE TABLE `table17_int` (pk integer auto_increment primary key, `col_char_10_not_null_key` char(10), `col_enum_not_null_key` int);
3142 +CREATE TABLE `table30_int` (pk integer auto_increment primary key, `col_enum_not_null_key` int);
3143 +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*/;
3145 +DROP TABLE table17_int;
3146 +DROP TABLE table30_int;
3148 +++ b/mysql-test/t/percona_bug856404-master.opt
3150 +--query-cache-size=10M --query-cache-strip-comments
3152 +++ b/mysql-test/t/percona_bug856404.test
3154 +########################################################################
3155 +# Bug #856404: Crash when query_cache_strip_comments enabled
3156 +########################################################################
3159 +DROP TABLE IF EXISTS table17_int;
3160 +DROP TABLE IF EXISTS table30_int;
3163 +CREATE TABLE `table17_int` (pk integer auto_increment primary key, `col_char_10_not_null_key` char(10), `col_enum_not_null_key` int);
3164 +CREATE TABLE `table30_int` (pk integer auto_increment primary key, `col_enum_not_null_key` int);
3165 +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*/;
3167 +DROP TABLE table17_int;
3168 +DROP TABLE table30_int;