~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/range.test

  • Committer: Monty Taylor
  • Date: 2008-11-16 05:36:13 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116053613-bld4rqxhlkb49c02
Split out cache_row and type_holder.

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 NULL,
 
10
  event_date date DEFAULT '0000-00-00' NOT NULL,
11
11
  type int DEFAULT '0' NOT NULL,
12
12
  event_id int DEFAULT '0' NOT NULL,
13
13
  PRIMARY KEY (event_date,type,event_id)
42
42
  YEAR int DEFAULT '0' NOT NULL,
43
43
  ISSUE int DEFAULT '0' NOT NULL,
44
44
  CLOSED int DEFAULT '0' NOT NULL,
45
 
  ISS_DATE date,
 
45
  ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
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;
65
66
drop table t1;
66
67
 
67
68
CREATE TABLE t1 (
115
116
# Problem with binary strings
116
117
#
117
118
 
118
 
CREATE TEMPORARY TABLE t1 (
 
119
CREATE TABLE t1 (
119
120
  t1ID int NOT NULL auto_increment,
120
121
  art varbinary(1) NOT NULL default '',
121
122
  KNR char(5) NOT NULL default '',
209
210
# bug #1724: use RANGE on more selective column instead of REF on less
210
211
# selective
211
212
 
212
 
CREATE TEMPORARY TABLE t1 (
 
213
CREATE TABLE t1 (
213
214
  a int default NULL,
214
215
  b int default NULL,
215
216
  KEY a (a),
260
261
# Test of problem with IN on many different keyparts. (Bug #4157)
261
262
#
262
263
 
263
 
CREATE TEMPORARY TABLE t1 (
 
264
CREATE TABLE t1 (
264
265
id int NOT NULL AUTO_INCREMENT ,
265
266
line int NOT NULL default '0',
266
267
columnid int NOT NULL default '0',
312
313
  name char(1) not null,
313
314
  uid int not null,
314
315
  primary key (id),
315
 
  index uid_index (uid));
 
316
  index uid_index (uid)) ENGINE=Myisam;
316
317
  
317
318
create table t2 (
318
319
  id int not null auto_increment,
319
320
  name char(1) not null,
320
321
  uid int not null,
321
322
  primary key (id),
322
 
  index uid_index (uid));
 
323
  index uid_index (uid)) engine=myisam;
323
324
  
324
325
insert into t1(id, uid, name) values(1, 0, ' ');
325
326
insert into t1(uid, name) values(0, ' ');
379
380
 
380
381
analyze table t1,t2;
381
382
 
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 #
385
384
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid > 0;
386
 
--replace_column 3 # 8 # 9 #
387
385
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid != 0;
388
 
--replace_column 3 # 8 # 9 #
389
386
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid != 0;
390
387
 
391
388
select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
395
392
 
396
393
# Fix for bug#4488 
397
394
#
398
 
create table t1 (x bigint unsigned not null);
 
395
create table t1 (x bigint not null);
399
396
insert into t1(x) values (0x0ffffffffffffff0);
400
397
insert into t1(x) values (0x0ffffffffffffff1);
401
398
select * from t1;
440
437
#
441
438
# Bug #11185 incorrect comparison of int to signed constant
442
439
#
443
 
create table t1 (a bigint unsigned);
444
 
show create table t1;
 
440
create table t1 (a bigint);
445
441
create index t1i on t1(a);
446
 
show create table t1;
447
 
insert into t1 values (9223372036854775807);
448
 
truncate t1;
449
442
insert into t1 select 18446744073709551615;
450
443
insert into t1 select 18446744073709551614;
451
444
 
508
501
  PRIMARY KEY (pk1,pk2,pk3,pk4)
509
502
);
510
503
 
511
 
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A CROSS JOIN t1 B;
 
504
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
512
505
INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
513
506
  (2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'),
514
507
  (2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler');
544
537
  KEY OXLEFT (OXLEFT),
545
538
  KEY OXRIGHT (OXRIGHT),
546
539
  KEY OXROOTID (OXROOTID)
547
 
);
 
540
) ENGINE=MyISAM;
548
541
 
549
542
INSERT INTO t1 VALUES
550
543
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
559
552
('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11,
560
553
 'd8c4177d09f8b11f5.52725521');
561
554
 
562
 
--replace_column 3 # 8 # 9 #
563
 
--sorted_result
564
555
EXPLAIN
565
556
SELECT s.oxid FROM t1 v, t1 s 
566
557
  WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
792
783
insert into t1 values ('a ','');
793
784
insert into t1 values ('a  ', '');
794
785
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;
 
786
  from t3 A, t3 B, t3 C;
796
787
 
797
788
create table t2 (a varchar(10), filler char(200), key(a));
798
789
insert into t2 select * from t1;
799
790
 
800
 
--replace_column 3 # 8 # 9 #
 
791
--replace_column 9 #
801
792
explain select * from t1 where a between 'a' and 'a '; 
802
 
--replace_column 3 # 8 # 9 #
 
793
--replace_column 9 #
803
794
explain select * from t1 where a = 'a' or a='a ';
804
795
 
805
 
--replace_column 3 # 8 # 9 #
 
796
--replace_column 9 #
806
797
explain select * from t2 where a between 'a' and 'a '; 
807
 
--replace_column 3 # 8 # 9 #
 
798
--replace_column 9 #
808
799
explain select * from t2 where a = 'a' or a='a ';
809
800
 
810
801
update t1 set a='b' where a<>'a';
811
 
--replace_column 3 # 4 # 5 # 6 # 7 # 8 # 9 #
 
802
--replace_column 9 #
812
803
explain select * from t1 where a not between 'b' and 'b'; 
813
804
select a, hex(filler) from t1 where a not between 'b' and 'b'; 
814
805
 
847
838
#             when a range condition use an invalid datetime constant 
848
839
#
849
840
 
850
 
CREATE TEMPORARY TABLE t1 (                                      
 
841
CREATE TABLE t1 (                                      
851
842
  item char(20) NOT NULL default '',                          
852
 
  started datetime, 
 
843
  started datetime NOT NULL default '0000-00-00 00:00:00', 
853
844
  price decimal(16,3) NOT NULL default '0.000',                 
854
845
  PRIMARY KEY (item,started)                     
855
846
) ENGINE=MyISAM;   
860
851
('A1','2005-12-12 08:00:00',3000),
861
852
('A2','2005-12-01 08:00:00',1000);
862
853
 
863
 
--replace_column 3 # 8 # 9 #
864
 
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
865
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
866
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
867
 
 
868
 
# Disabling for now, since it fails.  Likely due to only currently
869
 
# checking for bad datetimes on string conversions...
870
 
#
871
 
#DROP INDEX `PRIMARY` ON t1;
872
 
 
873
 
#EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
874
 
#SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
875
 
#SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
 
854
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
 
855
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
 
856
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
 
857
 
 
858
DROP INDEX `PRIMARY` ON t1;
 
859
 
 
860
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
 
861
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
 
862
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
876
863
 
877
864
DROP TABLE t1;
878
865
 
966
953
create table t1 (a int);
967
954
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
968
955
 
969
 
create table t2 (a int, b int, filler char(100));
 
956
create table t2 (a int, b int, filler char(100)) ENGINE=myisam;
970
957
insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
971
958
t1 B, t1 C where A.a < 5;
972
959
 
983
970
# 500 rows, 1 row
984
971
 
985
972
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;
 
973
explain select * from t2 where a=1000 and b<11;
991
974
 
992
975
drop table t1, t2;
993
976