summaryrefslogtreecommitdiff
path: root/mysql-test/suite
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2010-08-04 10:39:53 +0200
committerunknown <knielsen@knielsen-hq.org>2010-08-04 10:39:53 +0200
commit3f1c763a94cd25c4810692983f6e61b528e21268 (patch)
treed8f9632933303f9bdf8cdc875613ca99f51ecbcb /mysql-test/suite
parenta74d04671d23fa65bd610184965cc2974ec41cf9 (diff)
parent0c6afe17dceb926b5c757157308188e540caec1e (diff)
downloadmariadb-git-3f1c763a94cd25c4810692983f6e61b528e21268.tar.gz
Merge XtraDB from Percona-Server-5.1.47-11 into MariaDB.
Diffstat (limited to 'mysql-test/suite')
-rw-r--r--mysql-test/suite/innodb/r/innodb-autoinc-44030.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb.result32
-rw-r--r--mysql-test/suite/innodb/r/innodb_bug21704.result12
-rw-r--r--mysql-test/suite/innodb/r/innodb_misc1.result1
-rw-r--r--mysql-test/suite/innodb/t/disabled.def8
-rw-r--r--mysql-test/suite/innodb/t/innodb-autoinc-44030.test2
-rw-r--r--mysql-test/suite/innodb/t/innodb.test11
-rw-r--r--mysql-test/suite/innodb/t/innodb_misc1.test2
-rw-r--r--mysql-test/suite/percona/disabled.def13
-rw-r--r--mysql-test/suite/percona/percona_innodb_deadlock_count.result28
-rw-r--r--mysql-test/suite/percona/percona_innodb_deadlock_count.test49
-rw-r--r--mysql-test/suite/percona/percona_innodb_doublewrite_file-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_innodb_doublewrite_file.result4
-rw-r--r--mysql-test/suite/percona/percona_innodb_doublewrite_file.test2
-rw-r--r--mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-slave.opt1
-rw-r--r--mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.result103
-rw-r--r--mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test139
-rw-r--r--mysql-test/suite/percona/percona_log_slow_slave_statements-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_log_slow_slave_statements-slave.opt1
-rw-r--r--mysql-test/suite/percona/percona_log_slow_slave_statements.result86
-rw-r--r--mysql-test/suite/percona/percona_log_slow_slave_statements.test160
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments.inc.backup88
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments.result866
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments.test4
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments_crash.result21
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments_crash.test22
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments_disable.result865
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments_disable.test3
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments_prepared_statements.result396
-rw-r--r--mysql-test/suite/percona/percona_query_cache_with_comments_prepared_statements.test208
-rw-r--r--mysql-test/suite/percona/percona_show_temp_tables.result58
-rw-r--r--mysql-test/suite/percona/percona_show_temp_tables.test65
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-control_global_slow-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-control_global_slow.result12
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test12
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-log_slow_filter-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.result25
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test33
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.result9
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test13
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-long_query_time-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-long_query_time.result22
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-long_query_time.test19
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.result12
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test20
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.result25
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test33
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.result24
-rw-r--r--mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test21
-rw-r--r--mysql-test/suite/percona/percona_suppress_log_warning_1592-master.opt1
-rw-r--r--mysql-test/suite/percona/percona_suppress_log_warning_1592.result28
-rw-r--r--mysql-test/suite/percona/percona_suppress_log_warning_1592.test46
-rw-r--r--mysql-test/suite/percona/percona_xtradb_admin_command.result6
-rw-r--r--mysql-test/suite/percona/percona_xtradb_admin_command.test3
-rw-r--r--mysql-test/suite/percona/percona_xtradb_bug317074.result4
-rw-r--r--mysql-test/suite/percona/percona_xtradb_bug317074.test45
61 files changed, 3646 insertions, 31 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-autoinc-44030.result b/mysql-test/suite/innodb/r/innodb-autoinc-44030.result
index c0695bf0be0..54e972843f5 100644
--- a/mysql-test/suite/innodb/r/innodb-autoinc-44030.result
+++ b/mysql-test/suite/innodb/r/innodb-autoinc-44030.result
@@ -13,18 +13,18 @@ d1
1
2
INSERT INTO t1 VALUES(null);
-Got one of the listed errors
ALTER TABLE t1 AUTO_INCREMENT = 3;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`d1`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES(null);
SELECT * FROM t1;
d1
1
2
3
+4
DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result
index c6f6f352743..345da7a0163 100644
--- a/mysql-test/suite/innodb/r/innodb.result
+++ b/mysql-test/suite/innodb/r/innodb.result
@@ -691,14 +691,16 @@ count(*)
select count(*) from t1 where sca_pic is null;
count(*)
2
-alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
+alter table t1 drop index sca_pic;
+alter table t1 add index sca_pic (cat_code, sca_pic);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
count(*)
1
select count(*) from t1 where cat_code='E';
count(*)
0
-alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
+alter table t1 drop index sca_pic;
+alter table t1 add index (sca_pic, cat_code);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
count(*)
1
@@ -1357,7 +1359,7 @@ insert t2 select * from t1;
insert t3 select * from t1;
checksum table t1, t2, t3, t4 quick;
Table Checksum
-test.t1 2948697075
+test.t1 3442722830
test.t2 NULL
test.t3 NULL
test.t4 NULL
@@ -1365,17 +1367,17 @@ Warnings:
Error 1146 Table 'test.t4' doesn't exist
checksum table t1, t2, t3, t4;
Table Checksum
-test.t1 2948697075
-test.t2 2948697075
-test.t3 2948697075
+test.t1 3442722830
+test.t2 3442722830
+test.t3 3442722830
test.t4 NULL
Warnings:
Error 1146 Table 'test.t4' doesn't exist
checksum table t1, t2, t3, t4 extended;
Table Checksum
-test.t1 2948697075
-test.t2 2948697075
-test.t3 2948697075
+test.t1 3442722830
+test.t2 3442722830
+test.t3 3442722830
test.t4 NULL
Warnings:
Error 1146 Table 'test.t4' doesn't exist
@@ -1432,7 +1434,7 @@ t2 CREATE TABLE `t2` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop index id2 on t2;
drop index id on t2;
-Got one of the listed errors
+ERROR HY000: Cannot drop index 'id': needed in a foreign key constraint
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
@@ -1662,7 +1664,7 @@ count(*)
drop table t1;
SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
variable_value
-512
+8191
SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size';
variable_value
16384
@@ -1690,9 +1692,10 @@ variable_value - @innodb_row_lock_time_max_orig
SELECT variable_value - @innodb_row_lock_time_avg_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg';
variable_value - @innodb_row_lock_time_avg_orig
0
+SET @innodb_sync_spin_loops_orig = @@innodb_sync_spin_loops;
show variables like "innodb_sync_spin_loops";
Variable_name Value
-innodb_sync_spin_loops 20
+innodb_sync_spin_loops 30
set global innodb_sync_spin_loops=1000;
show variables like "innodb_sync_spin_loops";
Variable_name Value
@@ -1705,10 +1708,11 @@ set global innodb_sync_spin_loops=20;
show variables like "innodb_sync_spin_loops";
Variable_name Value
innodb_sync_spin_loops 20
+set global innodb_sync_spin_loops=@innodb_sync_spin_loops_orig;
SET @old_innodb_thread_concurrency= @@global.innodb_thread_concurrency;
show variables like "innodb_thread_concurrency";
Variable_name Value
-innodb_thread_concurrency 8
+innodb_thread_concurrency 0
set global innodb_thread_concurrency=1001;
Warnings:
Warning 1292 Truncated incorrect thread_concurrency value: '1001'
@@ -2301,6 +2305,8 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (v varchar(10), c char(10)) row_format=fixed;
+Warnings:
+Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
diff --git a/mysql-test/suite/innodb/r/innodb_bug21704.result b/mysql-test/suite/innodb/r/innodb_bug21704.result
index b8e0b15d50d..ffbfa8a337e 100644
--- a/mysql-test/suite/innodb/r/innodb_bug21704.result
+++ b/mysql-test/suite/innodb/r/innodb_bug21704.result
@@ -25,8 +25,8 @@ ALTER TABLE t1 CHANGE a c INT;
ERROR HY000: Error on rename of '#sql-temporary' to './test/t1' (errno: 150)
# Ensure that online column rename works.
ALTER TABLE t1 CHANGE b c INT;
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 3
+info: Records: 3 Duplicates: 0 Warnings: 0
# Test renaming the column in the referencing table
@@ -34,8 +34,8 @@ ALTER TABLE t2 CHANGE a c INT;
ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150)
# Ensure that online column rename works.
ALTER TABLE t2 CHANGE b c INT;
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 3
+info: Records: 3 Duplicates: 0 Warnings: 0
# Test with self-referential constraints
@@ -45,8 +45,8 @@ ALTER TABLE t3 CHANGE b d INT;
ERROR HY000: Error on rename of '#sql-temporary' to './test/t3' (errno: 150)
# Ensure that online column rename works.
ALTER TABLE t3 CHANGE c d INT;
-affected rows: 0
-info: Records: 0 Duplicates: 0 Warnings: 0
+affected rows: 3
+info: Records: 3 Duplicates: 0 Warnings: 0
# Cleanup.
diff --git a/mysql-test/suite/innodb/r/innodb_misc1.result b/mysql-test/suite/innodb/r/innodb_misc1.result
index 40d13c9726a..214e79de985 100644
--- a/mysql-test/suite/innodb/r/innodb_misc1.result
+++ b/mysql-test/suite/innodb/r/innodb_misc1.result
@@ -763,6 +763,7 @@ t1 CREATE TABLE `t1` (
CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
DROP TABLE t1,t2;
+SET SESSION innodb_strict_mode = on;
CREATE TABLE t1 (
c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
diff --git a/mysql-test/suite/innodb/t/disabled.def b/mysql-test/suite/innodb/t/disabled.def
index 90c9bc5b38e..cae02f606d6 100644
--- a/mysql-test/suite/innodb/t/disabled.def
+++ b/mysql-test/suite/innodb/t/disabled.def
@@ -10,9 +10,5 @@
#
##############################################################################
-innodb : Bug#53306 2010-04-30 VasilDimov valgrind warnings
-innodb_bug52663 : Waiting for merge with XtraDB
-innodb_bug51920 : Waiting for merge with XtraDB
-innodb_bug48024 : Waiting for merge with XtraDB
-innodb_bug49164 : Waiting for merge with XtraDB
-innodb_bug54044 : Waiting for merge with XtraDB
+#innodb : Bug#53306 2010-04-30 VasilDimov valgrind warnings
+innodb_bug48024 : Waiting for merge with Percona Server; bug fixed in innodb_plugin in MySQL 5.1.48
diff --git a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test
index 2524ceb4009..bfde243c495 100644
--- a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test
+++ b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test
@@ -27,7 +27,7 @@ SELECT * FROM t1;
# longer results in the two data dictionaries being out of sync. If they
# revert their changes then this check for ER_AUTOINC_READ_FAILED will need
# to be enabled. Also, see http://bugs.mysql.com/bug.php?id=47621.
--- error ER_AUTOINC_READ_FAILED,1467
+# -- error ER_AUTOINC_READ_FAILED,1467
INSERT INTO t1 VALUES(null);
ALTER TABLE t1 AUTO_INCREMENT = 3;
SHOW CREATE TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb.test b/mysql-test/suite/innodb/t/innodb.test
index 480183b9e2d..743f47e1ccc 100644
--- a/mysql-test/suite/innodb/t/innodb.test
+++ b/mysql-test/suite/innodb/t/innodb.test
@@ -427,11 +427,13 @@ INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca
select count(*) from t1 where sca_code = 'PD';
select count(*) from t1 where sca_code <= 'PD';
select count(*) from t1 where sca_pic is null;
-alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic);
+alter table t1 drop index sca_pic;
+alter table t1 add index sca_pic (cat_code, sca_pic);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
select count(*) from t1 where cat_code='E';
-alter table t1 drop index sca_pic, add index (sca_pic, cat_code);
+alter table t1 drop index sca_pic;
+alter table t1 add index (sca_pic, cat_code);
select count(*) from t1 where sca_code='PD' and sca_pic is null;
select count(*) from t1 where sca_pic >= 'n';
select sca_pic from t1 where sca_pic is null;
@@ -1124,7 +1126,7 @@ show create table t2;
create index id2 on t2 (id);
show create table t2;
drop index id2 on t2;
---error 1025,1025
+--error ER_DROP_INDEX_FK
drop index id on t2;
show create table t2;
drop table t2;
@@ -1292,6 +1294,7 @@ drop table t1;
# Test for testable InnoDB status variables. This test
# uses previous ones(pages_created, rows_deleted, ...).
+--replace_result 8192 8191
SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size';
SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted';
@@ -1306,6 +1309,7 @@ SELECT variable_value - @innodb_row_lock_time_max_orig FROM information_schema.g
SELECT variable_value - @innodb_row_lock_time_avg_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg';
# Test for innodb_sync_spin_loops variable
+SET @innodb_sync_spin_loops_orig = @@innodb_sync_spin_loops;
show variables like "innodb_sync_spin_loops";
set global innodb_sync_spin_loops=1000;
show variables like "innodb_sync_spin_loops";
@@ -1313,6 +1317,7 @@ set global innodb_sync_spin_loops=0;
show variables like "innodb_sync_spin_loops";
set global innodb_sync_spin_loops=20;
show variables like "innodb_sync_spin_loops";
+set global innodb_sync_spin_loops=@innodb_sync_spin_loops_orig;
# Test for innodb_thread_concurrency variable
SET @old_innodb_thread_concurrency= @@global.innodb_thread_concurrency;
diff --git a/mysql-test/suite/innodb/t/innodb_misc1.test b/mysql-test/suite/innodb/t/innodb_misc1.test
index 30f9c129570..1bebd5411bc 100644
--- a/mysql-test/suite/innodb/t/innodb_misc1.test
+++ b/mysql-test/suite/innodb/t/innodb_misc1.test
@@ -1021,6 +1021,8 @@ DROP TABLE t1,t2;
#
# Bug #21101 (Prints wrong error message if max row size is too large)
#
+#from innodb-1.0.8, any size is passed without innodb_strict_mode.
+SET SESSION innodb_strict_mode = on;
--error 1118
CREATE TABLE t1 (
c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
diff --git a/mysql-test/suite/percona/disabled.def b/mysql-test/suite/percona/disabled.def
new file mode 100644
index 00000000000..4f35807b7a1
--- /dev/null
+++ b/mysql-test/suite/percona/disabled.def
@@ -0,0 +1,13 @@
+percona_suppress_log_warning_1592: Feature not merged into MariaDB
+percona_log_slow_slave_statements: Feature not merged into MariaDB
+percona_log_slow_slave_statements-and-use_global_long_query_time: Feature not merged into MariaDB
+percona_slow_query_log-control_global_slow: Feature not merged into MariaDB
+percona_slow_query_log-microseconds_in_slow_query_log: Feature not merged into MariaDB
+percona_query_cache_with_comments: Feature not merged into MariaDB
+percona_query_cache_with_comments_prepared_statements: Feature not merged into MariaDB
+percona_show_temp_tables: Feature not merged into MariaDB
+percona_slow_query_log-use_global_long_query_time: Feature not merged into MariaDB
+percona_query_cache_with_comments_disable: Feature not merged into MariaDB
+
+percona_slow_query_log-log_slow_verbosity: InnoDB filtering information not fully merged into MariaDB
+
diff --git a/mysql-test/suite/percona/percona_innodb_deadlock_count.result b/mysql-test/suite/percona/percona_innodb_deadlock_count.result
new file mode 100644
index 00000000000..4ad6fd433fe
--- /dev/null
+++ b/mysql-test/suite/percona/percona_innodb_deadlock_count.result
@@ -0,0 +1,28 @@
+# Establish connection con1 (user=root)
+# Establish connection con2 (user=root)
+# Establish connection con3 (user=root)
+# Drop test table
+drop table if exists t;
+# Create test table
+create table t(a INT PRIMARY KEY, b INT) engine=InnoDB;
+# Insert two rows to test table
+insert into t values(2,1);
+insert into t values(1,2);
+# Switch to connection con1
+BEGIN;
+SELECT b FROM t WHERE a=1 FOR UPDATE;
+b
+2
+# Switch to connection con2
+BEGIN;
+SELECT b FROM t WHERE a=2 FOR UPDATE;
+b
+1
+# Switch to connection con1
+SELECT b FROM t WHERE a=2 FOR UPDATE;
+# Switch to connection con2
+SELECT b FROM t WHERE a=1 FOR UPDATE;
+# Switch to connection con3
+1
+# Drop test table
+drop table t;
diff --git a/mysql-test/suite/percona/percona_innodb_deadlock_count.test b/mysql-test/suite/percona/percona_innodb_deadlock_count.test
new file mode 100644
index 00000000000..b0882a18dc1
--- /dev/null
+++ b/mysql-test/suite/percona/percona_innodb_deadlock_count.test
@@ -0,0 +1,49 @@
+--source include/have_innodb.inc
+--echo # Establish connection con1 (user=root)
+connect (con1,localhost,root,,);
+--echo # Establish connection con2 (user=root)
+connect (con2,localhost,root,,);
+--echo # Establish connection con3 (user=root)
+connect (con3,localhost,root,,);
+--echo # Drop test table
+--disable_warnings
+drop table if exists t;
+--enable_warnings
+disable_abort_on_error;
+
+--echo # Create test table
+create table t(a INT PRIMARY KEY, b INT) engine=InnoDB;
+--echo # Insert two rows to test table
+insert into t values(2,1);
+insert into t values(1,2);
+
+#--echo # Save current deadlock count
+let $current = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_deadlocks'`;
+
+--echo # Switch to connection con1
+connection con1;
+BEGIN; SELECT b FROM t WHERE a=1 FOR UPDATE;
+
+#show engine innodb status;
+
+--echo # Switch to connection con2
+connection con2;
+BEGIN; SELECT b FROM t WHERE a=2 FOR UPDATE;
+
+--echo # Switch to connection con1
+connection con1;
+SEND SELECT b FROM t WHERE a=2 FOR UPDATE;
+
+--echo # Switch to connection con2
+connection con2;
+SEND SELECT b FROM t WHERE a=1 FOR UPDATE;
+
+SLEEP 0.2;
+--echo # Switch to connection con3
+connection con3;
+let $result = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_deadlocks'`;
+
+let $diff = `SELECT $result - $current`;
+echo $diff;
+--echo # Drop test table
+drop table t;
diff --git a/mysql-test/suite/percona/percona_innodb_doublewrite_file-master.opt b/mysql-test/suite/percona/percona_innodb_doublewrite_file-master.opt
new file mode 100644
index 00000000000..0f4d0c45410
--- /dev/null
+++ b/mysql-test/suite/percona/percona_innodb_doublewrite_file-master.opt
@@ -0,0 +1 @@
+--innodb_doublewrite_file=ib_doublewrite
diff --git a/mysql-test/suite/percona/percona_innodb_doublewrite_file.result b/mysql-test/suite/percona/percona_innodb_doublewrite_file.result
new file mode 100644
index 00000000000..4d086cc4498
--- /dev/null
+++ b/mysql-test/suite/percona/percona_innodb_doublewrite_file.result
@@ -0,0 +1,4 @@
+show variables like 'innodb_doublewrite%';
+Variable_name Value
+innodb_doublewrite ON
+innodb_doublewrite_file ib_doublewrite
diff --git a/mysql-test/suite/percona/percona_innodb_doublewrite_file.test b/mysql-test/suite/percona/percona_innodb_doublewrite_file.test
new file mode 100644
index 00000000000..8068d561190
--- /dev/null
+++ b/mysql-test/suite/percona/percona_innodb_doublewrite_file.test
@@ -0,0 +1,2 @@
+--source include/have_innodb.inc
+show variables like 'innodb_doublewrite%';
diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-master.opt b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-master.opt
new file mode 100644
index 00000000000..d600400af08
--- /dev/null
+++ b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_log_slow_slave_statements-master.log --long-query-time=1 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-slave.opt b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-slave.opt
new file mode 100644
index 00000000000..c79e637317b
--- /dev/null
+++ b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-slave.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_log_slow_slave_statements-slave.log --long-query-time=1 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.result b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.result
new file mode 100644
index 00000000000..c17e7a3f508
--- /dev/null
+++ b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.result
@@ -0,0 +1,103 @@
+# Activate master-slave replication
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+# Make table t for test
+DROP TABLE IF EXISTS t;
+CREATE TABLE t(id INT);
+# Start slave replication
+START SLAVE;
+INSERT INTO t VALUES (1);
+# Read information about master binlog
+# Sync(1) slave thread
+# Read and change log_slow_slave_statements to ON on slave
+show variables like 'log_slow_slave_statements';
+Variable_name Value
+log_slow_slave_statements OFF
+set global log_slow_slave_statements=ON;
+show variables like 'log_slow_slave_statements';
+Variable_name Value
+log_slow_slave_statements ON
+INSERT INTO t VALUES (2);
+# Read information about master binlog
+# Sync slave(2) thread
+# Restart slave
+STOP SLAVE;
+START SLAVE;
+INSERT INTO t VALUES (3);
+# Read information about master binlog
+# Sync(3) slave thread
+show variables like 'long_query_time';
+Variable_name Value
+long_query_time 1.000000
+show global variables like 'long_query_time';
+Variable_name Value
+long_query_time 1.000000
+show global variables like 'use_global_long_query_time';
+Variable_name Value
+use_global_long_query_time OFF
+set global long_query_time=0;
+show variables like 'long_query_time';
+Variable_name Value
+long_query_time 1.000000
+show global variables like 'long_query_time';
+Variable_name Value
+long_query_time 0.000000
+show global variables like 'use_global_long_query_time';
+Variable_name Value
+use_global_long_query_time OFF
+INSERT INTO t VALUES (4);
+# Read information about master binlog
+# Sync slave(4) thread
+show variables like 'long_query_time';
+Variable_name Value
+long_query_time 1.000000
+show global variables like 'long_query_time';
+Variable_name Value
+long_query_time 0.000000
+show global variables like 'use_global_long_query_time';
+Variable_name Value
+use_global_long_query_time OFF
+set global use_global_long_query_time=1;
+show variables like 'long_query_time';
+Variable_name Value
+long_query_time 0.000000
+show global variables like 'long_query_time';
+Variable_name Value
+long_query_time 0.000000
+show global variables like 'use_global_long_query_time';
+Variable_name Value
+use_global_long_query_time ON
+INSERT INTO t VALUES (5);
+# Read information about master binlog
+# Sync slave(5) thread
+show variables like 'long_query_time';
+Variable_name Value
+long_query_time 0.000000
+show global variables like 'long_query_time';
+Variable_name Value
+long_query_time 0.000000
+show global variables like 'use_global_long_query_time';
+Variable_name Value
+use_global_long_query_time ON
+set global long_query_time=1;
+set global use_global_long_query_time=0;
+# Analyse master slow_query_log
+0
+0
+0
+0
+0
+# Analyse slave slow_query_log
+0
+0
+0
+0
+1
+set global log_slow_slave_statements=OFF;
+DROP TABLE t;
+# Read information about master binlog
+# Sync slave(6) thread
diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test
new file mode 100644
index 00000000000..7605218e463
--- /dev/null
+++ b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test
@@ -0,0 +1,139 @@
+-- echo # Activate master-slave replication
+-- source include/master-slave.inc
+
+connection master;
+-- echo # Make table t for test
+-- disable_warnings
+DROP TABLE IF EXISTS t;
+-- enable_warnings
+CREATE TABLE t(id INT);
+
+
+-- echo # Start slave replication
+-- disable_warnings
+connection slave;
+START SLAVE;
+-- source include/wait_for_slave_to_start.inc
+-- enable_warnings
+
+#-- echo # Make insert(1) on master
+connection master;
+INSERT INTO t VALUES (1);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync(1) slave thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+
+-- echo # Read and change log_slow_slave_statements to ON on slave
+show variables like 'log_slow_slave_statements';
+set global log_slow_slave_statements=ON;
+show variables like 'log_slow_slave_statements';
+
+#-- echo # Make insert(2) on master
+connection master;
+INSERT INTO t VALUES (2);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(2) thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+-- echo # Restart slave
+STOP SLAVE;
+-- source include/wait_for_slave_to_stop.inc
+START SLAVE;
+-- source include/wait_for_slave_to_start.inc
+
+#-- echo # Make insert(3) on master
+connection master;
+INSERT INTO t VALUES (3);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync(3) slave thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+show variables like 'long_query_time';
+show global variables like 'long_query_time';
+show global variables like 'use_global_long_query_time';
+set global long_query_time=0;
+show variables like 'long_query_time';
+show global variables like 'long_query_time';
+show global variables like 'use_global_long_query_time';
+
+#-- echo # Make insert(4) on master
+connection master;
+INSERT INTO t VALUES (4);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(4) thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+show variables like 'long_query_time';
+show global variables like 'long_query_time';
+show global variables like 'use_global_long_query_time';
+set global use_global_long_query_time=1;
+show variables like 'long_query_time';
+show global variables like 'long_query_time';
+show global variables like 'use_global_long_query_time';
+
+#-- echo # Make insert(5) on master
+connection master;
+let $MASTER_DATADIR= `select @@datadir`;
+INSERT INTO t VALUES (5);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(5) thread
+connection slave;
+let $SLAVE_DATADIR= `select @@datadir`;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+show variables like 'long_query_time';
+show global variables like 'long_query_time';
+show global variables like 'use_global_long_query_time';
+set global long_query_time=1;
+set global use_global_long_query_time=0;
+
+-- echo # Analyse master slow_query_log
+let $i=5;
+let $k=1;
+let $cmd=cat ./$MASTER_DATADIR/percona_log_slow_slave_statements-master.log | grep;
+while($i)
+{
+ let $current_cmd = $cmd "INSERT INTO t VALUES ($k)" | wc -l;
+ exec $current_cmd;
+ dec $i;
+ inc $k;
+}
+
+-- echo # Analyse slave slow_query_log
+let $i=5;
+let $k=1;
+let $cmd=cat $SLAVE_DATADIR/percona_log_slow_slave_statements-slave.log | grep;
+while($i)
+{
+ let $current_cmd = $cmd "INSERT INTO t VALUES ($k)" | wc -l;
+ exec $current_cmd;
+ dec $i;
+ inc $k;
+}
+set global log_slow_slave_statements=OFF;
+
+connection master;
+DROP TABLE t;
+
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(6) thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-master.opt b/mysql-test/suite/percona/percona_log_slow_slave_statements-master.opt
new file mode 100644
index 00000000000..dd94fd90a57
--- /dev/null
+++ b/mysql-test/suite/percona/percona_log_slow_slave_statements-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_log_slow_slave_statements-master.log --long-query-time=0 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-slave.opt b/mysql-test/suite/percona/percona_log_slow_slave_statements-slave.opt
new file mode 100644
index 00000000000..e276b0bcfc8
--- /dev/null
+++ b/mysql-test/suite/percona/percona_log_slow_slave_statements-slave.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_log_slow_slave_statements-slave.log --long-query-time=0 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements.result b/mysql-test/suite/percona/percona_log_slow_slave_statements.result
new file mode 100644
index 00000000000..e3bf3e92c94
--- /dev/null
+++ b/mysql-test/suite/percona/percona_log_slow_slave_statements.result
@@ -0,0 +1,86 @@
+# Activate master-slave replication
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+# Make table t for test
+DROP TABLE IF EXISTS t;
+CREATE TABLE t(id INT);
+# Start slave replication
+START SLAVE;
+INSERT INTO t VALUES (1);
+# Read information about master binlog
+# Sync(1) slave thread
+# Read and change log_slow_slave_statements to ON on slave
+show variables like 'log_slow_slave_statements';
+Variable_name Value
+log_slow_slave_statements OFF
+set global log_slow_slave_statements=ON;
+show variables like 'log_slow_slave_statements';
+Variable_name Value
+log_slow_slave_statements ON
+INSERT INTO t VALUES (2);
+# Read information about master binlog
+# Sync slave(2) thread
+# Restart slave
+STOP SLAVE;
+START SLAVE;
+INSERT INTO t VALUES (3);
+# Read information about master binlog
+# Sync(3) slave thread
+# Read and change log_slow_slave_statements to OFF on slave
+show variables like 'log_slow_slave_statements';
+Variable_name Value
+log_slow_slave_statements ON
+set global log_slow_slave_statements=OFF;
+show variables like 'log_slow_slave_statements';
+Variable_name Value
+log_slow_slave_statements OFF
+INSERT INTO t VALUES (4);
+# Read information about master binlog
+# Sync slave(4) thread
+# Restart slave
+STOP SLAVE;
+START SLAVE;
+INSERT INTO t VALUES (5);
+# Read information about master binlog
+# Sync slave(5) thread
+# Read and change log_slow_slave_statements to ON on slave
+show variables like 'log_slow_slave_statements';
+Variable_name Value
+log_slow_slave_statements OFF
+set global log_slow_slave_statements=ON;
+show variables like 'log_slow_slave_statements';
+Variable_name Value
+log_slow_slave_statements ON
+INSERT INTO t VALUES (6);
+# Read information about master binlog
+# Sync slave(6) thread
+# Restart slave
+STOP SLAVE;
+START SLAVE;
+INSERT INTO t VALUES (7);
+# Read information about master binlog
+# Sync slave(7) thread
+# Analyse master slow_query_log
+1
+1
+1
+1
+1
+1
+1
+# Analyse slave slow_query_log
+0
+0
+1
+0
+0
+0
+1
+set global log_slow_slave_statements=OFF;
+DROP TABLE t;
+# Read information about master binlog
+# Sync slave(8) thread
diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements.test b/mysql-test/suite/percona/percona_log_slow_slave_statements.test
new file mode 100644
index 00000000000..10a030616c6
--- /dev/null
+++ b/mysql-test/suite/percona/percona_log_slow_slave_statements.test
@@ -0,0 +1,160 @@
+-- echo # Activate master-slave replication
+-- source include/master-slave.inc
+
+connection master;
+-- echo # Make table t for test
+-- disable_warnings
+DROP TABLE IF EXISTS t;
+-- enable_warnings
+CREATE TABLE t(id INT);
+
+
+-- echo # Start slave replication
+-- disable_warnings
+connection slave;
+START SLAVE;
+-- source include/wait_for_slave_to_start.inc
+-- enable_warnings
+
+#-- echo # Make insert(1) on master
+connection master;
+INSERT INTO t VALUES (1);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync(1) slave thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+
+-- echo # Read and change log_slow_slave_statements to ON on slave
+show variables like 'log_slow_slave_statements';
+set global log_slow_slave_statements=ON;
+show variables like 'log_slow_slave_statements';
+
+#-- echo # Make insert(2) on master
+connection master;
+INSERT INTO t VALUES (2);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(2) thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+-- echo # Restart slave
+STOP SLAVE;
+-- source include/wait_for_slave_to_stop.inc
+START SLAVE;
+-- source include/wait_for_slave_to_start.inc
+
+#-- echo # Make insert(3) on master
+connection master;
+INSERT INTO t VALUES (3);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync(3) slave thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+-- echo # Read and change log_slow_slave_statements to OFF on slave
+show variables like 'log_slow_slave_statements';
+set global log_slow_slave_statements=OFF;
+show variables like 'log_slow_slave_statements';
+
+#-- echo # Make insert(4) on master
+connection master;
+INSERT INTO t VALUES (4);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(4) thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+-- echo # Restart slave
+STOP SLAVE;
+-- source include/wait_for_slave_to_stop.inc
+START SLAVE;
+-- source include/wait_for_slave_to_start.inc
+
+#-- echo # Make insert(5) on master
+connection master;
+INSERT INTO t VALUES (5);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(5) thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+-- echo # Read and change log_slow_slave_statements to ON on slave
+show variables like 'log_slow_slave_statements';
+set global log_slow_slave_statements=ON;
+show variables like 'log_slow_slave_statements';
+
+#-- echo # Make insert(6) on master
+connection master;
+INSERT INTO t VALUES (6);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(6) thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+-- echo # Restart slave
+STOP SLAVE;
+-- source include/wait_for_slave_to_stop.inc
+START SLAVE;
+-- source include/wait_for_slave_to_start.inc
+
+#-- echo # Make insert(7) on master
+connection master;
+let $MASTER_DATADIR= `select @@datadir`;
+INSERT INTO t VALUES (7);
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(7) thread
+connection slave;
+let $SLAVE_DATADIR= `select @@datadir`;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
+
+-- echo # Analyse master slow_query_log
+let $i=7;
+let $k=1;
+let $cmd=cat $MASTER_DATADIR/percona_log_slow_slave_statements-master.log | grep;
+while($i)
+{
+ let $current_cmd = $cmd "INSERT INTO t VALUES ($k)" | wc -l;
+ exec $current_cmd;
+ dec $i;
+ inc $k;
+}
+
+-- echo # Analyse slave slow_query_log
+let $i=7;
+let $k=1;
+let $cmd=cat $SLAVE_DATADIR/percona_log_slow_slave_statements-slave.log | grep;
+while($i)
+{
+ let $current_cmd = $cmd "INSERT INTO t VALUES ($k)" | wc -l;
+ exec $current_cmd;
+ dec $i;
+ inc $k;
+}
+set global log_slow_slave_statements=OFF;
+
+connection master;
+DROP TABLE t;
+
+-- echo # Read information about master binlog
+let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1);
+let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1);
+
+-- echo # Sync slave(8) thread
+connection slave;
+let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`;
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments.inc.backup b/mysql-test/suite/percona/percona_query_cache_with_comments.inc.backup
new file mode 100644
index 00000000000..4b5b31e9239
--- /dev/null
+++ b/mysql-test/suite/percona/percona_query_cache_with_comments.inc.backup
@@ -0,0 +1,88 @@
+--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
+/* 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
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments.result b/mysql-test/suite/percona/percona_query_cache_with_comments.result
new file mode 100644
index 00000000000..169fdf80fef
--- /dev/null
+++ b/mysql-test/suite/percona/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;
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments.test b/mysql-test/suite/percona/percona_query_cache_with_comments.test
new file mode 100644
index 00000000000..0190f54d104
--- /dev/null
+++ b/mysql-test/suite/percona/percona_query_cache_with_comments.test
@@ -0,0 +1,4 @@
+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
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments_crash.result b/mysql-test/suite/percona/percona_query_cache_with_comments_crash.result
new file mode 100644
index 00000000000..32bd3645ec4
--- /dev/null
+++ b/mysql-test/suite/percona/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;
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments_crash.test b/mysql-test/suite/percona/percona_query_cache_with_comments_crash.test
new file mode 100644
index 00000000000..e125c75c3de
--- /dev/null
+++ b/mysql-test/suite/percona/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;
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments_disable.result b/mysql-test/suite/percona/percona_query_cache_with_comments_disable.result
new file mode 100644
index 00000000000..a13a44d9a1c
--- /dev/null
+++ b/mysql-test/suite/percona/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;
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments_disable.test b/mysql-test/suite/percona/percona_query_cache_with_comments_disable.test
new file mode 100644
index 00000000000..ad59ac3566c
--- /dev/null
+++ b/mysql-test/suite/percona/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
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments_prepared_statements.result b/mysql-test/suite/percona/percona_query_cache_with_comments_prepared_statements.result
new file mode 100644
index 00000000000..9b28b7f0b62
--- /dev/null
+++ b/mysql-test/suite/percona/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;
diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments_prepared_statements.test b/mysql-test/suite/percona/percona_query_cache_with_comments_prepared_statements.test
new file mode 100644
index 00000000000..78cb7220aff
--- /dev/null
+++ b/mysql-test/suite/percona/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;
diff --git a/mysql-test/suite/percona/percona_show_temp_tables.result b/mysql-test/suite/percona/percona_show_temp_tables.result
new file mode 100644
index 00000000000..cbcb0331896
--- /dev/null
+++ b/mysql-test/suite/percona/percona_show_temp_tables.result
@@ -0,0 +1,58 @@
+drop table if exists t1,t2,t3;
+drop database if exists showtemp;
+create database if not exists showtemp;
+use test;
+create temporary table t1(id int);
+create temporary table t2(id int);
+create temporary table showtemp.t3(id int);
+insert into t1 values(10),(20),(30),(40);
+insert into showtemp.t3 values(999);
+show temporary tables;
+Temp_tables_in_test
+t2
+t1
+show temporary tables from test;
+Temp_tables_in_test
+t2
+t1
+show temporary tables in showtemp;
+Temp_tables_in_showtemp
+t3
+select table_schema, table_name, engine, table_rows from Information_schema.temporary_tables;
+table_schema table_name engine table_rows
+showtemp t3 MyISAM 1
+test t2 MyISAM 0
+test t1 MyISAM 4
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
+table_schema table_name engine table_rows
+showtemp t3 MyISAM 1
+test t2 MyISAM 0
+test t1 MyISAM 4
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables where table_schema='showtemp';
+table_schema table_name engine table_rows
+showtemp t3 MyISAM 1
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables where table_schema='temp';
+table_schema table_name engine table_rows
+drop table if exists showtemp.t2;
+create temporary table t1(id int);
+create temporary table showtemp.t2(id int);
+show temporary tables;
+Temp_tables_in_test
+t1
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
+table_schema table_name engine table_rows
+showtemp t2 MyISAM 0
+test t1 MyISAM 0
+showtemp t3 MyISAM 1
+test t2 MyISAM 0
+test t1 MyISAM 4
+drop table showtemp.t2;
+drop table t1;
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
+table_schema table_name engine table_rows
+showtemp t3 MyISAM 1
+test t2 MyISAM 0
+test t1 MyISAM 4
+drop table t1, t2;
+drop table showtemp.t3;
+drop database showtemp;
diff --git a/mysql-test/suite/percona/percona_show_temp_tables.test b/mysql-test/suite/percona/percona_show_temp_tables.test
new file mode 100644
index 00000000000..8837df199c5
--- /dev/null
+++ b/mysql-test/suite/percona/percona_show_temp_tables.test
@@ -0,0 +1,65 @@
+# Uses GRANT commands that usually disabled in embedded server
+-- source include/not_embedded.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+#
+# Test of SHOW [GLOBAL] TEMPORARY TABLES [FROM/IN] DB and
+# Information_schema.temporary_tables and global_temporary_tables
+#
+
+connect(stcon1,localhost,root,,test);
+connect(stcon2,localhost,root,,test);
+
+connection stcon1;
+
+--disable_warnings
+drop table if exists t1,t2,t3;
+drop database if exists showtemp;
+create database if not exists showtemp;
+--enable_warnings
+
+use test;
+create temporary table t1(id int);
+create temporary table t2(id int);
+create temporary table showtemp.t3(id int);
+insert into t1 values(10),(20),(30),(40);
+insert into showtemp.t3 values(999);
+
+show temporary tables;
+# "Session" is not same value always. mysql-test cannot test it always.
+#show global temporary tables;
+show temporary tables from test;
+show temporary tables in showtemp;
+select table_schema, table_name, engine, table_rows from Information_schema.temporary_tables;
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables where table_schema='showtemp';
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables where table_schema='temp';
+
+connection stcon2;
+
+--disable_warnings
+drop table if exists showtemp.t2;
+--enable_warnings
+create temporary table t1(id int);
+create temporary table showtemp.t2(id int);
+show temporary tables;
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
+drop table showtemp.t2;
+drop table t1;
+
+disconnect stcon2;
+
+connection stcon1;
+select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
+
+drop table t1, t2;
+drop table showtemp.t3;
+drop database showtemp;
+
+connection default;
+disconnect stcon1;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow-master.opt b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow-master.opt
new file mode 100644
index 00000000000..91dd41305cd
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_slow_query_log-control_global_slow.log --long-query-time=1 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.result b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.result
new file mode 100644
index 00000000000..ced47a700f7
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.result
@@ -0,0 +1,12 @@
+SELECT sleep(2);
+sleep(2)
+0
+set global log_slow_verbosity=innodb;
+set global use_global_log_slow_control="log_slow_verbosity,long_query_time";
+SELECT sleep(2);
+sleep(2)
+0
+set global use_global_log_slow_control=none;
+set global log_slow_verbosity=microtime;
+cat MYSQLD_DATADIR/percona_slow_query_log-control_global_slow.log | grep "No InnoDB statistics available for this query" | wc -l
+1
diff --git a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test
new file mode 100644
index 00000000000..d60a2a83a1c
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test
@@ -0,0 +1,12 @@
+source include/have_innodb.inc;
+SELECT sleep(2);
+set global log_slow_verbosity=innodb;
+set global use_global_log_slow_control="log_slow_verbosity,long_query_time";
+SELECT sleep(2);
+set global use_global_log_slow_control=none;
+set global log_slow_verbosity=microtime;
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-control_global_slow.log | grep "No InnoDB statistics available for this query" | wc -l;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+exec echo '$cmd';
+exec $cmd;
diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter-master.opt b/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter-master.opt
new file mode 100644
index 00000000000..cb93f7abf05
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_slow_query_log-log_slow_filter.log --long-query-time=1 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.result b/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.result
new file mode 100644
index 00000000000..da46efb8b63
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.result
@@ -0,0 +1,25 @@
+SET GLOBAL SLOW_QUERY_LOG=OFF;
+drop table if exists t;
+# Create test table
+create table t(id INT PRIMARY KEY) engine=InnoDB;
+# Insert two rows to test table
+insert into t values(1);
+insert into t values(2);
+insert into t values(3);
+SET GLOBAL SLOW_QUERY_LOG=ON;
+SELECT sleep(2);
+sleep(2)
+0
+set log_slow_filter=full_join;
+SELECT sleep(2) union select t2.id from t as t1,t as t2;
+sleep(2)
+0
+1
+2
+3
+SELECT sleep(2);
+sleep(2)
+0
+drop table if exists t;
+cat MYSQLD_DATADIR/percona_slow_query_log-log_slow_filter.log | grep Query_time | wc -l
+2
diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test b/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test
new file mode 100644
index 00000000000..e2f9f56ca04
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test
@@ -0,0 +1,33 @@
+source include/have_innodb.inc;
+
+SET GLOBAL SLOW_QUERY_LOG=OFF;
+
+--disable_warnings
+drop table if exists t;
+--enable_warnings
+
+--echo # Create test table
+create table t(id INT PRIMARY KEY) engine=InnoDB;
+--echo # Insert two rows to test table
+insert into t values(1);
+insert into t values(2);
+insert into t values(3);
+
+SET GLOBAL SLOW_QUERY_LOG=ON;
+
+SELECT sleep(2);
+
+set log_slow_filter=full_join;
+
+SELECT sleep(2) union select t2.id from t as t1,t as t2;
+SELECT sleep(2);
+
+--disable_warnings
+drop table if exists t;
+--enable_warnings
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-log_slow_filter.log | grep Query_time | wc -l;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+exec echo '$cmd';
+exec $cmd;
diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity-master.opt b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity-master.opt
new file mode 100644
index 00000000000..8d21f40a34f
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_slow_query_log-log_slow_verbosity.log --long-query-time=1 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.result b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.result
new file mode 100644
index 00000000000..e2fba41787d
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.result
@@ -0,0 +1,9 @@
+SELECT sleep(2);
+sleep(2)
+0
+set log_slow_verbosity=innodb;
+SELECT sleep(2);
+sleep(2)
+0
+cat MYSQLD_DATADIR/percona_slow_query_log-log_slow_verbosity.log | grep "No InnoDB statistics available for this query" | wc -l
+1
diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test
new file mode 100644
index 00000000000..3a2589a8eb9
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test
@@ -0,0 +1,13 @@
+source include/have_innodb.inc;
+
+SELECT sleep(2);
+
+set log_slow_verbosity=innodb;
+
+SELECT sleep(2);
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-log_slow_verbosity.log | grep "No InnoDB statistics available for this query" | wc -l;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+exec echo '$cmd';
+exec $cmd;
diff --git a/mysql-test/suite/percona/percona_slow_query_log-long_query_time-master.opt b/mysql-test/suite/percona/percona_slow_query_log-long_query_time-master.opt
new file mode 100644
index 00000000000..473323e0bd9
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-long_query_time-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_slow_query_log-long_query_time.log --long-query-time=2 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_slow_query_log-long_query_time.result b/mysql-test/suite/percona/percona_slow_query_log-long_query_time.result
new file mode 100644
index 00000000000..87881558392
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-long_query_time.result
@@ -0,0 +1,22 @@
+SELECT sleep(1);
+sleep(1)
+0
+SELECT sleep(3);
+sleep(3)
+0
+SELECT sleep(5);
+sleep(5)
+0
+set long_query_time=4;
+SELECT sleep(1);
+sleep(1)
+0
+SELECT sleep(3);
+sleep(3)
+0
+SELECT sleep(5);
+sleep(5)
+0
+set long_query_time=2;
+cat MYSQLD_DATADIR/percona_slow_query_log-long_query_time.log | grep Query_time | wc -l
+3
diff --git a/mysql-test/suite/percona/percona_slow_query_log-long_query_time.test b/mysql-test/suite/percona/percona_slow_query_log-long_query_time.test
new file mode 100644
index 00000000000..06abf75782f
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-long_query_time.test
@@ -0,0 +1,19 @@
+source include/have_innodb.inc;
+
+SELECT sleep(1);
+SELECT sleep(3);
+SELECT sleep(5);
+
+set long_query_time=4;
+
+SELECT sleep(1);
+SELECT sleep(3);
+SELECT sleep(5);
+
+set long_query_time=2;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-long_query_time.log | grep Query_time | wc -l;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+exec echo '$cmd';
+exec $cmd;
diff --git a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log-master.opt b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log-master.opt
new file mode 100644
index 00000000000..6433539d3d1
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_slow_query_log-microseconds_in_slow_query_log.log --long-query-time=1 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.result b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.result
new file mode 100644
index 00000000000..79258fddb41
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.result
@@ -0,0 +1,12 @@
+SELECT sleep(2);
+sleep(2)
+0
+set global slow_query_log_microseconds_timestamp=ON;
+SELECT sleep(2);
+sleep(2)
+0
+set global slow_query_log_microseconds_timestamp=OFF;
+cat MYSQLD_DATADIR/percona_slow_query_log-microseconds_in_slow_query_log.log | grep -E '# Time: [0-9]+[ ]+[0-9]+:[0-\9]+:[0-9]+.[0-9]+' | wc -l
+1
+cat MYSQLD_DATADIR/percona_slow_query_log-microseconds_in_slow_query_log.log | grep -E '# Time: [0-9]+[ ]+[0-9]+:[0-\9]+:[0-9]+' | wc -l
+2
diff --git a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test
new file mode 100644
index 00000000000..294f291b292
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test
@@ -0,0 +1,20 @@
+source include/have_innodb.inc;
+
+SELECT sleep(2);
+
+set global slow_query_log_microseconds_timestamp=ON;
+
+SELECT sleep(2);
+
+set global slow_query_log_microseconds_timestamp=OFF;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-microseconds_in_slow_query_log.log | grep -E '# Time: [0-9]+[ ]+[0-9]+:[0-\9]+:[0-9]+.[0-9]+' | wc -l;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+exec echo "$cmd";
+exec $cmd;
+
+let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-microseconds_in_slow_query_log.log | grep -E '# Time: [0-9]+[ ]+[0-9]+:[0-\9]+:[0-9]+' | wc -l;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+exec echo "$cmd";
+exec $cmd;
diff --git a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit-master.opt b/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit-master.opt
new file mode 100644
index 00000000000..6f82556fb0c
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_slow_query_log-min_examined_row_limit.log --long-query-time=1 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.result b/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.result
new file mode 100644
index 00000000000..2032c07966e
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.result
@@ -0,0 +1,25 @@
+SET GLOBAL SLOW_QUERY_LOG=OFF;
+drop table if exists t;
+# Create test table
+create table t(id INT PRIMARY KEY) engine=InnoDB;
+# Insert two rows to test table
+insert into t values(1);
+insert into t values(2);
+insert into t values(3);
+SET GLOBAL SLOW_QUERY_LOG=ON;
+SELECT sleep(2);
+sleep(2)
+0
+set min_examined_row_limit=5;
+SELECT sleep(2) union select t2.id from t as t1,t as t2;
+sleep(2)
+0
+1
+2
+3
+SELECT sleep(2);
+sleep(2)
+0
+drop table if exists t;
+cat MYSQLD_DATADIR/percona_slow_query_log-min_examined_row_limit.log | grep Query_time | wc -l
+2
diff --git a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test b/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test
new file mode 100644
index 00000000000..c728e38c3b6
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test
@@ -0,0 +1,33 @@
+source include/have_innodb.inc;
+
+SET GLOBAL SLOW_QUERY_LOG=OFF;
+
+--disable_warnings
+drop table if exists t;
+--enable_warnings
+
+--echo # Create test table
+create table t(id INT PRIMARY KEY) engine=InnoDB;
+--echo # Insert two rows to test table
+insert into t values(1);
+insert into t values(2);
+insert into t values(3);
+
+SET GLOBAL SLOW_QUERY_LOG=ON;
+
+SELECT sleep(2);
+
+set min_examined_row_limit=5;
+
+SELECT sleep(2) union select t2.id from t as t1,t as t2;
+SELECT sleep(2);
+
+--disable_warnings
+drop table if exists t;
+--enable_warnings
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-min_examined_row_limit.log | grep Query_time | wc -l;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+exec echo '$cmd';
+exec $cmd;
diff --git a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time-master.opt b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time-master.opt
new file mode 100644
index 00000000000..e2f3b6f2041
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time-master.opt
@@ -0,0 +1 @@
+--slow-query-log-file=percona_slow_query_log-use_global_long_query_time.log --long-query-time=2 \ No newline at end of file
diff --git a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.result b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.result
new file mode 100644
index 00000000000..60052540faf
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.result
@@ -0,0 +1,24 @@
+SELECT sleep(1);
+sleep(1)
+0
+SELECT sleep(3);
+sleep(3)
+0
+SELECT sleep(5);
+sleep(5)
+0
+set global long_query_time=4;
+set global use_global_long_query_time=1;
+SELECT sleep(1);
+sleep(1)
+0
+SELECT sleep(3);
+sleep(3)
+0
+SELECT sleep(5);
+sleep(5)
+0
+set global long_query_time=2;
+set global use_global_long_query_time=0;
+cat MYSQLD_DATADIR/percona_slow_query_log-use_global_long_query_time.log | grep Query_time | wc -l
+3
diff --git a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test
new file mode 100644
index 00000000000..c025554f0c6
--- /dev/null
+++ b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test
@@ -0,0 +1,21 @@
+source include/have_innodb.inc;
+
+SELECT sleep(1);
+SELECT sleep(3);
+SELECT sleep(5);
+
+set global long_query_time=4;
+set global use_global_long_query_time=1;
+
+SELECT sleep(1);
+SELECT sleep(3);
+SELECT sleep(5);
+
+set global long_query_time=2;
+set global use_global_long_query_time=0;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-use_global_long_query_time.log | grep Query_time | wc -l;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+exec echo '$cmd';
+exec $cmd;
diff --git a/mysql-test/suite/percona/percona_suppress_log_warning_1592-master.opt b/mysql-test/suite/percona/percona_suppress_log_warning_1592-master.opt
new file mode 100644
index 00000000000..4658d62af60
--- /dev/null
+++ b/mysql-test/suite/percona/percona_suppress_log_warning_1592-master.opt
@@ -0,0 +1 @@
+--log-error
diff --git a/mysql-test/suite/percona/percona_suppress_log_warning_1592.result b/mysql-test/suite/percona/percona_suppress_log_warning_1592.result
new file mode 100644
index 00000000000..4715499b08f
--- /dev/null
+++ b/mysql-test/suite/percona/percona_suppress_log_warning_1592.result
@@ -0,0 +1,28 @@
+SET @old_log_warnings = @@log_warnings;
+SET @old_suppress_log_warning_1592 = @@suppress_log_warning_1592;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(20));
+SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 0;
+SET GLOBAL LOG_WARNINGS = 0;
+INSERT INTO t1 VALUES(UUID(), 'suppress_1592');
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
+SET GLOBAL LOG_WARNINGS = 1;
+INSERT INTO t1 VALUES(UUID(), 'suppress_1592');
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
+SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 1;
+SET GLOBAL LOG_WARNINGS = 0;
+INSERT INTO t1 VALUES(UUID(), 'suppress_1592');
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
+SET GLOBAL LOG_WARNINGS = 1;
+INSERT INTO t1 VALUES(UUID(), 'suppress_1592');
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
+DROP TABLE t1;
+SET GLOBAL log_warnings = @old_log_warnings;
+SET GLOBAL suppress_log_warning_1592 = @old_suppress_log_warning_1592;
+# Count the number of times the "Unsafe" message was printed
+# to the error log.
+Occurrences: 1
diff --git a/mysql-test/suite/percona/percona_suppress_log_warning_1592.test b/mysql-test/suite/percona/percona_suppress_log_warning_1592.test
new file mode 100644
index 00000000000..97fe40469fc
--- /dev/null
+++ b/mysql-test/suite/percona/percona_suppress_log_warning_1592.test
@@ -0,0 +1,46 @@
+-- source include/have_log_bin.inc
+-- source include/have_binlog_format_statement.inc
+
+SET @old_log_warnings = @@log_warnings;
+SET @old_suppress_log_warning_1592 = @@suppress_log_warning_1592;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(20));
+SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 0;
+SET GLOBAL LOG_WARNINGS = 0;
+INSERT INTO t1 VALUES(UUID(), 'suppress_1592');
+SET GLOBAL LOG_WARNINGS = 1;
+INSERT INTO t1 VALUES(UUID(), 'suppress_1592');
+SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 1;
+SET GLOBAL LOG_WARNINGS = 0;
+INSERT INTO t1 VALUES(UUID(), 'suppress_1592');
+SET GLOBAL LOG_WARNINGS = 1;
+INSERT INTO t1 VALUES(UUID(), 'suppress_1592');
+DROP TABLE t1;
+
+SET GLOBAL log_warnings = @old_log_warnings;
+SET GLOBAL suppress_log_warning_1592 = @old_suppress_log_warning_1592;
+
+let $log_error_= `SELECT @@GLOBAL.log_error`;
+if(!`select LENGTH('$log_error_')`)
+{
+ # MySQL Server on windows is started with --console and thus
+ # does not know the location of its .err log, use default location
+ let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err;
+}
+# Assign env variable LOG_ERROR
+let LOG_ERROR=$log_error_;
+
+--echo # Count the number of times the "Unsafe" message was printed
+--echo # to the error log.
+
+perl;
+ use strict;
+ my $log_error= $ENV{'LOG_ERROR'} or die "LOG_ERROR not set";
+ open(FILE, "$log_error") or die("Unable to open $log_error: $!\n");
+ my $count = () = grep(/suppress_1592/g,<FILE>);
+ print "Occurrences: $count\n";
+ close(FILE);
+EOF
diff --git a/mysql-test/suite/percona/percona_xtradb_admin_command.result b/mysql-test/suite/percona/percona_xtradb_admin_command.result
new file mode 100644
index 00000000000..26ba14f2f3b
--- /dev/null
+++ b/mysql-test/suite/percona/percona_xtradb_admin_command.result
@@ -0,0 +1,6 @@
+select * from information_schema.XTRADB_ADMIN_COMMAND;
+result_message
+No XTRA_* command in the SQL statement. Please add /*!XTRA_xxxx*/ to the SQL.
+select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_HELLO*/;
+result_message
+Hello!
diff --git a/mysql-test/suite/percona/percona_xtradb_admin_command.test b/mysql-test/suite/percona/percona_xtradb_admin_command.test
new file mode 100644
index 00000000000..5dc3fb2b33a
--- /dev/null
+++ b/mysql-test/suite/percona/percona_xtradb_admin_command.test
@@ -0,0 +1,3 @@
+--source include/have_innodb.inc
+select * from information_schema.XTRADB_ADMIN_COMMAND;
+select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_HELLO*/;
diff --git a/mysql-test/suite/percona/percona_xtradb_bug317074.result b/mysql-test/suite/percona/percona_xtradb_bug317074.result
new file mode 100644
index 00000000000..82a98844652
--- /dev/null
+++ b/mysql-test/suite/percona/percona_xtradb_bug317074.result
@@ -0,0 +1,4 @@
+SET @old_innodb_file_format=@@innodb_file_format;
+SET @old_innodb_file_per_table=@@innodb_file_per_table;
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;
diff --git a/mysql-test/suite/percona/percona_xtradb_bug317074.test b/mysql-test/suite/percona/percona_xtradb_bug317074.test
new file mode 100644
index 00000000000..91c59cefb73
--- /dev/null
+++ b/mysql-test/suite/percona/percona_xtradb_bug317074.test
@@ -0,0 +1,45 @@
+-- source include/have_innodb.inc
+
+SET @old_innodb_file_format=@@innodb_file_format;
+SET @old_innodb_file_per_table=@@innodb_file_per_table;
+let $innodb_file_format_check_orig=`select @@innodb_file_format_check`;
+SET GLOBAL innodb_file_format='Barracuda';
+SET GLOBAL innodb_file_per_table=ON;
+
+-- disable_query_log
+-- disable_result_log
+
+DROP TABLE IF EXISTS `test1`;
+CREATE TABLE IF NOT EXISTS `test1` (
+ `a` int primary key auto_increment,
+ `b` int default 0,
+ `c` char(100) default 'testtest'
+) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
+
+set autocommit=0;
+delimiter |;
+CREATE PROCEDURE insert_many(p1 int)
+BEGIN
+SET @x = 0;
+SET @y = 0;
+REPEAT
+ insert into test1 set b=1;
+ SET @x = @x + 1;
+ SET @y = @y + 1;
+ IF @y >= 1000 THEN
+ commit;
+ SET @y = 0;
+ END IF;
+UNTIL @x >= p1 END REPEAT;
+END|
+delimiter ;|
+call insert_many(100000);
+DROP PROCEDURE insert_many;
+
+# The bug is hangup at the following statement
+ALTER TABLE test1 ENGINE=MyISAM;
+
+DROP TABLE test1;
+SET GLOBAL innodb_file_format=@old_innodb_file_format;
+SET GLOBAL innodb_file_per_table=@old_innodb_file_per_table;
+eval set global innodb_file_format_check=$innodb_file_format_check_orig;