summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@skysql.com>2014-06-26 20:47:08 +0300
committerJan Lindström <jan.lindstrom@skysql.com>2014-06-26 20:47:08 +0300
commitc6d29cd30db9053023124bf74f17f6ee9d8e168d (patch)
treea3f90d99d29655c249a8437b421523309cb473fb /mysql-test
parent3e5994868de68f5112e5faf63188e4f53050afd5 (diff)
parentbe885ebe8c3df78d090c2ad25772959fc2ae9fc9 (diff)
downloadmariadb-git-c6d29cd30db9053023124bf74f17f6ee9d8e168d.tar.gz
Merge branch '10.1' of github.com:MariaDB/server into 10.1
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/analyze_stmt.result58
-rw-r--r--mysql-test/t/analyze_stmt.test54
2 files changed, 109 insertions, 3 deletions
diff --git a/mysql-test/r/analyze_stmt.result b/mysql-test/r/analyze_stmt.result
index 41fdce43807..8df6fe5127a 100644
--- a/mysql-test/r/analyze_stmt.result
+++ b/mysql-test/r/analyze_stmt.result
@@ -16,7 +16,7 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
# ANALYZE DELETE will delete rows:
analyze delete from t1 where a in (2,3,4);
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 10 NULL 100.00 30.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 30.00 Using where
select * from t1;
a
0
@@ -32,7 +32,7 @@ create table t1(a int, b int);
insert into t1 select a,a from t0;
analyze update t1 set b=100+b where a in (6,7,8);
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 10 NULL 100.00 30.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10 100.00 30.00 Using where
select * from t1;
a b
0 0
@@ -197,3 +197,57 @@ select * from t1;
a b
6 6
drop table t0, t1;
+#
+# MDEV-6393: ANALYZE SELECT crashes in Explain_query::print_explain with a non-existing column
+#
+create table t1 (i int);
+insert into t1 values (1),(2);
+analyze select a from t1;
+ERROR 42S22: Unknown column 'a' in 'field list'
+analyze delete from t1 where a=2;
+ERROR 42S22: Unknown column 'a' in 'where clause'
+analyze update t1 set a=2;
+ERROR 42S22: Unknown column 'a' in 'field list'
+create table t2 like t1;
+insert into t2 select * from t1;
+analyze update t2,t1 set t2.i=5 where t2.a=t1.a;
+ERROR 42S22: Unknown column 't2.a' in 'where clause'
+analyze delete t1 from t2,t1 where t2.a=t1.a;
+ERROR 42S22: Unknown column 't2.a' in 'where clause'
+drop table t1, t2;
+#
+# MDEV-6395: ANALYZE UPDATE/DELETE with impossible where does not produce any output
+#
+create table t1 (a int, b int, key(a));
+insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
+analyze delete from t1 where 1 > 2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+analyze delete from t1 where a > 30 and a < 10;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+analyze update t1 set b=12345 where 1 > 2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+analyze update t1 set b=12345 where a > 30 and a < 10;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+drop table t1;
+#
+# MDEV-6398: ANALYZE UPDATE does not populate r_rows
+#
+create table t1 (i int);
+insert into t1 values (1),(2),(3),(4);
+analyze update t1 set i=8;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 4 100.00 100.00
+drop table t1;
+#
+# Check ANALYZE SELECT INTO
+#
+create table t1 (i int);
+insert into t1 values (1);
+analyze select * from t1 into @var;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 100.00 NULL
+drop table t1;
diff --git a/mysql-test/t/analyze_stmt.test b/mysql-test/t/analyze_stmt.test
index 2f9de4a3763..8bd4ce37dd3 100644
--- a/mysql-test/t/analyze_stmt.test
+++ b/mysql-test/t/analyze_stmt.test
@@ -1,5 +1,5 @@
#
-# Tests for "ANALYZE $statement" feature (PostgreSQL's analog is called EXPLAIN ANALYZE)
+# Tests for "ANALYZE $statement" feature
#
--disable_warnings
drop table if exists t0,t1,t2,t3;
@@ -146,3 +146,55 @@ select * from t1;
drop table t0, t1;
+--echo #
+--echo # MDEV-6393: ANALYZE SELECT crashes in Explain_query::print_explain with a non-existing column
+--echo #
+create table t1 (i int);
+insert into t1 values (1),(2);
+--error ER_BAD_FIELD_ERROR
+analyze select a from t1;
+
+--error ER_BAD_FIELD_ERROR
+analyze delete from t1 where a=2;
+
+--error ER_BAD_FIELD_ERROR
+analyze update t1 set a=2;
+
+create table t2 like t1;
+insert into t2 select * from t1;
+
+--error ER_BAD_FIELD_ERROR
+analyze update t2,t1 set t2.i=5 where t2.a=t1.a;
+
+--error ER_BAD_FIELD_ERROR
+analyze delete t1 from t2,t1 where t2.a=t1.a;
+
+drop table t1, t2;
+--echo #
+--echo # MDEV-6395: ANALYZE UPDATE/DELETE with impossible where does not produce any output
+--echo #
+create table t1 (a int, b int, key(a));
+insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5);
+
+analyze delete from t1 where 1 > 2;
+analyze delete from t1 where a > 30 and a < 10;
+
+analyze update t1 set b=12345 where 1 > 2;
+analyze update t1 set b=12345 where a > 30 and a < 10;
+
+drop table t1;
+--echo #
+--echo # MDEV-6398: ANALYZE UPDATE does not populate r_rows
+--echo #
+create table t1 (i int);
+insert into t1 values (1),(2),(3),(4);
+analyze update t1 set i=8;
+drop table t1;
+
+--echo #
+--echo # Check ANALYZE SELECT INTO
+--echo #
+create table t1 (i int);
+insert into t1 values (1);
+analyze select * from t1 into @var;
+drop table t1;