~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/order_by.test

  • Committer: Monty Taylor
  • Date: 2008-10-07 09:36:42 UTC
  • mto: This revision was merged to the branch mainline in revision 489.
  • Revision ID: monty@inaugust.com-20081007093642-1uqwwt6z5u306cux
Split a method out into innodb_plugin_extras. Innodb is the only thing that uses it. I imagine we probably want to do something totally different with this...

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 DEFAULT '0' NOT NULL,
11
 
  idservice int,
12
 
  clee varchar(20) NOT NULL,
13
 
  flag varchar(1),
 
10
  id int(6) DEFAULT '0' NOT NULL,
 
11
  idservice int(5),
 
12
  clee char(20) NOT NULL,
 
13
  flag char(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 NOT NULL auto_increment,
 
28
  id int(6) NOT NULL auto_increment,
29
29
  description varchar(40) NOT NULL,
30
30
  idform varchar(40),
31
 
  ordre int DEFAULT '0' NOT NULL,
 
31
  ordre int(6) DEFAULT '0' NOT NULL,
32
32
  image varchar(60),
33
33
  PRIMARY KEY (id),
34
34
  KEY id (id,ordre)
191
191
 
192
192
#bug reported by Wouter de Jong
193
193
 
194
 
CREATE TEMPORARY TABLE t1 (
195
 
  member_id int NOT NULL auto_increment,
 
194
CREATE TABLE t1 (
 
195
  member_id int(11) 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 '',
205
205
  wijk varchar(40) NOT NULL default '',
206
206
  plaats varchar(50) NOT NULL default '',
207
207
  telefoon varchar(10) NOT NULL default '',
208
 
  geboortedatum date,
 
208
  geboortedatum date NOT NULL default '0000-00-00',
209
209
  geslacht varchar(5) NOT NULL default '',
210
210
  email varchar(80) NOT NULL default '',
211
211
  uin varchar(15) NOT NULL default '',
220
220
  info text NOT NULL default '',
221
221
  ipnr varchar(30) NOT NULL default '',
222
222
  PRIMARY KEY  (member_id)
223
 
) ENGINE=MyISAM;
 
223
) ENGINE=MyISAM PACK_KEYS=1;
224
224
 
225
225
insert into t1 (member_id) values (1),(2),(3);
226
226
select member_id, nickname, voornaam FROM t1
255
255
# Test things when we don't have NULL keys
256
256
#
257
257
 
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;
 
258
alter table t1 modify b int not null, modify c varchar(10) not null;
260
259
explain select * from t1 order by a, b, c;
261
260
select * from t1 order by a, b, c;
262
261
explain select * from t1 order by a desc, b desc, c desc;
278
277
drop table t1;
279
278
 
280
279
 
281
 
CREATE TEMPORARY TABLE t1 (
282
 
  gid int NOT NULL auto_increment,
283
 
  cid int NOT NULL default '0',
 
280
CREATE TABLE t1 (
 
281
  gid int(10) NOT NULL auto_increment,
 
282
  cid int(5) NOT NULL default '0',
284
283
  PRIMARY KEY  (gid),
285
284
  KEY component_id (cid)
286
285
) ENGINE=MyISAM;
287
286
INSERT INTO t1 VALUES (103853,108),(103867,108),(103962,108),(104505,108),(104619,108),(104620,108);
288
 
ALTER TABLE t1 add skr int default 42 not null;
 
287
ALTER TABLE t1 add skr int(10) not null;
289
288
 
290
 
CREATE TEMPORARY TABLE t2 (
291
 
  gid int NOT NULL default '0',
292
 
  uid int NOT NULL default '1',
293
 
  sid int NOT NULL default '1',
 
289
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',
294
293
  PRIMARY KEY  (gid),
295
294
  KEY uid (uid),
296
295
  KEY status_id (sid)
297
296
) ENGINE=MyISAM;
298
297
INSERT INTO t2 VALUES (103853,250,5),(103867,27,5),(103962,27,5),(104505,117,5),(104619,75,5),(104620,15,5);
299
298
 
300
 
CREATE TEMPORARY TABLE t3 (
301
 
  uid int NOT NULL auto_increment,
 
299
CREATE TABLE t3 (
 
300
  uid int(6) NOT NULL auto_increment,
302
301
  PRIMARY KEY  (uid)
303
302
) ENGINE=MyISAM;
304
303
INSERT INTO t3 VALUES (1),(15),(27),(75),(117),(250);
305
 
ALTER TABLE t3 add skr int default 42 not null;
 
304
ALTER TABLE t3 add skr int(10) not null;
306
305
 
307
306
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;
308
307
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;
309
308
 
310
309
# The following ORDER BY can be optimimized
311
 
select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid;
312
 
SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
 
310
EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid;
 
311
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
313
312
 
314
313
# The following ORDER BY can't be optimimized
315
 
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;
316
 
SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
317
 
SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
 
314
EXPLAIN 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;
 
315
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
 
316
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
318
317
drop table t1,t2,t3;
319
318
 
320
319
#
323
322
 
324
323
CREATE TABLE t1 (
325
324
  `titre` char(80) NOT NULL default '',
326
 
  `numeropost` int NOT NULL auto_increment,
327
 
  `date` datetime,
 
325
  `numeropost` mediumint(8) NOT NULL auto_increment,
 
326
  `date` datetime NOT NULL default '0000-00-00 00:00:00',
328
327
  `auteur` char(35) NOT NULL default '',
329
 
  `icone` int NOT NULL default '0',
 
328
  `icone` int(2) NOT NULL default '0',
330
329
  `lastauteur` char(35) NOT NULL default '',
331
 
  `nbrep` int NOT NULL default '0',
 
330
  `nbrep` int(6) NOT NULL default '0',
332
331
  `dest` char(35) NOT NULL default '',
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',
 
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',
337
336
  PRIMARY KEY  (`numeropost`),
338
337
  KEY `date` (`date`),
339
338
  KEY `dest` (`dest`,`ludest`),
340
339
  KEY `auteur` (`auteur`,`lu`),
341
340
  KEY `auteur_2` (`auteur`,`date`),
342
341
  KEY `dest_2` (`dest`,`date`)
343
 
);
 
342
) CHECKSUM=1;
344
343
 
345
344
CREATE TABLE t2 (
346
 
  `numeropost` int NOT NULL default '0',
 
345
  `numeropost` mediumint(8) NOT NULL default '0',
347
346
  `pseudo` char(35) NOT NULL default '',
348
347
  PRIMARY KEY  (`numeropost`,`pseudo`),
349
348
  KEY `pseudo` (`pseudo`)
377
376
create table t1(id int not null auto_increment primary key, t char(12));
378
377
disable_query_log;
379
378
let $1 = 1000;
380
 
begin;
381
379
while ($1)
382
380
 {
383
381
  eval insert into t1(t) values ('$1'); 
384
382
  dec $1;
385
383
 }
386
 
commit;
387
384
enable_query_log;
388
 
select id,t from t1 force index (primary) order by id;
 
385
explain select id,t from t1 order by id;
 
386
explain select id,t from t1 force index (primary) order by id;
389
387
drop table t1;
390
388
 
391
389
#
393
391
#
394
392
CREATE TABLE t1 (
395
393
  FieldKey varchar(36) NOT NULL default '',
396
 
  LongVal bigint default NULL,
397
 
  StringVal text,
 
394
  LongVal bigint(20) default NULL,
 
395
  StringVal mediumtext,
398
396
  KEY FieldKey (FieldKey),
399
397
  KEY LongField (FieldKey,LongVal),
400
398
  KEY StringField (FieldKey,StringVal(32))
401
399
);
402
400
INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
 
401
EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
403
402
SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
 
403
EXPLAIN SELECT * FROM t1 ignore index (FieldKey, LongField) WHERE FieldKey > '2' ORDER BY LongVal;
404
404
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
 
405
EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
405
406
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
406
407
DROP TABLE t1;
407
408
#
416
417
# Bug when doing an order by on a 1 byte string (Bug #2147)
417
418
#
418
419
 
419
 
CREATE TEMPORARY TABLE t1 (  id int NOT NULL default '0',  menu int NOT NULL default '0',  KEY id (id),  KEY menu (menu)) ENGINE=MyISAM;
 
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
421
INSERT INTO t1 VALUES (11384, 2),(11392, 2);
421
422
SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ;
422
423
drop table t1;
451
452
insert into t1 select null, b, c, d from t2;
452
453
insert into t2 select null, b, c, d from t1;
453
454
insert into t1 select null, b, c, d from t2;
454
 
alter table t1 engine="default";
 
455
optimize table t1;
455
456
set @row=10;
456
457
insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10;
457
458
select * from t1 where a=1 and b in (1) order by c, b, a;
474
475
# Let us also test various ambiguos and potentially ambiguos cases 
475
476
# related to aliases
476
477
#
477
 
--error ER_NON_UNIQ_ERROR
 
478
--error 1052
478
479
select col1 as col, col from t1 order by col;
479
 
--error ER_NON_UNIQ_ERROR
480
 
select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2
481
 
  order by col;
482
 
--error ER_NON_UNIQ_ERROR
483
 
select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2
484
 
  order by col;
485
 
--error ER_NON_UNIQ_ERROR
 
480
--error 1052
 
481
select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2
 
482
  order by col;
 
483
--error 1052
 
484
select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2
 
485
  order by col;
 
486
--error 1052
486
487
select col1 from t1, t2 where t1.col1=t2.col2 order by col;
487
 
--error ER_NON_UNIQ_ERROR
 
488
--error 1052
488
489
select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2
489
490
  order by col;
490
491
 
517
518
# Bug #7331
518
519
#
519
520
 
520
 
create temporary table t1 (
 
521
create table t1 (
521
522
  `sid` decimal(8,0) default null,
522
523
  `wnid` varchar(11) not null default '',
523
524
  key `wnid14` (`wnid`(4)),
524
525
  key `wnid` (`wnid`)
525
 
) engine=myisam;
 
526
) engine=myisam default charset=latin1;
526
527
 
527
528
insert into t1 (`sid`, `wnid`) values
528
529
('10100','01019000000'),('37986','01019000000'),('37987','01019010000'),
580
581
SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str);
581
582
SELECT a + 1 AS num FROM t1 GROUP BY 30 - num;
582
583
SELECT a + 1 AS num FROM t1 HAVING 30 - num;
583
 
--error ER_BAD_FIELD_ERROR
 
584
--error 1054
584
585
SELECT a + 1 AS num, num + 1 FROM t1;
585
586
SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1;
586
 
--error ER_BAD_FIELD_ERROR
 
587
--error 1054
587
588
SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
588
589
DROP TABLE t1;
589
590
 
594
595
CREATE TABLE bug25126 (
595
596
  val int NOT NULL AUTO_INCREMENT PRIMARY KEY
596
597
);
597
 
--error ER_BAD_FIELD_ERROR
 
598
--error 1054
598
599
UPDATE bug25126 SET MissingCol = MissingCol;
599
 
--error ER_BAD_FIELD_ERROR
 
600
--error 1054
600
601
UPDATE bug25126 SET val = val ORDER BY MissingCol;
601
602
UPDATE bug25126 SET val = val ORDER BY val;
602
603
UPDATE bug25126 SET val = 1 ORDER BY val;
603
 
--error ER_BAD_FIELD_ERROR
 
604
--error 1054
604
605
UPDATE bug25126 SET val = 1 ORDER BY MissingCol;
605
 
--error ER_BAD_FIELD_ERROR
 
606
--error 1054
606
607
UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol;
607
 
--error ER_BAD_FIELD_ERROR
 
608
--error 1054
608
609
UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol;
609
 
--error ER_BAD_FIELD_ERROR
 
610
--error 1054
610
611
UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol;
611
 
--error ER_BAD_FIELD_ERROR
 
612
--error 1054
612
613
UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol;
613
 
--error ER_BAD_FIELD_ERROR
 
614
--error 1054
614
615
UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol;
615
 
--error ER_BAD_FIELD_ERROR
 
616
--error 1054
616
617
UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol;
617
618
DROP TABLE bug25126;
618
619
 
624
625
CREATE TABLE t1 (a int);
625
626
 
626
627
SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1;
627
 
--error ER_NON_UNIQ_ERROR
 
628
--error 1052
628
629
SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val;
629
 
--error ER_NON_UNIQ_ERROR
 
630
--error 1052
630
631
SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1;
631
632
 
632
633
DROP TABLE t1;
712
713
drop table t1;
713
714
 
714
715
#
 
716
# Bug#26672: Incorrect SEC_TO_TIME() casting in ORDER BY
 
717
#
 
718
CREATE TABLE t1 (a INT NOT NULL, b TIME);
 
719
INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10);
 
720
UPDATE t1 SET b = SEC_TO_TIME(a);
 
721
 
 
722
# Correct ORDER
 
723
SELECT a, b FROM t1 ORDER BY b DESC;
 
724
 
 
725
# must be ordered as the above
 
726
SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC;
 
727
 
 
728
DROP TABLE t1;
 
729
 
 
730
#
715
731
# BUG#16590: Optimized does not do right "const" table pre-read
716
732
#
717
733
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b));
720
736
CREATE TABLE t2 (a INT, b INT, KEY a (a,b));
721
737
INSERT INTO t2 VALUES (1,1),(1,2),(2,1),(2,2);
722
738
 
