~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/order_by.test

  • Committer: Brian Aker
  • Date: 2008-10-10 18:07:08 UTC
  • Revision ID: brian@tangent.org-20081010180708-dyxthxiyno22s3pb
Re-enabled more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
--enable_warnings
8
8
 
9
9
CREATE TABLE t1 (
10
 
  id int(6) DEFAULT '0' NOT NULL,
11
 
  idservice int(5),
12
 
  clee char(20) NOT NULL,
13
 
  flag char(1),
 
10
  id int DEFAULT '0' NOT NULL,
 
11
  idservice int,
 
12
  clee varchar(20) NOT NULL,
 
13
  flag varchar(1),
14
14
  KEY id (id),
15
15
  PRIMARY KEY (clee)
16
16
);
25
25
INSERT INTO t1 VALUES (2,3,'dd','Y');
26
26
 
27
27
CREATE TABLE t2 (
28
 
  id int(6) NOT NULL auto_increment,
 
28
  id int NOT NULL auto_increment,
29
29
  description varchar(40) NOT NULL,
30
30
  idform varchar(40),
31
 
  ordre int(6) DEFAULT '0' NOT NULL,
 
31
  ordre int DEFAULT '0' NOT NULL,
32
32
  image varchar(60),
33
33
  PRIMARY KEY (id),
34
34
  KEY id (id,ordre)
192
192
#bug reported by Wouter de Jong
193
193
 
194
194
CREATE TABLE t1 (
195
 
  member_id int(11) NOT NULL auto_increment,
 
195
  member_id int NOT NULL auto_increment,
196
196
  inschrijf_datum varchar(20) NOT NULL default '',
197
197
  lastchange_datum varchar(20) NOT NULL default '',
198
198
  nickname varchar(20) NOT NULL default '',
255
255
# Test things when we don't have NULL keys
256
256
#
257
257
 
258
 
alter table t1 modify b int not null, modify c varchar(10) not null;
 
258
delete from t1 WHERE b IS NULL OR c IS NULL;
 
259
alter table t1 modify b bigint not null, modify c varchar(100) not null;
259
260
explain select * from t1 order by a, b, c;
260
261
select * from t1 order by a, b, c;
261
262
explain select * from t1 order by a desc, b desc, c desc;
278
279
 
279
280
 
280
281
CREATE TABLE t1 (
281
 
  gid int(10) NOT NULL auto_increment,
282
 
  cid int(5) NOT NULL default '0',
 
282
  gid int NOT NULL auto_increment,
 
283
  cid int NOT NULL default '0',
283
284
  PRIMARY KEY  (gid),
284
285
  KEY component_id (cid)
285
286
) ENGINE=MyISAM;
286
287
INSERT INTO t1 VALUES (103853,108),(103867,108),(103962,108),(104505,108),(104619,108),(104620,108);
287
 
ALTER TABLE t1 add skr int(10) not null;
 
288
ALTER TABLE t1 add skr int not null;
288
289
 
289
290
CREATE TABLE t2 (
290
 
  gid int(10) NOT NULL default '0',
291
 
  uid int(5) NOT NULL default '1',
292
 
  sid int(3) NOT NULL default '1',
 
291
  gid int NOT NULL default '0',
 
292
  uid int NOT NULL default '1',
 
293
  sid int NOT NULL default '1',
293
294
  PRIMARY KEY  (gid),
294
295
  KEY uid (uid),
295
296
  KEY status_id (sid)
297
298
INSERT INTO t2 VALUES (103853,250,5),(103867,27,5),(103962,27,5),(104505,117,5),(104619,75,5),(104620,15,5);
298
299
 
299
300
CREATE TABLE t3 (
300
 
  uid int(6) NOT NULL auto_increment,
 
301
  uid int NOT NULL auto_increment,
301
302
  PRIMARY KEY  (uid)
302
303
) ENGINE=MyISAM;
303
304
INSERT INTO t3 VALUES (1),(15),(27),(75),(117),(250);
304
 
ALTER TABLE t3 add skr int(10) not null;
 
305
ALTER TABLE t3 add skr int not null;
305
306
 
306
307
select t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
307
308
select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
322
323
 
323
324
CREATE TABLE t1 (
324
325
  `titre` char(80) NOT NULL default '',
325
 
  `numeropost` mediumint(8) NOT NULL auto_increment,
 
326
  `numeropost` int NOT NULL auto_increment,
326
327
  `date` datetime NOT NULL default '0000-00-00 00:00:00',
327
328
  `auteur` char(35) NOT NULL default '',
328
 
  `icone` int(2) NOT NULL default '0',
 
329
  `icone` int NOT NULL default '0',
329
330
  `lastauteur` char(35) NOT NULL default '',
330
 
  `nbrep` int(6) NOT NULL default '0',
 
331
  `nbrep` int NOT NULL default '0',
331
332
  `dest` char(35) NOT NULL default '',
332
 
  `lu` int(1) NOT NULL default '0',
333
 
  `vue` mediumint(8) NOT NULL default '0',
334
 
  `ludest` int(1) NOT NULL default '0',
335
 
  `ouvert` int(1) NOT NULL default '1',
 
333
  `lu` int NOT NULL default '0',
 
334
  `vue` int NOT NULL default '0',
 
335
  `ludest` int NOT NULL default '0',
 
336
  `ouvert` int NOT NULL default '1',
336
337
  PRIMARY KEY  (`numeropost`),
337
338
  KEY `date` (`date`),
338
339
  KEY `dest` (`dest`,`ludest`),
342
343
) CHECKSUM=1;
343
344
 
344
345
CREATE TABLE t2 (
345
 
  `numeropost` mediumint(8) NOT NULL default '0',
 
346
  `numeropost` int NOT NULL default '0',
346
347
  `pseudo` char(35) NOT NULL default '',
347
348
  PRIMARY KEY  (`numeropost`,`pseudo`),
348
349
  KEY `pseudo` (`pseudo`)
382
383
  dec $1;
383
384
 }
384
385
enable_query_log;
385
 
explain select id,t from t1 order by id;
386
 
explain select id,t from t1 force index (primary) order by id;
 
386
select id,t from t1 force index (primary) order by id;
387
387
drop table t1;
388
388
 
389
389
#
391
391
#
392
392
CREATE TABLE t1 (
393
393
  FieldKey varchar(36) NOT NULL default '',
394
 
  LongVal bigint(20) default NULL,
395
 
  StringVal mediumtext,
 
394
  LongVal bigint default NULL,
 
395
  StringVal text,
396
396
  KEY FieldKey (FieldKey),
397
397
  KEY LongField (FieldKey,LongVal),
398
398
  KEY StringField (FieldKey,StringVal(32))
417
417
# Bug when doing an order by on a 1 byte string (Bug #2147)
418
418
#
419
419
 
420
 
CREATE TABLE t1 (  id int(6) NOT NULL default '0',  menu int(4) NOT NULL default '0',  KEY id (id),  KEY menu (menu)) ENGINE=MyISAM;
 
420
CREATE TABLE t1 (  id int NOT NULL default '0',  menu int NOT NULL default '0',  KEY id (id),  KEY menu (menu)) ENGINE=MyISAM;
421
421
INSERT INTO t1 VALUES (11384, 2),(11392, 2);
422
422
SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ;
423
423
drop table t1;
523
523
  `wnid` varchar(11) not null default '',
524
524
  key `wnid14` (`wnid`(4)),
525
525
  key `wnid` (`wnid`)
526
 
) engine=myisam default charset=latin1;
 
526
) engine=myisam;
527
527
 
528
528
insert into t1 (`sid`, `wnid`) values
529
529
('10100','01019000000'),('37986','01019000000'),('37987','01019010000'),
742
742
 
743
743
# End of 5.0
744
744
 
745
 
#
746
 
# Bug #28404: query with ORDER BY and ref access
747
 
#
748
 
 
749
 
CREATE TABLE t1(
750
 
  id int auto_increment PRIMARY KEY, c2 int, c3 int, INDEX k2(c2), INDEX k3(c3));
751
 
 
752
 
INSERT INTO t1 (c2,c3) VALUES
753
 
 (31,34),(35,38),(34,31),(32,35),(31,39),
754
 
 (11,14),(15,18),(14,11),(12,15),(11,19);
755
 
 
756
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
757
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
758
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
759
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
760
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
761
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
762
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
763
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
764
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
765
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
766
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
767
 
INSERT INTO t1 (c2,c3) SELECT c2,c3 FROM t1;
768
 
UPDATE t1 SET c2=20 WHERE id%100 = 0;
769
 
SELECT COUNT(*) FROM t1;
770
 
 
771
 
CREATE TABLE t2 LIKE t1;
772
 
INSERT INTO t2 SELECT * FROM t1 ORDER BY id;
773
 
 
774
 
EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20;
775
 
EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000;
776
 
EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20;
777
 
EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000;
778
 
 
779
 
SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20;
780
 
 
781
 
DROP TABLE t1,t2;
782
 
 
783
745
784
746
# Bug #30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY}
785
747
#
798
760
 
799
761
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
800
762
 
801
 
--disable_query_log
802
 
--let $q = `show status like 'Created_tmp_tables';`
803
 
eval set @tmp_tables_before = 
804
 
  CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED);
805
 
--enable_query_log
806
 
 
807
763
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
808
764
 
809
 
# this query creates one temporary table in itself, which we are not
810
 
# interested in.
811
 
 
812
 
--disable_query_log
813
 
--let $q = `show status like 'Created_tmp_tables';`
814
 
eval set @tmp_tables_after = 
815
 
  CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED);
