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