summaryrefslogtreecommitdiff
path: root/mysql-test/t/analyze_stmt.test
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-06-25 16:01:09 +0400
committerSergei Petrunia <psergey@askmonty.org>2014-06-25 16:01:09 +0400
commitb561a98a87c0326dce59eb49c1b4b8f31da21d1e (patch)
tree573cd0a48bfda9441ddf0c1ba2aa7bd7989d2b94 /mysql-test/t/analyze_stmt.test
parent7711999d8b89d9bcf394e78a79c3c25013e249d6 (diff)
downloadmariadb-git-b561a98a87c0326dce59eb49c1b4b8f31da21d1e.tar.gz
MDEV-406: ANALYZE $stmt: add some tests for joins
Diffstat (limited to 'mysql-test/t/analyze_stmt.test')
-rw-r--r--mysql-test/t/analyze_stmt.test23
1 files changed, 21 insertions, 2 deletions
diff --git a/mysql-test/t/analyze_stmt.test b/mysql-test/t/analyze_stmt.test
index ab47fa52165..9320f6f81a4 100644
--- a/mysql-test/t/analyze_stmt.test
+++ b/mysql-test/t/analyze_stmt.test
@@ -84,7 +84,26 @@ explain select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
--echo # Now, t1 should have filtered=10
analyze select * from t0, t1 where t0.a<5 and t1.a<5 and t1.b=t0.b;
-drop table t0,t1;
-
--echo # TODO: Check what is counted for "range checked for each record".
+--echo #
+--echo # Test for joins
+--echo #
+create table t2 (key1 int, key2x int, col1 int, key(key1), key(key2x));
+insert into t2 select A.a + 10 *B.a +100 * C.a,
+ (A.a + 10 *B.a +100 * C.a)*2,
+ A.a + 10 *B.a +100 * C.a
+ from t0 A, t0 B, t0 C;
+
+--echo # This always has matches, filtered=100%.
+analyze select * from t1,t2 where t2.key1=t1.a;
+
+--echo # This shows r_rows=0. It is actually 0.5 (should r_rows be changed to double?)
+analyze select * from t1,t2 where t2.key2x=t1.a;
+ select * from t1,t2 where t2.key2x=t1.a;
+
+--echo # This has t2.filtered=40% (there are 5 values: {0,1,2,3,4}. two of them have mod=0)
+analyze select * from t1,t2 where t2.key2x=t1.a and mod(t2.col1,4)=0;
+
+drop table t0,t1,t2;
+