~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/range.test

  • Committer: Monty Taylor
  • Date: 2008-10-22 23:45:01 UTC
  • Revision ID: monty@inaugust.com-20081022234501-hwybvprata8ba98l
Moved handler_error_messages array out of header file. Moved associated
functions to live with it.

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;
540
537
  KEY OXLEFT (OXLEFT),
541
538
  KEY OXRIGHT (OXRIGHT),
542
539
  KEY OXROOTID (OXROOTID)
543
 
);
 
540
) ENGINE=MyISAM;
544
541
 
545
542
INSERT INTO t1 VALUES
546
543
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
555
552
('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11,
556
553
 'd8c4177d09f8b11f5.52725521');
557
554
 
558
 
--replace_column 3 # 8 # 9 #
559
 
--sorted_result
560
555
EXPLAIN
561
556
SELECT s.oxid FROM t1 v, t1 s 
562
557
  WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
793
788
create table t2 (a varchar(10), filler char(200), key(a));
794
789
insert into t2 select * from t1;
795
790
 
796
 
--replace_column 3 # 8 # 9 #
 
791
--replace_column 9 #
797
792
explain select * from t1 where a between 'a' and 'a '; 
798
 
--replace_column 3 # 8 # 9 #
 
793
--replace_column 9 #
799
794
explain select * from t1 where a = 'a' or a='a ';
800
795
 
801
 
--replace_column 3 # 8 # 9 #
 
796
--replace_column 9 #
802
797
explain select * from t2 where a between 'a' and 'a '; 
803
 
--replace_column 3 # 8 # 9 #
 
798
--replace_column 9 #
804
799
explain select * from t2 where a = 'a' or a='a ';
805
800
 
806
801
update t1 set a='b' where a<>'a';
807
 
--replace_column 3 # 4 # 5 # 6 # 7 # 8 # 9 #
 
802
--replace_column 9 #
808
803
explain select * from t1 where a not between 'b' and 'b'; 
809
804
select a, hex(filler) from t1 where a not between 'b' and 'b'; 
810
805
 
843
838
#             when a range condition use an invalid datetime constant 
844
839
#
845
840
 
846
 
CREATE TEMPORARY TABLE t1 (                                      
 
841
CREATE TABLE t1 (                                      
847
842
  item char(20) NOT NULL default '',                          
848
 
  started datetime, 
 
843
  started datetime NOT NULL default '0000-00-00 00:00:00', 
849
844
  price decimal(16,3) NOT NULL default '0.000',                 
850
845
  PRIMARY KEY (item,started)                     
851
846
) ENGINE=MyISAM;   
856
851
('A1','2005-12-12 08:00:00',3000),
857
852
('A2','2005-12-01 08:00:00',1000);
858
853
 
859
 
--replace_column 3 # 8 # 9 #
860
 
EXPLAIN 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-01 23:59:59';
862
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
863
 
 
864
 
# Disabling for now, since it fails.  Likely due to only currently
865
 
# checking for bad datetimes on string conversions...
866
 
#
867
 
#DROP INDEX `PRIMARY` ON t1;
868
 
 
869
 
#EXPLAIN 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-01 23:59:59';
871
 
#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';
872
863
 
873
864
DROP TABLE t1;
874
865
 
962
953
create table t1 (a int);
963
954
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
964
955
 
965
 
create table t2 (a int, b int, filler char(100));
 
956
create table t2 (a int, b int, filler char(100)) ENGINE=myisam;
966
957
insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
967
958
t1 B, t1 C where A.a < 5;
968
959
 
979
970
# 500 rows, 1 row
980
971
 
981
972
select 'In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)' Z;
982
 
create temporary table t2e like t2;
983
 
alter table t2e engine=myisam;
984
 
insert into t2e select * from t2;
985
 
analyze table t2e;
986
 
explain select * from t2e where a=1000 and b<11;
 
973
explain select * from t2 where a=1000 and b<11;
987
974
 
988
975
drop table t1, t2;
989
976