summaryrefslogtreecommitdiff
path: root/mysql-test/include
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-03-31 16:40:29 +0400
committerAlexander Barkov <bar@mariadb.org>2017-03-31 16:40:29 +0400
commitf00a314f9a659399eff392c4b635d1c381b9badb (patch)
treec64e89699dcc22b4ba3a62f83f21252c486617ce /mysql-test/include
parente191833d758e89d282aea2d84126c9ca10036571 (diff)
parent2f3d4bd566b5e377fe8a1749c14050b0a0e083d0 (diff)
downloadmariadb-git-f00a314f9a659399eff392c4b635d1c381b9badb.tar.gz
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Diffstat (limited to 'mysql-test/include')
-rw-r--r--mysql-test/include/check-testcase.test4
-rw-r--r--mysql-test/include/gap_lock_error_all.inc27
-rw-r--r--mysql-test/include/gap_lock_error_cleanup.inc1
-rw-r--r--mysql-test/include/gap_lock_error_init.inc24
-rw-r--r--mysql-test/include/gap_lock_error_select.inc89
-rw-r--r--mysql-test/include/gap_lock_error_update.inc91
-rw-r--r--mysql-test/include/mtr_warnings.sql1
7 files changed, 237 insertions, 0 deletions
diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test
index abac3861c66..3b2c2a46590 100644
--- a/mysql-test/include/check-testcase.test
+++ b/mysql-test/include/check-testcase.test
@@ -79,5 +79,9 @@ if (!$tmp) {
}
call mtr.check_testcase();
+
+let $datadir=`select @@datadir`;
+list_files $datadir mysql_upgrade_info;
+
--enable_query_log
diff --git a/mysql-test/include/gap_lock_error_all.inc b/mysql-test/include/gap_lock_error_all.inc
new file mode 100644
index 00000000000..fc69dfb56f0
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_all.inc
@@ -0,0 +1,27 @@
+--source include/have_partition.inc
+--source include/gap_lock_error_init.inc
+
+let $select_lock=for update;
+let $autocommit = 0;
+--source include/gap_lock_error_select.inc
+let $autocommit = 1;
+--source include/gap_lock_error_select.inc
+
+let $select_lock=lock in share mode;
+let $autocommit = 0;
+--source include/gap_lock_error_select.inc
+let $autocommit = 1;
+--source include/gap_lock_error_select.inc
+
+let $select_lock=;
+let $autocommit = 0;
+--source include/gap_lock_error_select.inc
+let $autocommit = 1;
+--source include/gap_lock_error_select.inc
+
+let $autocommit = 0;
+--source include/gap_lock_error_update.inc
+let $autocommit = 1;
+--source include/gap_lock_error_update.inc
+
+--source include/gap_lock_error_cleanup.inc
diff --git a/mysql-test/include/gap_lock_error_cleanup.inc b/mysql-test/include/gap_lock_error_cleanup.inc
new file mode 100644
index 00000000000..8558b5a528f
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_cleanup.inc
@@ -0,0 +1 @@
+drop table gap1, gap2, gap3, gap4;
diff --git a/mysql-test/include/gap_lock_error_init.inc b/mysql-test/include/gap_lock_error_init.inc
new file mode 100644
index 00000000000..26aa852a398
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_init.inc
@@ -0,0 +1,24 @@
+eval CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
+ PRIMARY KEY (id1, id2, id3),
+ INDEX i (c1)) ENGINE=$engine;
+CREATE TABLE gap2 like gap1;
+eval CREATE TABLE gap3 (id INT, value INT,
+ PRIMARY KEY (id),
+ UNIQUE KEY ui(value)) ENGINE=$engine;
+eval CREATE TABLE gap4 (id INT, value INT,
+ PRIMARY KEY (id)) ENGINE=$engine
+ PARTITION BY HASH(id) PARTITIONS 2;
+--disable_query_log
+let $max = 1000;
+let $i = 1;
+while ($i <= $max) {
+ eval INSERT INTO gap1 (id1, id2, id3, c1, value)
+ VALUES ($i div 2, $i div 10, $i, $i, $i);
+ eval INSERT INTO gap2 (id1, id2, id3, c1, value)
+ VALUES ($i div 2, $i div 10, $i, $i, $i);
+ inc $i;
+}
+--enable_query_log
+
+insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
+insert into gap4 values (1,1), (2,2),(3,3),(4,4),(5,5);
diff --git a/mysql-test/include/gap_lock_error_select.inc b/mysql-test/include/gap_lock_error_select.inc
new file mode 100644
index 00000000000..91db9bed68a
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_select.inc
@@ -0,0 +1,89 @@
+eval set session autocommit=$autocommit;
+let $is_gaplock_target = `SELECT @@autocommit = 0 && '$select_lock' != '' && '$expect_gap_lock_errors' = 1`;
+
+if ($is_gaplock_target)
+{
+# rnd_init
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 limit 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where value != 100 limit 1 $select_lock;
+# index_read_map
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 $select_lock;
+# read_range_first
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 and id3 != 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 and id3
+ between 1 and 3 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 order by id3 asc
+ limit 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 order by id3 desc
+ limit 1 $select_lock;
+# index_first
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 order by id1 asc limit 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 $select_lock;
+# index_last
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 order by id1 desc limit 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 order by id1 desc, id2 desc, id3 desc
+ limit 1 $select_lock;
+# secondary index lookup
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 force index(i) where c1=1 $select_lock;
+# unique index lookup, ensure no gap lock errors as this is effectively a
+# single point select that does not lock ranges or gaps of keys
+eval select * from gap3 force index(ui) where value=1 $select_lock;
+# primary key lookup, ensure no gap lock errors as these are effectively
+# single point selects that do not lock ranges or gaps of keys
+eval select * from gap1 where id1=1 and id2=1 and id3=1 $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+ order by c1 $select_lock;
+eval select * from gap3 where id=1 $select_lock;
+eval select * from gap4 where id=1 $select_lock;
+eval select * from gap4 where id in (1, 2, 3) $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap4 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap4 where id between 3 and 7 $select_lock;
+}
+
+if (!$is_gaplock_target)
+{
+eval select * from gap1 limit 1 $select_lock;
+eval select * from gap1 where value != 100 limit 1 $select_lock;
+eval select * from gap1 where id1=1 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 and id3 != 1 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 and id3
+ between 1 and 3 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 order by id3 asc
+ limit 1 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 order by id3 desc
+ limit 1 $select_lock;
+eval select * from gap1 order by id1 asc limit 1 $select_lock;
+eval select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 $select_lock;
+eval select * from gap1 order by id1 desc limit 1 $select_lock;
+eval select * from gap1 order by id1 desc, id2 desc, id3 desc
+ limit 1 $select_lock;
+eval select * from gap1 force index(i) where c1=1 $select_lock;
+eval select * from gap3 force index(ui) where value=1 $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3=1 $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+ order by c1 $select_lock;
+eval select * from gap3 where id=1 $select_lock;
+eval select * from gap4 where id=1 $select_lock;
+eval select * from gap4 where id in (1, 2, 3) $select_lock;
+eval select * from gap4 $select_lock;
+eval select * from gap4 where id between 3 and 7 $select_lock;
+}
diff --git a/mysql-test/include/gap_lock_error_update.inc b/mysql-test/include/gap_lock_error_update.inc
new file mode 100644
index 00000000000..d456cf81588
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_update.inc
@@ -0,0 +1,91 @@
+eval set session autocommit=$autocommit;
+let $is_gaplock_target = `SELECT @@autocommit = 0 && '$expect_gap_lock_errors' = 1`;
+
+if ($is_gaplock_target)
+{
+## single-table insert,update,delete
+insert into gap1 (id1, id2, id3) values (-1,-1,-1);
+insert into gap1 (id1, id2, id3) values (-1,-1,-1)
+ on duplicate key update value=100;
+--error ER_UNKNOWN_ERROR
+update gap1 set value=100 where id1=1;
+update gap1 set value=100 where id1=1 and id2=1 and id3=1;
+--error ER_UNKNOWN_ERROR
+delete from gap1 where id1=2;
+delete from gap1 where id1=-1 and id2=-1 and id3=-1;
+commit;
+
+## multi-table statements (preventing all gap locks with autocommit)
+# insert into select
+--error ER_UNKNOWN_ERROR
+insert into gap2 select * from gap1;
+--error ER_UNKNOWN_ERROR
+insert into gap2 select * from gap1 where id1=1;
+insert into gap2 select * from gap1 where id1=1 and id2=1 and id3=1;
+
+# create table select
+create table t4 select * from gap1 where id1=1 and id2=1 and id3=1;
+drop table t4;
+--error ER_UNKNOWN_ERROR
+create table t4 select * from gap1;
+--error ER_UNKNOWN_ERROR
+create table t4 select * from gap1 where id1=1;
+
+# update join
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 set gap1.value=100 where gap2.id1=3
+ and gap2.id2=3 and gap2.id3=3;
+--error ER_UNKNOWN_ERROR
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 set gap1.value=100 where gap2.id1=3;
+--error ER_UNKNOWN_ERROR
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 join gap3 on gap1.id1=gap3.id
+ set gap1.value=100 where gap2.id1=3;
+--error ER_UNKNOWN_ERROR
+update gap1 set gap1.value= (select count(*) from gap2);
+
+# delete join
+delete gap1 from gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 where gap2.id1=3
+ and gap2.id2=3 and gap2.id3=3;
+--error ER_UNKNOWN_ERROR
+delete gap1 from gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 where gap2.id1=3;
+
+# select join / self join
+--error ER_UNKNOWN_ERROR
+select * from gap1, gap2 limit 1 for update;
+--error ER_UNKNOWN_ERROR
+select * from gap1 a, gap1 b limit 1 for update;
+
+# unique secondary key
+create table u1(
+ c1 int,
+ c2 int,
+ c3 int,
+ c4 int,
+ primary key (c1, c2, c3),
+ unique key (c3, c1)
+);
+begin;
+insert into u1 values (1,1,1,1);
+commit;
+begin;
+insert into u1 values (1,2,1,1) on duplicate key update c4=10;
+commit;
+begin;
+select * from u1 where c3=1 and c1 = 1 for update;
+--error ER_UNKNOWN_ERROR
+select * from u1 where c3=1 for update;
+commit;
+drop table u1;
+}
+
+if (!$is_gaplock_target)
+{
+# autocommit doesn't prevent single table operations
+insert into gap1 (id1, id2, id3) values (-1,-1,-1);
+insert into gap1 (id1, id2, id3) values (-1,-1,-1)
+ on duplicate key update value=100;
+update gap1 set value=100 where id1=1;
+update gap1 set value=100 where id1=1 and id2=1 and id3=1;
+delete from gap1 where id1=2;
+delete from gap1 where id1=-1 and id2=-1 and id3=-1;
+commit;
+}
diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql
index 635dfd9b8c3..71c693961c1 100644
--- a/mysql-test/include/mtr_warnings.sql
+++ b/mysql-test/include/mtr_warnings.sql
@@ -284,6 +284,7 @@ CREATE DEFINER=root@localhost
PROCEDURE add_suppression(pattern VARCHAR(255))
BEGIN
INSERT INTO test_suppressions (pattern) VALUES (pattern);
+ FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions;
END
*/||