@@ -236,6 +236,15 @@ create table t2i (a int);
236
236
insert into t2m values (5 );
237
237
insert into t2i values (5 );
238
238
239
+ -- disable_query_log
240
+ -- disable_result_log
241
+ analyze table t1i;
242
+ analyze table t1m;
243
+ analyze table t2i;
244
+ analyze table t2m;
245
+ -- enable_result_log
246
+ -- enable_query_log
247
+
239
248
# test with $engine_type
240
249
select min (a) from t1i;
241
250
select min (7 ) from t1i;
@@ -411,6 +420,13 @@ if ($test_foreign_keys)
411
420
INSERT INTO t1 VALUES (1 ,' A1' ),(2 ,' A2' ),(3 ,' B' );
412
421
INSERT INTO t2 VALUES (1 ,1 ),(2 ,2 ),(3 ,2 ),(4 ,3 ),(5 ,3 );
413
422
423
+ -- disable_query_log
424
+ -- disable_result_log
425
+ ANALYZE TABLE t1;
426
+ ANALYZE TABLE t2;
427
+ -- enable_result_log
428
+ -- enable_query_log
429
+
414
430
EXPLAIN
415
431
SELECT COUNT (* ) FROM t2 LEFT JOIN t1 ON t2 .fkey = t1 .id
416
432
WHERE t1 .name LIKE ' A%' ;
@@ -572,12 +588,22 @@ OPTIMIZE TABLE t1;
572
588
SELECT COUNT (* ) FROM t1;
573
589
SELECT COUNT (* ) FROM t1 WHERE acct_id= 785 ;
574
590
591
+ -- disable_query_log
592
+ -- disable_result_log
593
+ ANALYZE TABLE t1;
594
+ -- enable_result_log
595
+ -- enable_query_log
596
+
575
597
EXPLAIN SELECT COUNT (* ) FROM t1 WHERE stat_id IN (1 ,3 ) AND acct_id= 785 ;
576
598
577
599
INSERT INTO t2 SELECT * FROM t1;
578
600
OPTIMIZE TABLE t2;
579
601
580
- EXPLAIN SELECT COUNT (* ) FROM t2 WHERE stat_id IN (1 ,3 ) AND acct_id= 785 ;
602
+ -- disable_query_log
603
+ -- disable_result_log
604
+ ANALYZE TABLE t2;
605
+ -- enable_result_log
606
+ -- enable_query_log
581
607
582
608
DROP TABLE t1,t2;
583
609
@@ -704,6 +730,13 @@ INSERT INTO t1(b,c) SELECT b,c FROM t2;
704
730
UPDATE t2 SET c= ' 2007-01-03' ;
705
731
INSERT INTO t1(b,c) SELECT b,c FROM t2;
706
732
733
+ -- disable_query_log
734
+ -- disable_result_log
735
+ ANALYZE TABLE t1;
736
+ ANALYZE TABLE t2;
737
+ -- enable_result_log
738
+ -- enable_query_log
739
+
707
740
set @@sort_buffer_size= 8192 ;
708
741
709
742
SELECT COUNT (* ) FROM t1;
@@ -793,6 +826,12 @@ INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
793
826
INSERT INTO t1 SELECT a + 32 , MOD(a + 32 , 20 ), 1 FROM t1;
794
827
INSERT INTO t1 SELECT a + 64 , MOD(a + 64 , 20 ), 1 FROM t1;
795
828
829
+ -- disable_query_log
830
+ -- disable_result_log
831
+ ANALYZE TABLE t1;
832
+ -- enable_result_log
833
+ -- enable_query_log
834
+
796
835
EXPLAIN SELECT b, SUM (c) FROM t1 GROUP BY b;
797
836
EXPLAIN SELECT SQL_BIG_RESULT b, SUM (c) FROM t1 GROUP BY b;
798
837
DROP TABLE t1;
@@ -855,6 +894,11 @@ CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB;
855
894
INSERT INTO t1 VALUES (1 ,2 ),(3 ,2 ),(2 ,2 ),(4 ,2 ),(5 ,2 ),(6 ,2 ),(7 ,2 ),(8 ,2 );
856
895
INSERT INTO t1 SELECT a + 8 , 2 FROM t1;
857
896
INSERT INTO t1 SELECT a + 16 , 1 FROM t1;
897
+ -- disable_query_log
898
+ -- disable_result_log
899
+ ANALYZE TABLE t1;
900
+ -- enable_result_log
901
+ -- enable_query_log
858
902
query_vertical EXPLAIN SELECT * FROM t1 WHERE b= 2 ORDER BY a;
859
903
SELECT * FROM t1 WHERE b= 2 ORDER BY a;
860
904
query_vertical EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a;
@@ -868,6 +912,12 @@ INSERT INTO t2 VALUES (1,1,1),(3,1,1),(2,1,1),(4,1,1);
868
912
INSERT INTO t2 SELECT a + 4 , 1 , 1 FROM t2;
869
913
INSERT INTO t2 SELECT a + 8 , 1 , 1 FROM t2;
870
914
915
+ -- disable_query_log
916
+ -- disable_result_log
917
+ ANALYZE TABLE t2;
918
+ -- enable_result_log
919
+ -- enable_query_log
920
+
871
921
query_vertical EXPLAIN SELECT * FROM t2 WHERE b= 1 ORDER BY a;
872
922
SELECT * FROM t2 WHERE b= 1 ORDER BY a;
873
923
query_vertical EXPLAIN SELECT * FROM t2 WHERE b= 1 AND c= 1 ORDER BY a;
@@ -959,7 +1009,7 @@ SELECT * FROM t1 WHERE b=20 FOR UPDATE;
959
1009
960
1010
-- connect (conn2, localhost, root,,test)
961
1011
962
- # This statement gives a "failed: 1205: Lock wait timeout exceeded; try
1012
+ # This statement gives a "failed: 1205: Lock wait timeout exceeded; try
963
1013
# restarting transaction" message when the bug is present.
964
1014
START TRANSACTION ;
965
1015
SELECT * FROM t1 WHERE b= 10 ORDER BY A FOR UPDATE ;
@@ -984,6 +1034,12 @@ CREATE TABLE t1(
984
1034
985
1035
INSERT INTO t1 VALUES (1 ,1 ,1 ,50 ), (1 ,2 ,3 ,40 ), (2 ,1 ,3 ,4 );
986
1036
1037
+ -- disable_query_log
1038
+ -- disable_result_log
1039
+ ANALYZE TABLE t1;
1040
+ -- enable_result_log
1041
+ -- enable_query_log
1042
+
987
1043
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d;
988
1044
SELECT c,b,d FROM t1 GROUP BY c,b,d;
989
1045
EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL ;
@@ -1004,6 +1060,12 @@ DROP TABLE t1;
1004
1060
CREATE TABLE t1 (a INT , b INT , PRIMARY KEY (a), INDEX b (b)) ENGINE= InnoDB;
1005
1061
INSERT INTO t1(a,b) VALUES (1 ,1 ), (2 ,2 ), (3 ,2 );
1006
1062
1063
+ -- disable_query_log
1064
+ -- disable_result_log
1065
+ ANALYZE TABLE t1;
1066
+ -- enable_result_log
1067
+ -- enable_query_log
1068
+
1007
1069
# The two queries below should produce different results, but they don't.
1008
1070
query_vertical EXPLAIN SELECT * FROM t1 WHERE b= 2 ORDER BY a ASC ;
1009
1071
SELECT * FROM t1 WHERE b= 2 ORDER BY a ASC ;
@@ -1087,6 +1149,12 @@ CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
1087
1149
INSERT INTO t1 VALUES
1088
1150
(191 , ' member' , 1 ), (NULL , ' member' , 3 ), (NULL , ' member' , 4 ), (201 , ' member' , 2 );
1089
1151
1152
+ -- disable_query_log
1153
+ -- disable_result_log
1154
+ ANALYZE TABLE t1;
1155
+ -- enable_result_log
1156
+ -- enable_query_log
1157
+
1090
1158
EXPLAIN SELECT * FROM t1 WHERE id= 191 OR id IS NULL ORDER BY d;
1091
1159
SELECT * FROM t1 WHERE id= 191 OR id IS NULL ORDER BY d;
1092
1160
@@ -1115,12 +1183,13 @@ CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b))
1115
1183
INSERT INTO t1 (a,b,c) VALUES (1 ,1 ,1 ), (2 ,1 ,1 ), (3 ,1 ,1 ), (4 ,1 ,1 );
1116
1184
INSERT INTO t1 (a,b,c) SELECT a+ 4 ,b,c FROM t1;
1117
1185
1118
- # should be range access
1186
+ -- disable_query_log
1187
+ -- disable_result_log
1188
+ ANALYZE TABLE t1;
1189
+ -- enable_result_log
1190
+ -- enable_query_log
1119
1191
1120
- #
1121
- # InnoDB uses "where", while xtradb "index condition"
1122
- #
1123
- -- replace_regex /where/index condition/
1192
+ # should be range access
1124
1193
EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5 ;
1125
1194
1126
1195
# should produce '8 7 6 5 4' for a
@@ -1514,6 +1583,12 @@ INSERT INTO t1 VALUES
1514
1583
(4 ,1 ,3 ,' pk' ,NULL ),(5 ,1 ,3 ,' c2' ,NULL ),
1515
1584
(2 ,1 ,4 ,' c_extra' ,NULL ),(3 ,1 ,4 ,' c_extra' ,NULL );
1516
1585
1586
+ -- disable_query_log
1587
+ -- disable_result_log
1588
+ ANALYZE TABLE t1;
1589
+ -- enable_result_log
1590
+ -- enable_query_log
1591
+
1517
1592
EXPLAIN SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC ;
1518
1593
1519
1594
SELECT * FROM t1 FORCE INDEX (PRIMARY) WHERE tid = 1 AND vid = 3 ORDER BY idx DESC ;
@@ -1531,6 +1606,12 @@ CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3))
1531
1606
ENGINE= $engine_type;
1532
1607
INSERT INTO t1 VALUES (1 ,1 ,1 ), (1 ,1 ,1 ), (1 ,1 ,2 ), (1 ,1 ,1 ), (1 ,1 ,2 );
1533
1608
1609
+ -- disable_query_log
1610
+ -- disable_result_log
1611
+ ANALYZE TABLE t1;
1612
+ -- enable_result_log
1613
+ -- enable_query_log
1614
+
1534
1615
SELECT 1 FROM (SELECT COUNT (DISTINCT c1)
1535
1616
FROM t1 WHERE c2 IN (1 , 1 ) AND c3 = 2 GROUP BY c2) x;
1536
1617
EXPLAIN
@@ -1544,6 +1625,12 @@ CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3))
1544
1625
ENGINE= $engine_type;
1545
1626
INSERT INTO t1 VALUES (1 ,1 ,1 ), (1 ,1 ,1 ), (1 ,1 ,2 ), (1 ,1 ,1 ), (1 ,1 ,2 );
1546
1627
1628
+ -- disable_query_log
1629
+ -- disable_result_log
1630
+ ANALYZE TABLE t1;
1631
+ -- enable_result_log
1632
+ -- enable_query_log
1633
+
1547
1634
SELECT 1 FROM (SELECT COUNT (DISTINCT c1)
1548
1635
FROM t1 WHERE c2 IN (1 , 1 ) AND c3 = 2 GROUP BY c2) x;
1549
1636
EXPLAIN
@@ -1558,6 +1645,12 @@ CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2),
1558
1645
ENGINE= $engine_type;
1559
1646
INSERT INTO t1 VALUES (1 ,1 ,1 ), (1 ,1 ,1 ), (1 ,1 ,2 ), (1 ,1 ,1 ), (1 ,1 ,2 );
1560
1647
1648
+ -- disable_query_log
1649
+ -- disable_result_log
1650
+ ANALYZE TABLE t1;
1651
+ -- enable_result_log
1652
+ -- enable_query_log
1653
+
1561
1654
SELECT 1 FROM (SELECT COUNT (DISTINCT c1)
1562
1655
FROM t1 WHERE c2 IN (1 , 1 ) AND c3 = 2 GROUP BY c2) x;
1563
1656
EXPLAIN
@@ -1585,6 +1678,13 @@ CREATE TABLE t2 (
1585
1678
insert into t1 values (0 ),(1 ),(2 ),(3 ),(4 );
1586
1679
insert into t2 select A .a + 10 * B .a , 1 , ' filler' from t1 A, t1 B;
1587
1680
1681
+ -- disable_query_log
1682
+ -- disable_result_log
1683
+ analyze table t1;
1684
+ analyze table t2;
1685
+ -- enable_result_log
1686
+ -- enable_query_log
1687
+
1588
1688
explain select * from t1, t2 where t2 .a = t1 .a and t2 .b + 1 ;
1589
1689
select * from t1, t2 where t2 .a = t1 .a and t2 .b + 1 ;
1590
1690
0 commit comments