~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-16 09:12:23 UTC
  • mto: (511.1.6 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016091223-17ngih0qu9vssjs3
We pass -Wunused-macros now!

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 '',
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
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),
287
287
INSERT INTO t1 VALUES (103853,108),(103867,108),(103962,108),(104505,108),(104619,108),(104620,108);
288
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;
324
324
CREATE TABLE t1 (
325
325
  `titre` char(80) NOT NULL default '',
326
326
  `numeropost` int NOT NULL auto_increment,
327
 
  `date` datetime,
 
327
  `date` datetime NOT NULL default '0000-00-00 00:00:00',
328
328
  `auteur` char(35) NOT NULL default '',
329
329
  `icone` int NOT NULL default '0',
330
330
  `lastauteur` char(35) NOT NULL default '',
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',
377
377
create table t1(id int not null auto_increment primary key, t char(12));
378
378
disable_query_log;
379
379
let $1 = 1000;
380
 
begin;
381
380
while ($1)
382
381
 {
383
382
  eval insert into t1(t) values ('$1'); 
384
383
  dec $1;
385
384
 }
386
 
commit;
387
385
enable_query_log;
388
386
select id,t from t1 force index (primary) order by id;
389
387
drop table t1;
416
414
# Bug when doing an order by on a 1 byte string (Bug #2147)
417
415
#
418
416
 
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;
 
417
CREATE TABLE t1 (  id int NOT NULL default '0',  menu int NOT NULL default '0',  KEY id (id),  KEY menu (menu)) ENGINE=MyISAM;
420
418
INSERT INTO t1 VALUES (11384, 2),(11392, 2);
421
419
SELECT id FROM t1 WHERE id <11984 AND menu =2 ORDER BY id DESC LIMIT 1 ;
422
420
drop table t1;
451
449
insert into t1 select null, b, c, d from t2;
452
450
insert into t2 select null, b, c, d from t1;
453
451
insert into t1 select null, b, c, d from t2;
454
 
alter table t1 engine="default";
 
452
optimize table t1;
455
453
set @row=10;
456
454
insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10;
457
455
select * from t1 where a=1 and b in (1) order by c, b, a;
474
472
# Let us also test various ambiguos and potentially ambiguos cases 
475
473
# related to aliases
476
474
#
477
 
--error ER_NON_UNIQ_ERROR
 
475
--error 1052
478
476
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
 
477
--error 1052
 
478
select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2
 
479
  order by col;
 
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
486
484
select col1 from t1, t2 where t1.col1=t2.col2 order by col;
487
 
--error ER_NON_UNIQ_ERROR
 
485
--error 1052
488
486
select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2
489
487
  order by col;
490
488
 
517
515
# Bug #7331
518
516
#
519
517
 
520
 
create temporary table t1 (
 
518
create table t1 (
521
519
  `sid` decimal(8,0) default null,
522
520
  `wnid` varchar(11) not null default '',
523
521
  key `wnid14` (`wnid`(4)),
580
578
SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str);
581
579
SELECT a + 1 AS num FROM t1 GROUP BY 30 - num;
582
580
SELECT a + 1 AS num FROM t1 HAVING 30 - num;
583
 
--error ER_BAD_FIELD_ERROR
 
581
--error 1054
584
582
SELECT a + 1 AS num, num + 1 FROM t1;
585
583
SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1;
586
 
--error ER_BAD_FIELD_ERROR
 
584
--error 1054
587
585
SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
588
586
DROP TABLE t1;
589
587
 
594
592
CREATE TABLE bug25126 (
595
593
  val int NOT NULL AUTO_INCREMENT PRIMARY KEY
596
594
);
597
 
--error ER_BAD_FIELD_ERROR
 
595
--error 1054
598
596
UPDATE bug25126 SET MissingCol = MissingCol;
599
 
--error ER_BAD_FIELD_ERROR
 
597
--error 1054
600
598
UPDATE bug25126 SET val = val ORDER BY MissingCol;
601
599
UPDATE bug25126 SET val = val ORDER BY val;
602
600
UPDATE bug25126 SET val = 1 ORDER BY val;
603
 
--error ER_BAD_FIELD_ERROR
 
601
--error 1054
604
602
UPDATE bug25126 SET val = 1 ORDER BY MissingCol;
605
 
--error ER_BAD_FIELD_ERROR
 
603
--error 1054
606
604
UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol;
607
 
--error ER_BAD_FIELD_ERROR
 
605
--error 1054
608
606
UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol;
609
 
--error ER_BAD_FIELD_ERROR
 
607
--error 1054
610
608
UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol;
611
 
--error ER_BAD_FIELD_ERROR
 
609
--error 1054
612
610
UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol;
613
 
--error ER_BAD_FIELD_ERROR
 
611
--error 1054
614
612
UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol;
615
 
--error ER_BAD_FIELD_ERROR
 
613
--error 1054
616
614
UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol;
617
615
DROP TABLE bug25126;
618
616
 
624
622
CREATE TABLE t1 (a int);
625
623
 
626
624
SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1;
627
 
--error ER_NON_UNIQ_ERROR
 
625
--error 1052
628
626
SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val;
629
 
--error ER_NON_UNIQ_ERROR
 
627
--error 1052
630
628
SELECT p.a AS val, q.a AS val FROM t1 p, t1 q ORDER BY val > 1;
631
629
 
632
630
DROP TABLE t1;
712
710
drop table t1;
713
711
 
714
712
#
 
713
# Bug#26672: Incorrect SEC_TO_TIME() casting in ORDER BY
 
714
#
 
715
CREATE TABLE t1 (a INT NOT NULL, b TIME);
 
716
INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10);
 
717
UPDATE t1 SET b = SEC_TO_TIME(a);
 
718
 
 
719
# Correct ORDER
 
720
SELECT a, b FROM t1 ORDER BY b DESC;
 
721
 
 
722
# must be ordered as the above
 
723
SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC;
 
724
 
 
725
DROP TABLE t1;
 
726
 
 
727
#
715
728
# BUG#16590: Optimized does not do right "const" table pre-read
716
729
#
717
730
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b));
742
755
INSERT INTO t1 SELECT a +32, b +32 FROM t1;
743
756
INSERT INTO t1 SELECT a +64, b +64 FROM t1;
744
757
 
745
 
--error ER_KEY_DOES_NOT_EXITS
746
758
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a;
747
759
 
748
 
SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (primary, ab) GROUP BY a;
749
 
 
750
760
SELECT @tmp_tables_after = @tmp_tables_before ;
751
761
 
752
 
--error ER_KEY_DOES_NOT_EXITS
753
762
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
763
 
756
764
SELECT @tmp_tables_after = @tmp_tables_before;
757
765