~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/range.test

pandora-build v0.100 - Fixes several bugs found by cb1kenobi. Add several thoughts from folks at LCA.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
 
1
 
2
2
# Problem with range optimizer
3
3
#
4
4
 
7
7
--enable_warnings
8
8
 
9
9
CREATE TABLE t1 (
10
 
  event_date date DEFAULT '0000-00-00' NOT NULL,
11
 
  type int(11) DEFAULT '0' NOT NULL,
12
 
  event_id int(11) DEFAULT '0' NOT NULL,
 
10
  event_date date NULL,
 
11
  type int DEFAULT '0' NOT NULL,
 
12
  event_id int DEFAULT '0' NOT NULL,
13
13
  PRIMARY KEY (event_date,type,event_id)
14
14
);
15
15
 
38
38
drop table t1;
39
39
 
40
40
CREATE TABLE t1 (
41
 
  PAPER_ID smallint(6) DEFAULT '0' NOT NULL,
42
 
  YEAR smallint(6) DEFAULT '0' NOT NULL,
43
 
  ISSUE smallint(6) DEFAULT '0' NOT NULL,
44
 
  CLOSED tinyint(4) DEFAULT '0' NOT NULL,
45
 
  ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
 
41
  PAPER_ID int DEFAULT '0' NOT NULL,
 
42
  YEAR int DEFAULT '0' NOT NULL,
 
43
  ISSUE int DEFAULT '0' NOT NULL,
 
44
  CLOSED int DEFAULT '0' NOT NULL,
 
45
  ISS_DATE date,
46
46
  PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
47
47
);
48
48
INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'),
62
62
                      (3,1999,35,0,'1999-07-12');
63
63
select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28))  order by YEAR,ISSUE;
64
64
check table t1;
65
 
repair table t1;
66
65
drop table t1;
67
66
 
68
67
CREATE TABLE t1 (
69
 
  id int(11) NOT NULL auto_increment,
70
 
  parent_id int(11) DEFAULT '0' NOT NULL,
71
 
  level tinyint(4) DEFAULT '0' NOT NULL,
 
68
  id int NOT NULL auto_increment,
 
69
  parent_id int DEFAULT '0' NOT NULL,
 
70
  level int DEFAULT '0' NOT NULL,
72
71
  PRIMARY KEY (id),
73
72
  KEY parent_id (parent_id),
74
73
  KEY level (level)
116
115
# Problem with binary strings
117
116
#
118
117
 
119
 
CREATE TABLE t1 (
120
 
  t1ID int(10) unsigned NOT NULL auto_increment,
121
 
  art binary(1) NOT NULL default '',
 
118
CREATE TEMPORARY TABLE t1 (
 
119
  t1ID int NOT NULL auto_increment,
 
120
  art varbinary(1) NOT NULL default '',
122
121
  KNR char(5) NOT NULL default '',
123
122
  RECHNR char(6) NOT NULL default '',
124
123
  POSNR char(2) NOT NULL default '',
197
196
#
198
197
# bug #1172: "Force index" option caused server crash
199
198
#
200
 
CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1));
 
199
CREATE TABLE t1 (key1 int NOT NULL default '0', KEY i1 (key1));
201
200
INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1);
202
 
CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya));
 
201
CREATE TABLE t2 (keya int NOT NULL default '0', KEY j1 (keya));
203
202
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
204
203
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
205
204
explain select * from t1 force index(i1), t2 force index(j1) where 
210
209
# bug #1724: use RANGE on more selective column instead of REF on less
211
210
# selective
212
211
 
213
 