723
 
SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b;
 
739
EXPLAIN SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b;
724
740
 
725
741
DROP TABLE t1,t2;
726
742
 
727
743
# End of 5.0
728
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
 
729
783
730
784
# Bug #30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY}
731
785
#
742
796
INSERT INTO t1 SELECT a +32, b +32 FROM t1;
743
797
INSERT INTO t1 SELECT a +64, b +64 FROM t1;
744
798
 
745
 
--error ER_KEY_DOES_NOT_EXITS
 
799
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
 
800
 
 
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
 
746
807
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
747
808
 
748
 
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (primary, ab) GROUP BY a;
 
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
749
817
 
750
818
SELECT @tmp_tables_after = @tmp_tables_before ;
751
819
 
752
 
--error ER_KEY_DOES_NOT_EXITS
 
820
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a;
 
821
 
 
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
 
753
828
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a;
754
 
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (primary, ab) ORDER BY a;
 
829
 
 
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
755
835
 
756
836
SELECT @tmp_tables_after = @tmp_tables_before;
757
837
 
759
839
--echo #
760
840
--echo # Bug#31590: Wrong error message on sort buffer being too small.
761
841
--echo #
762
 
create table t1(a int, b text);
 
842
create table t1(a int, b tinytext);
763
843
insert into t1 values (1,2),(3,2);
764
844
set session sort_buffer_size= 30000;
765
845
set session max_sort_length= 2180;
 