816
 
--enable_query_log
817
 
 
818
765
SELECT @tmp_tables_after = @tmp_tables_before ;
819
766
 
820
767
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a;
821
768
 
822
 
--disable_query_log
823
 
--let $q = `show status like 'Created_tmp_tables';`
824
 
eval set @tmp_tables_before = 
825
 
  CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED);
826
 
--enable_query_log
827
 
 
828
769
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a;
829
770
 
830
 
--disable_query_log
831
 
--let $q = `show status like 'Created_tmp_tables';`
832
 
eval set @tmp_tables_after = 
833
 
  CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED);
834
 
--enable_query_log
835
 
 
836
771
SELECT @tmp_tables_after = @tmp_tables_before;
837
772
 
838
773
DROP TABLE t1;
839
774
--echo #
840
775
--echo # Bug#31590: Wrong error message on sort buffer being too small.
841
776
--echo #
842
 
create table t1(a int, b tinytext);
 
777
create table t1(a int, b text);
843
778
insert into t1 values (1,2),(3,2);
844
779
set session sort_buffer_size= 30000;
845
780
set session max_sort_length= 2180;
846
 
--error 1038
847
781
select * from t1 order by b;
848
782
drop table t1;
849
783
 
851
785
# Bug #35206: select query result different if the key is indexed or not
852
786
#
853
787
 
854
 
CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, 
 
788
CREATE TABLE t2 (a varchar(32), b int, c float, d double, 
855
789
  UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c));
856
790
 
857
791
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b));