CREATE TABLE t1 (
214
 
  a int(11) default NULL,
215
 
  b int(11) default NULL,
 
212
CREATE TEMPORARY TABLE t1 (
 
213
  a int default NULL,
 
214
  b int default NULL,
216
215
  KEY a (a),
217
216
  KEY b (b)
218
217
) ENGINE=MyISAM;
261
260
# Test of problem with IN on many different keyparts. (Bug #4157)
262
261
#
263
262
 
264
 
CREATE TABLE t1 (
265
 
id int( 11 ) unsigned NOT NULL AUTO_INCREMENT ,
266
 
line int( 5 ) unsigned NOT NULL default '0',
267
 
columnid int( 3 ) unsigned NOT NULL default '0',
268
 
owner int( 3 ) unsigned NOT NULL default '0',
269
 
ordinal int( 3 ) unsigned NOT NULL default '0',
270
 
showid smallint( 6 ) unsigned NOT NULL default '1',
271
 
tableid int( 1 ) unsigned NOT NULL default '1',
272
 
content int( 5 ) unsigned NOT NULL default '188',
 
263
CREATE TEMPORARY TABLE t1 (
 
264
id int NOT NULL AUTO_INCREMENT ,
 
265
line int NOT NULL default '0',
 
266
columnid int NOT NULL default '0',
 
267
owner int NOT NULL default '0',
 
268
ordinal int NOT NULL default '0',
 
269
showid int NOT NULL default '1',
 
270
tableid int NOT NULL default '1',
 
271
content int NOT NULL default '188',
273
272
PRIMARY KEY ( owner, id ) ,
274
273
KEY menu( owner, showid, columnid ) ,
275
274
KEY `COLUMN` ( owner, columnid, line ) ,
286
285
# test for a bug with in() and unique key
287
286
#
288
287
 
289
 
create  table t1 (id int(10) primary key);
 
288
create  table t1 (id int primary key);
290
289
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
291
290
 
292
291
select id from t1 where id in (2,5,9) ;
380
379
 
381
380
analyze table t1,t2;
382
381
 
 
382
--replace_column 3 # 8 # 9 #
383
383
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
 
384
--replace_column 3 # 8 # 9 #
384
385
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid > 0;
 
386
--replace_column 3 # 8 # 9 #
385
387
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid != 0;
 
388
--replace_column 3 # 8 # 9 #
386
389
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid != 0;
387
390
 
388
391
select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
392
395
 
393
396
# Fix for bug#4488 
394
397
#
395
 
create table t1 (x bigint unsigned not null);
396
 
insert into t1(x) values (0xfffffffffffffff0);
397
 
insert into t1(x) values (0xfffffffffffffff1);
 
398
create table t1 (x bigint not null);
 
399
insert into t1(x) values (0x0ffffffffffffff0);
 
400
insert into t1(x) values (0x0ffffffffffffff1);
398
401
select * from t1;
399
402
select count(*) from t1 where x>0;
400
403
select count(*) from t1 where x=0;
419
422
drop table t1,t2;
420
423
 
421
424
--disable_warnings
422
 
create table t1 (x bigint unsigned not null primary key) engine=innodb;
 
425
create table t1 (x bigint not null primary key) engine=innodb;
423
426
--enable_warnings
424
 
insert into t1(x) values (0xfffffffffffffff0);
425
 
insert into t1(x) values (0xfffffffffffffff1);
 
427
insert into t1(x) values (0x0ffffffffffffff0);
 
428
insert into t1(x) values (0x0ffffffffffffff1);
426
429
select * from t1;
427
430
select count(*) from t1 where x>0;
428
431
select count(*) from t1 where x=0;
435
438
drop table t1;
436
439
 
437
440
#
438
 
# Bug #11185 incorrect comparison of unsigned int to signed constant
 
441
# Bug #11185 incorrect comparison of int to signed constant
439
442
#
440
 
create table t1 (a bigint unsigned);
 
443
create table t1 (a bigint);
441
444
create index t1i on t1(a);
442
445
insert into t1 select 18446744073709551615;
443
446
insert into t1 select 18446744073709551614;
457
460
# Bug #6045: Binary Comparison regression in MySQL 4.1
458
461
# Binary searches didn't use a case insensitive index.
459
462
#
460
 
set names latin1;
461
 
create table t1 (a char(10), b text, key (a)) character set latin1;
 
463
create table t1 (a char(10), b text, key (a));
462
464
INSERT INTO t1 (a) VALUES
463
465
('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb');
464
466
# all these three can be optimized
465
467
explain select * from t1 where a='aaa';
466
468
explain select * from t1 where a=binary 'aaa';
467
 
explain select * from t1 where a='aaa' collate latin1_bin;
468
 
# this one cannot:
469
 
explain select * from t1 where a='aaa' collate latin1_german1_ci;
 
469
explain select * from t1 where a='aaa' collate utf8_bin;
470
470
drop table t1;
471
471
 
472
472
# Test for BUG#9348 "result for WHERE A AND (B OR C) differs from WHERE a AND (C OR B)"
473
473
--disable_warnings
474
474
CREATE TABLE t1 (
475
 
  `CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000',
476
 
  `ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '',
477
 
  `ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '',
478
 
  `FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '',
479
 
  `FUNCTINT` int(11) NOT NULL default '0',
 
475
  `CLIENT` char(3) collate utf8_bin NOT NULL default '000',
 
476
  `ARG1` char(3) collate utf8_bin NOT NULL default '',
 
477
  `ARG2` char(3) collate utf8_bin NOT NULL default '',
 
478
  `FUNCTION` varchar(10) collate utf8_bin NOT NULL default '',
 
479
  `FUNCTINT` int NOT NULL default '0',
480
480
  KEY `VERI_CLNT~2` (`ARG1`)
481
 
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
481
) ENGINE=InnoDB;
482
482
--enable_warnings
483
483
 
484
484
INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0),
496
496
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
497
497
 
498
498
CREATE TABLE t2 (
499
 
  pk1 int(11) NOT NULL,
500
 
  pk2 int(11) NOT NULL,
501
 
  pk3 int(11) NOT NULL,
502
 
  pk4 int(11) NOT NULL,
 
499
  pk1 int NOT NULL,
 
500
  pk2 int NOT NULL,
 
501
  pk3 int NOT NULL,
 
502
  pk4 int NOT NULL,
503
503
  filler char(82),
504
504
  PRIMARY KEY (pk1,pk2,pk3,pk4)
505
 
) DEFAULT CHARSET=latin1;
 
505
);
506
506
 
507
507
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
508
508
INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
530
530
#
531
531
 
532
532
CREATE TABLE t1 (
533
 
  OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '',
534
 
  OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid',
 
533
  OXID varchar(32) NOT NULL DEFAULT '',
 
534
  OXPARENTID varchar(32) NOT NULL DEFAULT 'oxrootid',
535
535
  OXLEFT int NOT NULL DEFAULT '0',
536
536
  OXRIGHT int NOT NULL DEFAULT '0',
537
 
  OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '',
 
537
  OXROOTID varchar(32) NOT NULL DEFAULT '',
538
538
  PRIMARY KEY  (OXID),
539
539
  KEY OXNID (OXID),
540
540
  KEY OXLEFT (OXLEFT),
541
541
  KEY OXRIGHT (OXRIGHT),
542
542
  KEY OXROOTID (OXROOTID)
543
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci;
 
543
);
544
544
 
545
545
INSERT INTO t1 VALUES
546
546
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
555
555
('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11,
556
556
 'd8c4177d09f8b11f5.52725521');
557
557
 
 
558
--replace_column 3 # 8 # 9 #
558
559
EXPLAIN
559
560
SELECT s.oxid FROM t1 v, t1 s 
560
561
  WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
719
720
#
720
721
 
721
722
CREATE TABLE t1 (
722
 
  id int(11) NOT NULL auto_increment,
 
723
  id int NOT NULL auto_increment,
723
724
  status varchar(20),
724
725
  PRIMARY KEY  (id),
725
726
  KEY (status)
755
756
DROP TABLE t1;
756
757
 
757
758
#
758
 
# Test for bug #10031: range to be used over a view
759
 
#
760
 
 
761
 
CREATE TABLE  t1 (a int, b int, primary key(a,b));
762
 
 
763
 
INSERT INTO  t1 VALUES
764
 
  (1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3);
765
 
 
766
 
CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
767
 
 
768
 
EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3;
769
 
EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
770
 
 
771
 
EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
772
 
EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
773
 
 
774
 
SELECT a,b FROM t1 WHERE a < 2 and b=3;
775
 
SELECT a,b FROM v1 WHERE a < 2 and b=3; 
776
 
 
777
 
DROP VIEW v1;
778
 
DROP TABLE t1;
779
 
 
780
 
#
781
759
# Bug #11853: DELETE statement with a NOT (LIKE/<=>) where condition
782
760
#             for an indexed attribute              
783
761
#             
800
778
 
801
779
DROP TABLE t1;
802
780
 
803
 
#
804
 
# BUG#13317: range optimization doesn't work for IN over VIEW.
805
 
#
806
 
create table t1 (a int, b int, primary key(a,b));
807
 
create view v1 as select a, b from t1;
808
 
 
809
 
INSERT INTO `t1` VALUES
810
 
(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2)
811
 
,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
812
 
 
813
 
--replace_column 9 #
814
 
explain select * from t1 where a in (3,4)  and b in (1,2,3);
815
 
--replace_column 9 #
816
 
explain select * from v1 where a in (3,4)  and b in (1,2,3);
817
 
--replace_column 9 #
818
 
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
819
 
--replace_column 9 #
820
 
explain select * from v1 where a between 3 and 4 and b between 1 and 2;
821
 
 
822
 
drop view v1;
823
 
drop table t1;
824
 
 
825
781
# BUG#13455: 
826
782
create table t3 (a int);
827
783
insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
828
784
 
829
 
create table t1 (a varchar(10), filler char(200), key(a)) charset=binary;
 
785
create table t1 (a varchar(10), filler char(200), key(a));
830
786
insert into t1 values ('a','');
831
787
insert into t1 values ('a ','');
832
788
insert into t1 values ('a  ', '');
836
792
create table t2 (a varchar(10), filler char(200), key(a));
837
793
insert into t2 select * from t1;
838
794
 
839
 
--replace_column 9 #
 
795
--replace_column 3 # 8 # 9 #
840
796
explain select * from t1 where a between 'a' and 'a '; 
841
 
--replace_column 9 #
 
797
--replace_column 3 # 8 # 9 #
842
798
explain select * from t1 where a = 'a' or a='a ';
843
799
 
844
 
--replace_column 9 #
 
800
--replace_column 3 # 8 # 9 #
845
801
explain select * from t2 where a between 'a' and 'a '; 
846
 
--replace_column 9 #
 
802
--replace_column 3 # 8 # 9 #
847
803
explain select * from t2 where a = 'a' or a='a ';
848
804
 
849
805
update t1 set a='b' where a<>'a';
850
 
--replace_column 9 #
 
806
--replace_column 3 # 8 # 9 #
851
807
explain select * from t1 where a not between 'b' and 'b'; 
852
808
select a, hex(filler) from t1 where a not between 'b' and 'b'; 
853
809
 
854
810
drop table t1,t2,t3;
855
811
 
856
812
#
857
 
# BUG#21282
858
 
#
859
 
create table t1 (a int);
860
 
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
861
 
create table t2 (a int, key(a));
862
 
insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
863
 
 
864
 
set @a="select * from t2 force index (a) where a NOT IN(0";
865
 
select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
866
 
set @a=concat(@a, ')');
867
 
 
868
 
insert into t2 values (11),(13),(15);
869
 
 
870
 
set @b= concat("explain ", @a);
871
 
 
872
 
prepare stmt1 from @b;
873
 
execute stmt1;
874
 
 
875
 
prepare stmt1 from @a;
876
 
execute stmt1;
877
 
 
878
 
drop table t1, t2;
879
 
 
880
 
#
881
813
# Bug #18165: range access for BETWEEN with a constant for the first argument 
882
814
#
883
815
 
910
842
#             when a range condition use an invalid datetime constant 
911
843
#
912
844
 
913
 
CREATE TABLE t1 (                                      
 
845
CREATE TEMPORARY TABLE t1 (                                      
914
846
  item char(20) NOT NULL default '',                          
915
 
  started datetime NOT NULL default '0000-00-00 00:00:00', 
 
847
  started datetime, 
916
848
  price decimal(16,3) NOT NULL default '0.000',                 
917
849
  PRIMARY KEY (item,started)                     
918
850
) ENGINE=MyISAM;   
923
855
('A1','2005-12-12 08:00:00',3000),
924
856
('A2','2005-12-01 08:00:00',1000);
925
857
 
926
 
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
927
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
928
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
929
 
 
930
 
DROP INDEX `PRIMARY` ON t1;
931
 
 
932
 
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
933
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
934
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
 
858
--replace_column 3 # 8 # 9 #
 
859
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
 
860
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
 
861
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
 
862
 
 
863
# Disabling for now, since it fails.  Likely due to only currently
 
864
# checking for bad datetimes on string conversions...
 
865
#
 
866
#DROP INDEX `PRIMARY` ON t1;
 
867
 
 
868
#EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
 
869
#SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
 
870
#SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
935
871
 
936
872
DROP TABLE t1;
937
873
 
939
875
--echo BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly"
940
876
--echo
941
877
CREATE TABLE t1 (
942
 
  id int(11) NOT NULL auto_increment,
 
878
  id int NOT NULL auto_increment,
943
879
  dateval date default NULL,
944
880
  PRIMARY KEY  (id),
945
881
  KEY dateval (dateval)
962
898
 
963
899
CREATE TABLE t1 (
964
900
  a varchar(32), index (a)
965
 
) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
 
901
) DEFAULT COLLATE=utf8_bin;
966
902
 
967
903
INSERT INTO t1 VALUES
968
904
  ('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
977
913
#
978
914
 
979
915
# test UNSIGNED. only occurs when indexed.
980
 
CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1));
 
916
CREATE TABLE t1 (f1 int NOT NULL, PRIMARY KEY (f1));
981
917
 
982
918
INSERT INTO t1 VALUES (127),(254),(0),(1),(255);
983
919
 
984
920
# test upper bound
985
921
# count 5
986
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256;
987
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256.0;
 
922
SELECT COUNT(*) FROM t1 WHERE f1 < 256;
 
923
SELECT COUNT(*) FROM t1 WHERE f1 < 256.0;
988
924
# count 4
989
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 255;
 
925
SELECT COUNT(*) FROM t1 WHERE f1 < 255;
990
926
 
991
927
# show we don't fiddle with lower bound on UNSIGNED
992
928
# count 0
993
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < -1;
 
929
SELECT COUNT(*) FROM t1 WHERE f1 < -1;
994
930
# count 5
995
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -1;
 
931
SELECT COUNT(*) FROM t1 WHERE f1 > -1;
996
932
 
997
933
DROP TABLE t1;
998
934
 
999
935
 
1000
936
# test signed. only occurs when index.
1001
 
CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1));
 
