~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/group_min_max.test

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
drop table if exists t1;
15
15
--enable_warnings
16
16
 
17
 
create table t1 (
 
17
create TEMPORARY table t1 (
18
18
  a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
19
 
);
 
19
) ENGINE=MYISAM;
20
20
 
21
21
insert into t1 (a1, a2, b, c, d) values
22
22
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
64
64
drop table if exists t2;
65
65
--enable_warnings
66
66
 
67
 
create table t2 (
 
67
create TEMPORARY table t2 (
68
68
  a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(64) default ' '
69
 
);
 
69
) ENGINE=MYISAM;
70
70
insert into t2 select * from t1;
71
71
# add few rows with NULL's in the MIN/MAX column
72
72
insert into t2 (a1, a2, b, c, d) values
101
101
drop table if exists t3;
102
102
--enable_warnings
103
103
 
104
 
create table t3 (
 
104
create TEMPORARY table t3 (
105
105
  a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' '
106
 
);
 
106
) ENGINE=MYISAM;
107
107
 
108
108
insert into t3 (a1, a2, b, c, d) values
109
109
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
369
369
 
370
370
# queries
371
371
select a1,a2,b,       max(c) from t1 where (c > 'b1') group by a1,a2,b;
372
 
select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;
 
372
#select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') group by a1,a2,b;
373
373
select a1,a2,b,       max(c) from t1 where (c > 'f123') group by a1,a2,b;
374
 
select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;
 
374
#select a1,a2,b,min(c),max(c) from t1 where (c > 'f123') group by a1,a2,b;
375
375
select a1,a2,b,       max(c) from t1 where (c < 'a0') group by a1,a2,b;
376
376
select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') group by a1,a2,b;
377
377
select a1,a2,b,       max(c) from t1 where (c < 'k321') group by a1,a2,b;
378
378
select a1,a2,b,min(c),max(c) from t1 where (c < 'k321') group by a1,a2,b;
379
379
select a1,a2,b,       max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
380
 
select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
 
380
#select a1,a2,b,min(c),max(c) from t1 where (c < 'a0') or (c > 'b1') group by a1,a2,b;
381
381
select a1,a2,b,       max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
382
382
select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
383
383
select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
437
437
 
438
438
# queries
439
439
select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
440
 
select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
441
 
select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
 
440
#select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (c > 'b111') group by a1,a2,b;
 
441
#select a1,a2,b,min(c),max(c) from t1 where (a2 >= 'b') and (b = 'a') and (c > 'b111') group by a1,a2,b;
442
442
select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9'))  and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
443
443
select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9'))  and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
444
444
select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
523
523
# BUG #8532 - SELECT DISTINCT a, a causes server to crash
524
524
select distinct a1,a1 from t1;
525
525
select distinct a2,a1,a2,a1 from t1;
526
 
select distinct t1.a1,t2.a1 from t1,t2;
 
526
--sorted_result
 
527
select distinct t1.a1,t2.a1 from t1,t2 where t1.a1 >= '';
527
528
 
528
529
 
529
530
#
689
690
# Bug #14920 Ordering aggregated result sets with composite primary keys
690
691
# corrupts resultset
691
692
#
692
 
create table t1 (c1 int not null,c2 int not null, primary key(c1,c2));
 
693
create TEMPORARY table t1 (c1 int not null,c2 int not null, primary key(c1,c2)) ENGINE=MYISAM;
693
694
insert into t1 (c1,c2) values
694
695
(10,1),(10,2),(10,3),(20,4),(20,5),(20,6),(30,7),(30,8),(30,9);
695
696
select distinct c1, c2 from t1 order by c2;
702
703
#             returns impossible range
703
704
#
704
705
 
705
 
CREATE TABLE t1 (a varchar(5), b int(11), PRIMARY KEY (a,b));
 
706
CREATE TABLE t1 (a varchar(5), b int, PRIMARY KEY (a,b));
706
707
INSERT INTO t1 VALUES ('AA',1), ('AA',2), ('AA',3), ('BB',1), ('AA',4);
707
 
OPTIMIZE TABLE t1;
 
708
ALTER TABLE t1 ENGINE="DEFAULT";
708
709
 
709
710
SELECT a FROM t1 WHERE a='AA' GROUP BY a;
710
711
SELECT a FROM t1 WHERE a='BB' GROUP BY a;
904
905
SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
905
906
 
906
907
DROP TABLE t1;
 
908
 
 
909
#
 
910
# Bug #309547 key_infix_len can be overwritten causing some group by 
 
911
# queries return no rows
 
912
 
 
913
CREATE TABLE t1 (a int, b int, c int, d int,
 
914
  KEY foo (c,d,a,b), KEY bar (c,a,b,d));
 
915
 
 
916
INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
 
917
INSERT INTO t1 SELECT * FROM t1;
 
918
INSERT INTO t1 SELECT * FROM t1;
 
919
INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
 
920
 
 
921
#Should be non-empty
 
922
EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
 
923
SELECT DISTINCT c FROM t1 WHERE d=4;
 
924
 
 
925
DROP TABLE t1;