~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/range.test

Merge Nathan

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
# Problem with binary strings
116
116
#
117
117
 
118
 
CREATE TEMPORARY TABLE t1 (
 
118
CREATE TABLE t1 (
119
119
  t1ID int NOT NULL auto_increment,
120
120
  art varbinary(1) NOT NULL default '',
121
121
  KNR char(5) NOT NULL default '',
209
209
# bug #1724: use RANGE on more selective column instead of REF on less
210
210
# selective
211
211
 
212
 
CREATE TEMPORARY TABLE t1 (
 
212
CREATE TABLE t1 (
213
213
  a int default NULL,
214
214
  b int default NULL,
215
215
  KEY a (a),
260
260
# Test of problem with IN on many different keyparts. (Bug #4157)
261
261
#
262
262
 
263
 
CREATE TEMPORARY TABLE t1 (
 
263
CREATE TABLE t1 (
264
264
id int NOT NULL AUTO_INCREMENT ,
265
265
line int NOT NULL default '0',
266
266
columnid int NOT NULL default '0',
312
312
  name char(1) not null,
313
313
  uid int not null,
314
314
  primary key (id),
315
 
  index uid_index (uid));
 
315
  index uid_index (uid)) ENGINE=Myisam;
316
316
  
317
317
create table t2 (
318
318
  id int not null auto_increment,
319
319
  name char(1) not null,
320
320
  uid int not null,
321
321
  primary key (id),
322
 
  index uid_index (uid));
 
322
  index uid_index (uid)) engine=myisam;
323
323
  
324
324
insert into t1(id, uid, name) values(1, 0, ' ');
325
325
insert into t1(uid, name) values(0, ' ');
379
379
 
380
380
analyze table t1,t2;
381
381
 
382
 
--replace_column 3 # 8 # 9 #
383
382
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
384
 
--replace_column 3 # 8 # 9 #
385
383
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid > 0;
386
 
--replace_column 3 # 8 # 9 #
387
384
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid != 0;
388
 
--replace_column 3 # 8 # 9 #
389
385
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid != 0;
390
386
 
391
387
select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
395
391
 
396
392
# Fix for bug#4488 
397
393
#
398
 
create table t1 (x bigint unsigned not null);
 
394
create table t1 (x bigint not null);
399
395
insert into t1(x) values (0x0ffffffffffffff0);
400
396
insert into t1(x) values (0x0ffffffffffffff1);
401
397
select * from t1;
440
436
#
441
437
# Bug #11185 incorrect comparison of int to signed constant
442
438
#
443
 
create table t1 (a bigint unsigned);
444
 
show create table t1;
 
439
create table t1 (a bigint);
445
440
create index t1i on t1(a);
446
 
show create table t1;
447
 
insert into t1 values (9223372036854775807);
448
 
truncate t1;
449
441
insert into t1 select 18446744073709551615;
450
442
insert into t1 select 18446744073709551614;
451
443
 
508
500
  PRIMARY KEY (pk1,pk2,pk3,pk4)
509
501
);
510
502
 
511
 
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A CROSS JOIN t1 B;
 
503
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
512
504
INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
513
505
  (2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'),
514
506
  (2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler');
544
536
  KEY OXLEFT (OXLEFT),
545
537
  KEY OXRIGHT (OXRIGHT),
546
538
  KEY OXROOTID (OXROOTID)
547
 
);
 
539
) ENGINE=MyISAM;
548
540
 
549
541
INSERT INTO t1 VALUES
550
542
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
559
551
('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11,
560
552
 'd8c4177d09f8b11f5.52725521');
561
553
 
562
 
--replace_column 3 # 8 # 9 #
563
 
--sorted_result
564
554
EXPLAIN
565
555
SELECT s.oxid FROM t1 v, t1 s 
566
556
  WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
792
782
insert into t1 values ('a ','');
793
783
insert into t1 values ('a  ', '');
794
784
insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), ''
795
 
  from t3 A CROSS JOIN t3 B CROSS JOIN t3 C;
 
785
  from t3 A, t3 B, t3 C;
796
786
 
797
787
create table t2 (a varchar(10), filler char(200), key(a));
798
788
insert into t2 select * from t1;
799
789
 
800
 
--replace_column 3 # 8 # 9 #
 
790
--replace_column 9 #
801
791
explain select * from t1 where a between 'a' and 'a '; 
802
 
--replace_column 3 # 8 # 9 #
 
792
--replace_column 9 #
803
793
explain select * from t1 where a = 'a' or a='a ';
804
794
 
805
 
--replace_column 3 # 8 # 9 #
 
795
--replace_column 9 #
806
796
explain select * from t2 where a between 'a' and 'a '; 
807
 
--replace_column 3 # 8 # 9 #
 
797
--replace_column 9 #
808
798
explain select * from t2 where a = 'a' or a='a ';
809
799
 
810
800
update t1 set a='b' where a<>'a';
811
 
--replace_column 3 # 4 # 5 # 6 # 7 # 8 # 9 #
 
801
--replace_column 9 #
812
802
explain select * from t1 where a not between 'b' and 'b'; 
813
803
select a, hex(filler) from t1 where a not between 'b' and 'b'; 
814
804
 
847
837
#             when a range condition use an invalid datetime constant 
848
838
#
849
839
 
850
 
CREATE TEMPORARY TABLE t1 (                                      
 
840
CREATE TABLE t1 (                                      
851
841
  item char(20) NOT NULL default '',                          
852
842
  started datetime, 
853
843
  price decimal(16,3) NOT NULL default '0.000',                 
860
850
('A1','2005-12-12 08:00:00',3000),
861
851
('A2','2005-12-01 08:00:00',1000);
862
852
 
863
 
--replace_column 3 # 8 # 9 #
864
853
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
865
854
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
866
855
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
966
955
create table t1 (a int);
967
956
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
968
957
 
969
 
create table t2 (a int, b int, filler char(100));
 
958
create table t2 (a int, b int, filler char(100)) ENGINE=myisam;
970
959
insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
971
960
t1 B, t1 C where A.a < 5;
972
961
 
983
972
# 500 rows, 1 row
984
973
 
985
974
select 'In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)' Z;
986
 
create temporary table t2e like t2;
987
 
alter table t2e engine=myisam;
988
 
insert into t2e select * from t2;
989
 
analyze table t2e;
990
 
explain select * from t2e where a=1000 and b<11;
 
975
explain select * from t2 where a=1000 and b<11;
991
976
 
992
977
drop table t1, t2;
993
978