25
25
INSERT INTO t1 VALUES (2,3,'dd','Y');
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,
192
192
#bug reported by Wouter de Jong
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
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;
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)
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;
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),
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);
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)
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;
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;
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`),
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,
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)
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 ;
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;
528
528
insert into t1 (`sid`, `wnid`) values
529
529
('10100','01019000000'),('37986','01019000000'),('37987','01019010000'),
746
# Bug #28404: query with ORDER BY and ref access
750
id int auto_increment PRIMARY KEY, c2 int, c3 int, INDEX k2(c2), INDEX k3(c3));
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);
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;
771
CREATE TABLE t2 LIKE t1;
772
INSERT INTO t2 SELECT * FROM t1 ORDER BY id;
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;
779
SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20;
784
746
# Bug #30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY}
799
761
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
802
--let $q = `show status like 'Created_tmp_tables';`
803
eval set @tmp_tables_before =
804
CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED);
807
763
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
809
# this query creates one temporary table in itself, which we are not
813
--let $q = `show status like 'Created_tmp_tables';`
814
eval set @tmp_tables_after =
815
CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED);
818
765
SELECT @tmp_tables_after = @tmp_tables_before ;
820
767
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a;
823
--let $q = `show status like 'Created_tmp_tables';`
824
eval set @tmp_tables_before =
825
CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED);
828
769
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a;
831
--let $q = `show status like 'Created_tmp_tables';`
832
eval set @tmp_tables_after =
833
CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED);
836
771
SELECT @tmp_tables_after = @tmp_tables_before;
840
775
--echo # Bug#31590: Wrong error message on sort buffer being too small.
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;
847
781
select * from t1 order by b;
851
785
# Bug #35206: select query result different if the key is indexed or not
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));
857
791
CREATE TABLE t1 (a varchar(32), b char(3), UNIQUE KEY a (a,b), KEY b (b));