+--- /dev/null
++++ b/mysql-test/include/percona_query_cache_with_comments.inc
+@@ -0,0 +1,95 @@
++--source include/percona_query_cache_with_comments_clear.inc
++let $query=/* with comment first */select * from t1;
++eval $query;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=# with comment first
++select * from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=-- with comment first
++select * from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=/* with comment first and "quote" */select * from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=# with comment first and "quote"
++select * from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=-- with comment first and "quote"
++select * from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=
++ /* with comment and whitespaces first */select * from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=
++ # with comment and whitespaces first
++select * from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=
++ -- with comment and whitespaces first
++select * from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $internal=* internal comment *;
++
++let $query=select * /$internal/ from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++let $query=select */$internal/ from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++let $query=select */$internal/from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $internal=* internal comment with "quote" *;
++
++let $query=select * /$internal/ from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++let $query=select */$internal/ from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++let $query=select */$internal/from t1;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1
++;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1 ;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1 ;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1
++/* comment in the end */;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1
++/* *\/ */;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1
++/* comment in the end */
++;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1 #comment in the end;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1 #comment in the end
++;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1 -- comment in the end;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select * from t1 -- comment in the end
++;
++--source include/percona_query_cache_with_comments_eval.inc
++
++let $query=select ' \' ' from t1;
++--source include/percona_query_cache_with_comments_eval.inc
+--- /dev/null
++++ b/mysql-test/include/percona_query_cache_with_comments_begin.inc
+@@ -0,0 +1,12 @@
++-- source include/have_query_cache.inc
++
++set GLOBAL query_cache_size=1355776;
++
++--disable_warnings
++drop table if exists t1;
++--enable_warnings
++
++create table t1 (a int not null);
++insert into t1 values (1),(2),(3);
++
++--source include/percona_query_cache_with_comments_clear.inc
+--- /dev/null
++++ b/mysql-test/include/percona_query_cache_with_comments_clear.inc
+@@ -0,0 +1,5 @@
++# Reset query cache variables.
++flush query cache; # This crashed in some versions
++flush query cache; # This crashed in some versions
++reset query cache;
++flush status;
+--- /dev/null
++++ b/mysql-test/include/percona_query_cache_with_comments_end.inc
+@@ -0,0 +1,3 @@
++DROP TABLE t1;
++SET GLOBAL query_cache_size=default;
++set global query_cache_strip_comments=OFF;
+--- /dev/null
++++ b/mysql-test/include/percona_query_cache_with_comments_eval.inc
+@@ -0,0 +1,7 @@
++echo -----------------------------------------------------;
++echo $query;
++echo -----------------------------------------------------;
++--source include/percona_query_cache_with_comments_show.inc
++eval $query;
++eval $query;
++--source include/percona_query_cache_with_comments_show.inc
+--- /dev/null
++++ b/mysql-test/include/percona_query_cache_with_comments_show.inc
+@@ -0,0 +1,8 @@
++let $show=show status like "Qcache_queries_in_cache";
++eval $show;
++let $show=show status like "Qcache_inserts";
++eval $show;
++let $show=show status like "Qcache_hits";
++eval $show;
++
++
+--- /dev/null
++++ b/mysql-test/r/percona_query_cache_with_comments.result
+@@ -0,0 +1,866 @@
++set global query_cache_strip_comments=ON;
++set GLOBAL query_cache_size=1355776;
++drop table if exists t1;
++create table t1 (a int not null);
++insert into t1 values (1),(2),(3);
++flush query cache;
++flush query cache;
++reset query cache;
++flush status;
++flush query cache;
++flush query cache;
++reset query cache;
++flush status;
++/* with comment first */select * from t1;
++a
++1
++2
++3
++-----------------------------------------------------
++/* with comment first */select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 0
++/* with comment first */select * from t1;
++a
++1
++2
++3
++/* with comment first */select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 2
++-----------------------------------------------------
++# with comment first
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 2
++# with comment first
++select * from t1;
++a
++1
++2
++3
++# with comment first
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 4
++-----------------------------------------------------
++-- with comment first
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 4
++-- with comment first
++select * from t1;
++a
++1
++2
++3
++-- with comment first
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 6
++-----------------------------------------------------
++/* with comment first and "quote" */select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 6
++/* with comment first and "quote" */select * from t1;
++a
++1
++2
++3
++/* with comment first and "quote" */select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 8
++-----------------------------------------------------
++# with comment first and "quote"
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 8
++# with comment first and "quote"
++select * from t1;
++a
++1
++2
++3
++# with comment first and "quote"
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 10
++-----------------------------------------------------
++-- with comment first and "quote"
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 10
++-- with comment first and "quote"
++select * from t1;
++a
++1
++2
++3
++-- with comment first and "quote"
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 12
++-----------------------------------------------------
++/* with comment and whitespaces first */select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 12
++/* with comment and whitespaces first */select * from t1;
++a
++1
++2
++3
++/* with comment and whitespaces first */select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 14
++-----------------------------------------------------
++# with comment and whitespaces first
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 14
++# with comment and whitespaces first
++select * from t1;
++a
++1
++2
++3
++# with comment and whitespaces first
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 16
++-----------------------------------------------------
++-- with comment and whitespaces first
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 16
++-- with comment and whitespaces first
++select * from t1;
++a
++1
++2
++3
++-- with comment and whitespaces first
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 18
++-----------------------------------------------------
++select * /* internal comment */ from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 18
++select * /* internal comment */ from t1;
++a
++1
++2
++3
++select * /* internal comment */ from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 20
++-----------------------------------------------------
++select */* internal comment */ from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 20
++select */* internal comment */ from t1;
++a
++1
++2
++3
++select */* internal comment */ from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 22
++-----------------------------------------------------
++select */* internal comment */from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 22
++select */* internal comment */from t1;
++a
++1
++2
++3
++select */* internal comment */from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 24
++-----------------------------------------------------
++select * /* internal comment with "quote" */ from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 24
++select * /* internal comment with "quote" */ from t1;
++a
++1
++2
++3
++select * /* internal comment with "quote" */ from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 26
++-----------------------------------------------------
++select */* internal comment with "quote" */ from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 26
++select */* internal comment with "quote" */ from t1;
++a
++1
++2
++3
++select */* internal comment with "quote" */ from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 28
++-----------------------------------------------------
++select */* internal comment with "quote" */from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 28
++select */* internal comment with "quote" */from t1;
++a
++1
++2
++3
++select */* internal comment with "quote" */from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 30
++-----------------------------------------------------
++select * from t1
++
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 30
++select * from t1
++;
++a
++1
++2
++3
++select * from t1
++;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 32
++-----------------------------------------------------
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 32
++select * from t1 ;
++a
++1
++2
++3
++select * from t1 ;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 34
++-----------------------------------------------------
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 34
++select * from t1 ;
++a
++1
++2
++3
++select * from t1 ;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 36
++-----------------------------------------------------
++select * from t1
++/* comment in the end */
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 36
++select * from t1
++/* comment in the end */;
++a
++1
++2
++3
++select * from t1
++/* comment in the end */;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 38
++-----------------------------------------------------
++select * from t1
++/* *\/ */
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 38
++select * from t1
++/* *\/ */;
++a
++1
++2
++3
++select * from t1
++/* *\/ */;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 40
++-----------------------------------------------------
++select * from t1
++/* comment in the end */
++
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 40
++select * from t1
++/* comment in the end */
++;
++a
++1
++2
++3
++select * from t1
++/* comment in the end */
++;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 42
++-----------------------------------------------------
++select * from t1 #comment in the end
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 42
++select * from t1 #comment in the end;
++a
++1
++2
++3
++select * from t1 #comment in the end;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 44
++-----------------------------------------------------
++select * from t1 #comment in the end
++
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 44
++select * from t1 #comment in the end
++;
++a
++1
++2
++3
++select * from t1 #comment in the end
++;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 46
++-----------------------------------------------------
++select * from t1 -- comment in the end
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 46
++select * from t1 -- comment in the end;
++a
++1
++2
++3
++select * from t1 -- comment in the end;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 48
++-----------------------------------------------------
++select * from t1 -- comment in the end
++
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 48
++select * from t1 -- comment in the end
++;
++a
++1
++2
++3
++select * from t1 -- comment in the end
++;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 50
++-----------------------------------------------------
++select ' \' ' from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 50
++select ' \' ' from t1;
++'
++ '
++ '
++ '
++select ' \' ' from t1;
++'
++ '
++ '
++ '
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 2
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 2
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 51
++DROP TABLE t1;
++SET GLOBAL query_cache_size=default;
++set global query_cache_strip_comments=OFF;
+--- /dev/null
++++ b/mysql-test/r/percona_query_cache_with_comments_crash.result
+@@ -0,0 +1,21 @@
++set GLOBAL query_cache_size=1355776;
++drop table if exists t1;
++create table t1 (a int not null);
++insert into t1 values (1),(2),(3);
++flush query cache;
++flush query cache;
++reset query cache;
++flush status;
++( select * from t1 );
++a
++1
++2
++3
++/*!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 */;
++/* only comment */;
++# only comment
++;
++-- only comment
++;
++DROP TABLE t1;
++SET GLOBAL query_cache_size= default;
+--- /dev/null
++++ b/mysql-test/r/percona_query_cache_with_comments_disable.result
+@@ -0,0 +1,865 @@
++set GLOBAL query_cache_size=1355776;
++drop table if exists t1;
++create table t1 (a int not null);
++insert into t1 values (1),(2),(3);
++flush query cache;
++flush query cache;
++reset query cache;
++flush status;
++flush query cache;
++flush query cache;
++reset query cache;
++flush status;
++/* with comment first */select * from t1;
++a
++1
++2
++3
++-----------------------------------------------------
++/* with comment first */select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 0
++/* with comment first */select * from t1;
++a
++1
++2
++3
++/* with comment first */select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 2
++-----------------------------------------------------
++# with comment first
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 2
++# with comment first
++select * from t1;
++a
++1
++2
++3
++# with comment first
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 2
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 2
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 2
++-----------------------------------------------------
++-- with comment first
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 2
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 2
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 2
++-- with comment first
++select * from t1;
++a
++1
++2
++3
++-- with comment first
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 3
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 3
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 2
++-----------------------------------------------------
++/* with comment first and "quote" */select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 3
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 3
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 2
++/* with comment first and "quote" */select * from t1;
++a
++1
++2
++3
++/* with comment first and "quote" */select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 4
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 4
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 3
++-----------------------------------------------------
++# with comment first and "quote"
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 4
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 4
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 3
++# with comment first and "quote"
++select * from t1;
++a
++1
++2
++3
++# with comment first and "quote"
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 5
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 5
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 3
++-----------------------------------------------------
++-- with comment first and "quote"
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 5
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 5
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 3
++-- with comment first and "quote"
++select * from t1;
++a
++1
++2
++3
++-- with comment first and "quote"
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 6
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 6
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 3
++-----------------------------------------------------
++/* with comment and whitespaces first */select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 6
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 6
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 3
++/* with comment and whitespaces first */select * from t1;
++a
++1
++2
++3
++/* with comment and whitespaces first */select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 7
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 7
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 4
++-----------------------------------------------------
++# with comment and whitespaces first
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 7
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 7
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 4
++# with comment and whitespaces first
++select * from t1;
++a
++1
++2
++3
++# with comment and whitespaces first
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 8
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 8
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 4
++-----------------------------------------------------
++-- with comment and whitespaces first
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 8
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 8
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 4
++-- with comment and whitespaces first
++select * from t1;
++a
++1
++2
++3
++-- with comment and whitespaces first
++select * from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 9
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 9
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 4
++-----------------------------------------------------
++select * /* internal comment */ from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 9
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 9
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 4
++select * /* internal comment */ from t1;
++a
++1
++2
++3
++select * /* internal comment */ from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 10
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 10
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 5
++-----------------------------------------------------
++select */* internal comment */ from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 10
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 10
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 5
++select */* internal comment */ from t1;
++a
++1
++2
++3
++select */* internal comment */ from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 11
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 11
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 6
++-----------------------------------------------------
++select */* internal comment */from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 11
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 11
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 6
++select */* internal comment */from t1;
++a
++1
++2
++3
++select */* internal comment */from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 12
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 12
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 7
++-----------------------------------------------------
++select * /* internal comment with "quote" */ from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 12
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 12
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 7
++select * /* internal comment with "quote" */ from t1;
++a
++1
++2
++3
++select * /* internal comment with "quote" */ from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 13
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 13
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 8
++-----------------------------------------------------
++select */* internal comment with "quote" */ from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 13
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 13
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 8
++select */* internal comment with "quote" */ from t1;
++a
++1
++2
++3
++select */* internal comment with "quote" */ from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 14
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 14
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 9
++-----------------------------------------------------
++select */* internal comment with "quote" */from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 14
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 14
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 9
++select */* internal comment with "quote" */from t1;
++a
++1
++2
++3
++select */* internal comment with "quote" */from t1;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 15
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 15
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 10
++-----------------------------------------------------
++select * from t1
++
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 15
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 15
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 10
++select * from t1
++;
++a
++1
++2
++3
++select * from t1
++;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 16
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 16
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 11
++-----------------------------------------------------
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 16
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 16
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 11
++select * from t1 ;
++a
++1
++2
++3
++select * from t1 ;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 16
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 16
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 13
++-----------------------------------------------------
++select * from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 16
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 16
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 13
++select * from t1 ;
++a
++1
++2
++3
++select * from t1 ;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 16
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 16
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 15
++-----------------------------------------------------
++select * from t1
++/* comment in the end */
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 16
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 16
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 15
++select * from t1
++/* comment in the end */;
++a
++1
++2
++3
++select * from t1
++/* comment in the end */;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 17
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 17
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 16
++-----------------------------------------------------
++select * from t1
++/* *\/ */
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 17
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 17
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 16
++select * from t1
++/* *\/ */;
++a
++1
++2
++3
++select * from t1
++/* *\/ */;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 18
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 18
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 17
++-----------------------------------------------------
++select * from t1
++/* comment in the end */
++
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 18
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 18
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 17
++select * from t1
++/* comment in the end */
++;
++a
++1
++2
++3
++select * from t1
++/* comment in the end */
++;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 18
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 18
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 19
++-----------------------------------------------------
++select * from t1 #comment in the end
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 18
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 18
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 19
++select * from t1 #comment in the end;
++a
++1
++2
++3
++select * from t1 #comment in the end;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 19
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 19
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 20
++-----------------------------------------------------
++select * from t1 #comment in the end
++
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 19
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 19
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 20
++select * from t1 #comment in the end
++;
++a
++1
++2
++3
++select * from t1 #comment in the end
++;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 19
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 19
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 22
++-----------------------------------------------------
++select * from t1 -- comment in the end
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 19
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 19
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 22
++select * from t1 -- comment in the end;
++a
++1
++2
++3
++select * from t1 -- comment in the end;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 20
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 20
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 23
++-----------------------------------------------------
++select * from t1 -- comment in the end
++
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 20
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 20
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 23
++select * from t1 -- comment in the end
++;
++a
++1
++2
++3
++select * from t1 -- comment in the end
++;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 20
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 20
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 25
++-----------------------------------------------------
++select ' \' ' from t1
++-----------------------------------------------------
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 20
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 20
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 25
++select ' \' ' from t1;
++'
++ '
++ '
++ '
++select ' \' ' from t1;
++'
++ '
++ '
++ '
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 21
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 21
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 26
++DROP TABLE t1;
++SET GLOBAL query_cache_size=default;
++set global query_cache_strip_comments=OFF;
+--- /dev/null
++++ b/mysql-test/r/percona_query_cache_with_comments_prepared_statements.result
+@@ -0,0 +1,396 @@
++set GLOBAL query_cache_size=1355776;
++flush query cache;
++flush query cache;
++reset query cache;
++flush status;
++drop table if exists t1;
++create table t1 (a int not null);
++insert into t1 values (1),(2),(3);
++set global query_cache_strip_comments=ON;
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 0
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 0
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 0
++prepare stmt from '/* with comment */ select * from t1';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 0
++execute stmt;
++a
++1
++2
++3
++execute stmt;
++a
++1
++2
++3
++execute stmt;
++a
++1
++2
++3
++execute stmt;
++a
++1
++2
++3
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 5
++prepare stmt from 'select * from t1';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 6
++prepare stmt from 'select * /*internal comment*/from t1';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 7
++prepare stmt from 'select * /*internal comment*/ from t1';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 8
++prepare stmt from 'select * from t1 /* at the end */';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 9
++prepare stmt from 'select * from t1 /* with "quote" */';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 10
++prepare stmt from 'select * from t1 /* with \'quote\' */';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 11
++prepare stmt from 'select * from t1 # 123
++';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 12
++prepare stmt from 'select * from t1 # 123 with "quote"
++';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 13
++prepare stmt from 'select * from t1 # 123 with \'quote\'
++';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 14
++prepare stmt from 'select * from t1
++# 123
++';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 15
++prepare stmt from '#456
++select * from t1
++# 123
++';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 16
++prepare stmt from 'select * from t1 -- 123
++';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 17
++prepare stmt from 'select * from t1
++-- 123
++';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 18
++prepare stmt from '-- comment in first
++select * from t1
++# 123
++';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 1
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 1
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 19
++prepare stmt from '(#456(
++select * from t1
++# 123(
++)';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 2
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 2
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 19
++prepare stmt from '/*test*/(-- comment in first(
++select * from t1
++-- 123 asdasd
++/* test */)';
++execute stmt;
++a
++1
++2
++3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 2
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 2
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 20
++prepare stmt from 'select "test",a from t1';
++execute stmt;
++test a
++test 1
++test 2
++test 3
++execute stmt;
++test a
++test 1
++test 2
++test 3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 3
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 3
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 21
++prepare stmt from 'select "test /* internal \'comment\' */",a from t1';
++execute stmt;
++test /* internal 'comment' */ a
++test /* internal 'comment' */ 1
++test /* internal 'comment' */ 2
++test /* internal 'comment' */ 3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 4
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 4
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 21
++prepare stmt from 'select "test #internal comment" ,a from t1';
++execute stmt;
++test #internal comment a
++test #internal comment 1
++test #internal comment 2
++test #internal comment 3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 5
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 5
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 21
++prepare stmt from 'select "test #internal comment" #external comment
++,a from t1';
++execute stmt;
++test #internal comment a
++test #internal comment 1
++test #internal comment 2
++test #internal comment 3
++show status like "Qcache_queries_in_cache";
++Variable_name Value
++Qcache_queries_in_cache 5
++show status like "Qcache_inserts";
++Variable_name Value
++Qcache_inserts 5
++show status like "Qcache_hits";
++Variable_name Value
++Qcache_hits 22
++DROP TABLE t1;
++SET GLOBAL query_cache_size= default;
++set global query_cache_strip_comments=OFF;
+--- /dev/null
++++ b/mysql-test/t/percona_query_cache_with_comments.test
+@@ -0,0 +1,5 @@
++--disable_ps_protocol
++set global query_cache_strip_comments=ON;
++-- source include/percona_query_cache_with_comments_begin.inc
++-- source include/percona_query_cache_with_comments.inc
++-- source include/percona_query_cache_with_comments_end.inc
+--- /dev/null
++++ b/mysql-test/t/percona_query_cache_with_comments_crash.test
+@@ -0,0 +1,22 @@
++-- source include/have_query_cache.inc
++set GLOBAL query_cache_size=1355776;
++--disable_warnings
++drop table if exists t1;
++--enable_warnings
++create table t1 (a int not null);
++insert into t1 values (1),(2),(3);
++flush query cache; # This crashed in some versions
++flush query cache; # This crashed in some versions
++reset query cache;
++flush status;
++( select * from t1 );
++/*!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 */;
++/* only comment */;
++let query=# only comment
++;
++eval $query;
++let query=-- only comment
++;
++eval $query;
++DROP TABLE t1;
++SET GLOBAL query_cache_size= default;
+--- /dev/null
++++ b/mysql-test/t/percona_query_cache_with_comments_disable.test
+@@ -0,0 +1,3 @@
++-- source include/percona_query_cache_with_comments_begin.inc
++-- source include/percona_query_cache_with_comments.inc
++-- source include/percona_query_cache_with_comments_end.inc
+--- /dev/null
++++ b/mysql-test/t/percona_query_cache_with_comments_prepared_statements.test
+@@ -0,0 +1,208 @@
++-- source include/have_query_cache.inc
++
++set GLOBAL query_cache_size=1355776;
++
++# Reset query cache variables.
++flush query cache; # This crashed in some versions
++flush query cache; # This crashed in some versions
++reset query cache;
++flush status;
++--disable_warnings
++drop table if exists t1;
++--enable_warnings
++
++#
++# First simple test
++#
++
++create table t1 (a int not null);
++insert into t1 values (1),(2),(3);
++
++set global query_cache_strip_comments=ON;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from '/* with comment */ select * from t1';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++execute stmt;
++execute stmt;
++execute stmt;
++execute stmt;
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * /*internal comment*/from t1';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * /*internal comment*/ from t1';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1 /* at the end */';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1 /* with "quote" */';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1 /* with \'quote\' */';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1 # 123
++';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1 # 123 with "quote"
++';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1 # 123 with \'quote\'
++';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1
++# 123
++';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from '#456
++select * from t1
++# 123
++';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1 -- 123
++';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select * from t1
++-- 123
++';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from '-- comment in first
++select * from t1
++# 123
++';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from '(#456(
++select * from t1
++# 123(
++)';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from '/*test*/(-- comment in first(
++select * from t1
++-- 123 asdasd
++/* test */)';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select "test",a from t1';
++execute stmt;
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select "test /* internal \'comment\' */",a from t1';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select "test #internal comment" ,a from t1';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++prepare stmt from 'select "test #internal comment" #external comment
++,a from t1';
++execute stmt;
++
++show status like "Qcache_queries_in_cache";
++show status like "Qcache_inserts";
++show status like "Qcache_hits";
++
++DROP TABLE t1;
++SET GLOBAL query_cache_size= default;
++set global query_cache_strip_comments=OFF;
+--- /dev/null
++++ b/mysql-test/t/percona_status_wait_query_cache_mutex.test
+@@ -0,0 +1,35 @@
++--source include/have_query_cache.inc
++--source include/have_debug.inc
++--source include/have_debug_sync.inc
++SET GLOBAL query_cache_size=1355776;
++--source include/percona_query_cache_with_comments_clear.inc
++--let try_lock_mutex_query=SELECT "try_lock_mutex_query" as action
++
++--connect (mutex_locked_conn, localhost, root,,)
++--connect (try_mutex_lock_conn, localhost, root,,)
++
++--connection mutex_locked_conn
++SET DEBUG_SYNC='after_query_cache_mutex SIGNAL mutex_locked WAIT_FOR unlock_mutex';
++send SELECT "mutex_locked_query" as action;
++
++--connection default
++SET DEBUG_SYNC='now WAIT_FOR mutex_locked';
++
++--connection try_mutex_lock_conn
++SET DEBUG_SYNC='before_query_cache_mutex SIGNAL try_lock_mutex';
++send_eval $try_lock_mutex_query;
++
++--connection default
++SET DEBUG_SYNC='now WAIT_FOR try_lock_mutex';
++eval SELECT SQL_NO_CACHE state FROM INFORMATION_SCHEMA.PROCESSLIST WHERE info='$try_lock_mutex_query';
++SET DEBUG_SYNC='now SIGNAL unlock_mutex';
++
++--connection mutex_locked_conn
++reap;
++--connection try_mutex_lock_conn
++reap;
++
++--connection default
++--disconnect mutex_locked_conn
++--disconnect try_mutex_lock_conn
++SET GLOBAL query_cache_size=0;
+--- a/mysql-test/r/mysqld--help-notwin.result
++++ b/mysql-test/r/mysqld--help-notwin.result
+@@ -500,6 +500,10 @@
+ The minimum size for blocks allocated by the query cache
+ --query-cache-size=#
+ The memory allocated to store results from old queries
++ --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
+ --query-cache-type=name
+ OFF = Don't cache or retrieve results. ON = Cache all
+ results except SELECT SQL_NO_CACHE ... queries. DEMAND =
+@@ -942,6 +946,7 @@
+ query-cache-limit 1048576
+ query-cache-min-res-unit 4096
+ query-cache-size 0
++query-cache-strip-comments FALSE
+ query-cache-type ON
+ query-cache-wlock-invalidate FALSE
+ query-prealloc-size 8192
+--- /dev/null
++++ b/mysql-test/r/percona_status_wait_query_cache_mutex.result
+@@ -0,0 +1,20 @@
++SET GLOBAL query_cache_size=1355776;
++flush query cache;
++flush query cache;
++reset query cache;
++flush status;
++SET DEBUG_SYNC='after_query_cache_mutex SIGNAL mutex_locked WAIT_FOR unlock_mutex';
++SELECT "mutex_locked_query" as action;
++SET DEBUG_SYNC='now WAIT_FOR mutex_locked';
++SET DEBUG_SYNC='before_query_cache_mutex SIGNAL try_lock_mutex';
++SELECT "try_lock_mutex_query" as action;
++SET DEBUG_SYNC='now WAIT_FOR try_lock_mutex';
++SELECT SQL_NO_CACHE state FROM INFORMATION_SCHEMA.PROCESSLIST WHERE info='SELECT "try_lock_mutex_query" as action';
++state
++Waiting on query cache mutex
++SET DEBUG_SYNC='now SIGNAL unlock_mutex';
++action
++mutex_locked_query
++action
++try_lock_mutex_query
++SET GLOBAL query_cache_size=0;
+--- /dev/null
++++ b/mysql-test/r/percona_bug856404.result
+@@ -0,0 +1,8 @@
++DROP TABLE IF EXISTS table17_int;
++DROP TABLE IF EXISTS table30_int;
++CREATE TABLE `table17_int` (pk integer auto_increment primary key, `col_char_10_not_null_key` char(10), `col_enum_not_null_key` int);
++CREATE TABLE `table30_int` (pk integer auto_increment primary key, `col_enum_not_null_key` int);
++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*/;
++pk
++DROP TABLE table17_int;
++DROP TABLE table30_int;
+--- /dev/null
++++ b/mysql-test/t/percona_bug856404-master.opt
+@@ -0,0 +1 @@
++--query-cache-size=10M --query-cache-strip-comments
+--- /dev/null
++++ b/mysql-test/t/percona_bug856404.test
+@@ -0,0 +1,15 @@
++########################################################################
++# Bug #856404: Crash when query_cache_strip_comments enabled
++########################################################################
++
++--disable_warnings
++DROP TABLE IF EXISTS table17_int;
++DROP TABLE IF EXISTS table30_int;
++--enable_warnings
++
++CREATE TABLE `table17_int` (pk integer auto_increment primary key, `col_char_10_not_null_key` char(10), `col_enum_not_null_key` int);
++CREATE TABLE `table30_int` (pk integer auto_increment primary key, `col_enum_not_null_key` int);
++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*/;
++
++DROP TABLE table17_int;
++DROP TABLE table30_int;