846
--error 1038
766
847
select * from t1 order by b;
767
848
drop table t1;
768
849
 
770
851
# Bug #35206: select query result different if the key is indexed or not
771
852
#
772
853
 
773
 
CREATE TABLE t2 (a varchar(32), b int, c float, d double, 
 
854
CREATE TABLE t2 (a varchar(32), b int(11), c float, d double, 
774
855
  UNIQUE KEY a (a,b,c), KEY b (b), KEY c (c));
775
856
 
776
857
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b));
1211
1292
 
1212
1293
INSERT INTO t3 SELECT * FROM t1;
1213
1294
 
 
1295
EXPLAIN
 
1296
SELECT d FROM t1, t2
 
1297
WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
 
1298
ORDER BY t2.c LIMIT 1;
1214
1299
SELECT d FROM t1, t2
1215
1300
WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
1216
1301
ORDER BY t2.c LIMIT 1;
1217
1302
 
 
1303
EXPLAIN
 
1304
SELECT d FROM t3 AS t1, t2 AS t2 
 
1305
WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
 
1306
ORDER BY t2.c LIMIT 1;
1218
1307
SELECT d FROM t3 AS t1, t2 AS t2 
1219
1308
WHERE t2.b=14 AND t2.a=t1.a AND 5.1<t2.c AND t1.b='DE'
1220
1309
ORDER BY t2.c LIMIT 1;