2 # INSERT and REPLACE using index_merge optimization
5 # The include file works as intended only when index_merge_single_col_setup.inc
6 # or index_merge_multi_col_setup.inc is used. The table t1 set-up is done in
7 # these two include files.
10 DROP
TABLE IF EXISTS t2;
13 CREATE
TABLE t2 LIKE t1;
18 INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
19 rand()*6, rand()*6, rand()*6, rand()*6);
25 # intersect optimization technique test cases for non-selects
26 # are in a separate file(index_merge_intersect_dml.inc)
27 # due to different table requirements.
35 --let $query = INTO t2 SELECT * FROM t1 WHERE key3=1025 OR key5 IS NULL
38 --eval SELECT COUNT(*) FROM t2
40 --eval SELECT COUNT(*) FROM t2
42 --let $query = INTO t2 SELECT * FROM t1 WHERE key1=48 OR key4=2 OR key6=3
45 --eval SELECT COUNT(*) FROM t2
47 --eval SELECT COUNT(*) FROM t2
51 --let $query = INTO t2 SELECT * FROM t1 WHERE key1<2 OR key2<3
54 --eval SELECT COUNT(*) FROM t2
56 --eval SELECT COUNT(*) FROM t2
58 --let $query = INTO t2 SELECT * FROM t1 WHERE (key1>30 AND key1<35) OR (key2>32 AND key2<40)
61 --eval SELECT COUNT(*) FROM t2
63 --eval SELECT COUNT(*) FROM t2
65 # statements with use/force/ignore index
67 --let $query = INTO t2 SELECT * FROM t1 IGNORE INDEX(i2) WHERE key1<2 OR key2<3
70 --eval SELECT COUNT(*) FROM t2
72 --eval SELECT COUNT(*) FROM t2
74 INSERT INTO t1 VALUES (42,42,42,42,3,3,3,3),(4,4,6,6,6,6,4,4);
75 --let $query = INTO t2 SELECT * FROM t1 USE INDEX(i6,i3) WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6)
78 --eval SELECT COUNT(*) FROM t2
80 --eval SELECT COUNT(*) FROM t2
82 --let $query = INTO t2 SELECT * FROM t1 FORCE INDEX(i1,i2) WHERE (key1>1 OR key2>2)
85 --eval SELECT COUNT(*) FROM t2
87 --eval SELECT COUNT(*) FROM t2
95 INSERT INTO t1 VALUES (42,42,42,42,3,3,3,3),(4,4,6,6,6,6,4,4);
96 --let $query = INTO t2 SELECT * FROM t1 WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6) AND key5<>50
98 --eval EXPLAIN INSERT $query
99 --eval SELECT COUNT(*) FROM t2
101 --eval SELECT COUNT(*) FROM t2
105 --let $query = INTO t2 SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null
107 --eval EXPLAIN INSERT $query
108 --eval SELECT COUNT(*) FROM t2
110 --eval SELECT COUNT(*) FROM t2
112 # statements with use/force/ignore index
114 --let $query = INTO t2 SELECT * FROM t1 IGNORE INDEX(i1) WHERE key1<2 OR key2<3
116 --eval EXPLAIN INSERT $query
117 --eval SELECT COUNT(*) FROM t2
119 --eval SELECT COUNT(*) FROM t2
121 --let $query = INTO t2 SELECT * FROM t1 USE INDEX(i5,i6) WHERE (key1<2 OR key2<2) AND (key3<3 OR key4<3) AND (key5<5 OR key6<5);
123 --eval EXPLAIN INSERT $query
124 --eval SELECT COUNT(*) FROM t2
126 --eval SELECT COUNT(*) FROM t2
128 --let $query = INTO t2 SELECT * FROM t1 FORCE INDEX(i4,i5) WHERE (key4>3 OR key5>5)
130 --eval EXPLAIN INSERT $query
131 --eval SELECT COUNT(*) FROM t2
133 --eval SELECT COUNT(*) FROM t2