~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/order_by.test

  • Committer: Brian Aker
  • Date: 2009-04-27 14:36:40 UTC
  • Revision ID: brian@gaz-20090427143640-f6zjmtt9vm55qgm2
Patch on show processlist from  davi@apache.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
191
191
 
192
192
#bug reported by Wouter de Jong
193
193
 
194
 
CREATE TEMPORARY TABLE t1 (
 
194
CREATE TABLE t1 (
195
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 '',
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
278
278
drop table t1;
279
279
 
280
280
 
281
 
CREATE TEMPORARY TABLE t1 (
 
281
CREATE TABLE t1 (
282
282
  gid int NOT NULL auto_increment,
283
283
  cid int NOT NULL default '0',
284
284
  PRIMARY KEY  (gid),
285
285
  KEY component_id (cid)
286
286
) ENGINE=MyISAM;
287
287
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;
 
288
ALTER TABLE t1 add skr int not null;
289
289
 
290
 
CREATE TEMPORARY TABLE t2 (
 
290
CREATE TABLE t2 (
291
291
  gid int NOT NULL default '0',
292
292
  uid int NOT NULL default '1',
293
293
  sid int NOT NULL default '1',
297
297
) ENGINE=MyISAM;
298
298
INSERT INTO t2 VALUES (103853,250,5),(103867,27,5),(103962,27,5),(104505,117,5),(104619,75,5),(104620,15,5);
299
299
 
300
 
CREATE TEMPORARY TABLE t3 (
 
300
CREATE TABLE t3 (
301
301
  uid int NOT NULL auto_increment,
302
302
  PRIMARY KEY  (uid)
303
303
) ENGINE=MyISAM;
304
304
INSERT INTO t3 VALUES (1),(15),(27),(75),(117),(250);
305
 
ALTER TABLE t3 add skr int default 42 not null;
 
305
ALTER TABLE t3 add skr int not null;
306
306
 
307
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;
308
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;
340
340
  KEY `auteur` (`auteur`,`lu`),
341
341
  KEY `auteur_2` (`auteur`,`date`),
342
342
  KEY `dest_2` (`dest`,`date`)
343
 
);
 
343
) CHECKSUM=1;
344
344
 
345
345
CREATE TABLE t2 (
346
346
  `numeropost` int NOT NULL default '0',
416
416
# Bug when doing an order by on a 1 byte string (Bug #2147)
417
417
#
418
418
 
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;
 
419
CREATE TABLE t1 (  id int NOT NULL default '0',  menu int NOT NULL default '0',  KEY id (id),  KEY menu (menu)) ENGINE=MyISAM;
420
420
INSERT INTO t1 VALUES (11384, 2),(11392, 2);
421
421
SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ;
422
422
drop table t1;
451
451
insert into t1 select null, b, c, d from t2;
452
452
insert into t2 select null, b, c, d from t1;
453
453
insert into t1 select null, b, c, d from t2;
454
 
alter table t1 engine="default";
 
454
optimize table t1;
455
455
set @row=10;
456
456
insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10;
457
457
select * from t1 where a=1 and b in (1) order by c, b, a;
474
474
# Let us also test various ambiguos and potentially ambiguos cases 
475
475
# related to aliases
476
476
#
477
 
--error ER_NON_UNIQ_ERROR
 
477
--error 1052
478
478
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
 
479
--error 1052
 
480
select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2
 
481
  order by col;
 
482
--error 1052
 
483
select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2
 
484
  order by col;
 
485
--error 1052
486
486
select col1 from t1, t2 where t1.col1=t2.col2 order by col;
487
 
--error ER_NON_UNIQ_ERROR
 
487
--error 1052
488
488
select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2
489
489
  order by col;
490
490
 
517
517
# Bug #7331
518
518
#
519
519
 
520
 
create temporary table t1 (
 
520
create table t1 (
521
521
  `sid` decimal(8,0) default null,
522
522
  `wnid` varchar(11) not null default '',
523
523
  key `wnid14` (`wnid`(4)),
580
580
SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str);
581
581
SELECT a + 1 AS num FROM t1 GROUP BY 30 - num;
582
582
SELECT a + 1 AS num FROM t1 HAVING 30 - num;
583
 
--error ER_BAD_FIELD_ERROR
 
583
--error 1054
584
584
SELECT a + 1 AS num, num + 1 FROM t1;
585
585
SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1;
586
 
--error ER_BAD_FIELD_ERROR
 
586
--error 1054
587
587
SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
588
588
DROP TABLE t1;
589
589
 
594
594
CREATE TABLE bug25126 (
595
595
  val int NOT NULL AUTO_INCREMENT PRIMARY KEY
596
596
);
597
 
--error ER_BAD_FIELD_ERROR
 
597
--error 1054
598
598
UPDATE bug25126 SET MissingCol = MissingCol;
599
 
--error ER_BAD_FIELD_ERROR
 
599
--error 1054
600
600
UPDATE bug25126 SET val = val ORDER BY MissingCol;
601
601
UPDATE bug25126 SET val = val ORDER BY val;
602
602
UPDATE bug25126 SET val = 1 ORDER BY val;
603
 
--error ER_BAD_FIELD_ERROR
 
603
--error 1054
604
604
UPDATE bug25126 SET val = 1 ORDER BY MissingCol;
605
 
--error ER_BAD_FIELD_ERROR
 
605
--error 1054
606
606
UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol;
607
 
--error ER_BAD_FIELD_ERROR
 
607
--error 1054
608
608
UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol;
609
 
--error ER_BAD_FIELD_ERROR
 
609
--error 1054
610
610
UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol;
611
 
--error ER_BAD_FIELD_ERROR
 
611
--error 1054
612
612
UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol;
613
 
--error ER_BAD_FIELD_ERROR
 
613
--error 1054
614
614
UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol;
615
 
--error ER_BAD_FIELD_ERROR
 
615
--error 1054
616
616
UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol;
617
617
DROP TABLE bug25126;
618
618
 
624
624
CREATE TABLE t1 (a int);
625
625
 
626
626
SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1;
627
 
--error ER_NON_UNIQ_ERROR
 
627
--error 1052
628
628
SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val;
629
 
--error ER_NON_UNIQ_ERROR
 
629
--error 1052
630
630
SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1;
631
631
 
632
632
DROP TABLE t1;
742
742
INSERT INTO t1 SELECT a +32, b +32 FROM t1;
743
743
INSERT INTO t1 SELECT a +64, b +64 FROM t1;
744
744
 
745
 
--error ER_KEY_DOES_NOT_EXITS
746
745
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
747
746
 
748
 
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (primary, ab) GROUP BY a;
749
 
 
750
747
SELECT @tmp_tables_after = @tmp_tables_before ;
751
748
 
752
 
--error ER_KEY_DOES_NOT_EXITS
753
749
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;
755
750
 
756
751
SELECT @tmp_tables_after = @tmp_tables_before;
757
752