937
CREATE TABLE t1 ( f1 int NOT NULL, PRIMARY KEY (f1));
1002
938
 
1003
939
INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127);
1004
940
 
1005
941
# test upper bound
1006
942
# count 5
1007
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128;
1008
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128.0;
 
943
SELECT COUNT(*) FROM t1 WHERE f1 < 128;
 
944
SELECT COUNT(*) FROM t1 WHERE f1 < 128.0;
1009
945
# count 4
1010
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 127;
 
946
SELECT COUNT(*) FROM t1 WHERE f1 < 127;
1011
947
 
1012
948
# test lower bound
1013
949
# count 5
1014
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129;
1015
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129.0;
 
950
SELECT COUNT(*) FROM t1 WHERE f1 > -129;
 
951
SELECT COUNT(*) FROM t1 WHERE f1 > -129.0;
1016
952
# count 4
1017
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -128;
 
953
SELECT COUNT(*) FROM t1 WHERE f1 > -128;
1018
954
 
1019
955
DROP TABLE t1;
1020
956
 
1042
978
# 500 rows, 1 row
1043
979
 
1044
980
select 'In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)' Z;
1045
 
explain select * from t2 where a=1000 and b<11;
 
981
create temporary table t2e like t2;
 
982
alter table t2e engine=myisam;
 
983
insert into t2e select * from t2;
 
984
analyze table t2e;
 
985
explain select * from t2e where a=1000 and b<11;
1046
986
 
1047
987
drop table t1, t2;
1048
988