~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/group_by.test

  • Committer: Stewart Smith
  • Author(s): Marko Mäkelä
  • Date: 2010-12-20 03:21:44 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2022.
  • Revision ID: stewart@flamingspork.com-20101220032144-7aqh2z403u7d7bdp
Merge Revision revid:marko.makela@oracle.com-20101104131215-pfxnpidlrzd4krg0 from MySQL InnoDB

Original revid:marko.makela@oracle.com-20101104131215-pfxnpidlrzd4krg0

Original Authors: Marko Mäkelä <marko.makela@oracle.com>
Original commit message:
row_ins_index_entry(): Note that only CREATE INDEX sets foreign=FALSE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
  date date
23
23
);
24
24
 
25
 
INSERT INTO t1 VALUES (1,1,1,'','0000-00-00');
26
 
INSERT INTO t1 VALUES (2,2,2,'','0000-00-00');
27
 
INSERT INTO t1 VALUES (2,1,1,'','0000-00-00');
28
 
INSERT INTO t1 VALUES (3,3,3,'','0000-00-00');
 
25
INSERT INTO t1 VALUES (1,1,1,'',NULL);
 
26
INSERT INTO t1 VALUES (2,2,2,'',NULL);
 
27
INSERT INTO t1 VALUES (2,1,1,'',NULL);
 
28
INSERT INTO t1 VALUES (3,3,3,'',NULL);
29
29
 
30
30
CREATE TABLE t2 (
31
31
  userID int NOT NULL auto_increment,
62
62
 
63
63
CREATE TABLE t1 (
64
64
  PID int NOT NULL auto_increment,
65
 
  payDate date DEFAULT '0000-00-00' NOT NULL,
66
 
  recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
 
65
  payDate date,
 
66
  recDate datetime,
67
67
  URID int DEFAULT '0' NOT NULL,
68
68
  CRID int DEFAULT '0' NOT NULL,
69
69
  amount int DEFAULT '0' NOT NULL,
70
70
  operator int,
71
71
  method enum('unknown','cash','dealer','check','card','lazy','delayed','test') DEFAULT 'unknown' NOT NULL,
72
72
  DIID int,
73
 
  reason char(1) binary DEFAULT '' NOT NULL,
 
73
  reason char(1) DEFAULT '' NOT NULL,
74
74
  code_id int,
75
75
  qty int DEFAULT '0' NOT NULL,
76
76
  PRIMARY KEY (PID),
82
82
 
83
83
INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6);
84
84
 
85
 
--error 1056
 
85
--error ER_WRONG_GROUP_FIELD
86
86
SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000   AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew;
87
87
 
88
88
drop table t1;
90
90
#
91
91
# Problem with GROUP BY + ORDER BY when no match
92
92
# Tested with locking
 
93
#  NOTE: LOCK TABLE was removed, so now just testing normal syntax.
93
94
#
94
95
 
95
96
CREATE TABLE t1 (
108
109
  KEY contact_id (contact_id)
109
110
);
110
111
 
111
 
lock tables t1 read,t2 write;
112
 
 
113
112
INSERT INTO t2 VALUES (10,2);
114
113
INSERT INTO t2 VALUES (18,2);
115
114
INSERT INTO t2 VALUES (62,2);
118
117
 
119
118
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid;
120
119
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL;
121
 
SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
 
120
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
122
121
 
123
122
drop table t2;
124
 
unlock tables;
125
123
drop table t1;
126
124
 
127
125
# Test needs to be rewritten
170
168
#  KEY votes (votes)
171
169
#);
172
170
#
173
 
#--error 1265
 
171
#--error ER_WARN_DATA_TRUNCATED
174
172
#INSERT INTO t1 VALUES (1,0,0,'','normal','','2000-02-10 09:25:12',20000321114747,'','','Linux','P1','TestProduct','PC',3,'other','TestComponent','','M1',0,'',0);
175
173
#INSERT INTO t1 VALUES (9,0,0,'','enhancement','','2000-03-10 11:49:36',20000321114747,'','','All','P5','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
176
174
#INSERT INTO t1 VALUES (10,0,0,'','enhancement','','2000-03-10 18:10:16',20000321114747,'','','All','P4','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
285
283
INSERT INTO t1 VALUES ('A'),('B'),('A'),('B'),('A'),('B'),(NULL),('a'),('b'),(NULL),('A'),('B'),(NULL);
286
284
SELECT a FROM t1 GROUP BY a;
287
285
SELECT a,count(*) FROM t1 GROUP BY a;
288
 
SELECT a FROM t1 GROUP BY binary a;
289
 
SELECT a,count(*) FROM t1 GROUP BY binary a;
290
 
SELECT binary a FROM t1 GROUP BY 1;
291
 
SELECT binary a,count(*) FROM t1 GROUP BY 1;
 
286
SELECT a FROM t1 GROUP BY a;
 
287
SELECT a,count(*) FROM t1 GROUP BY a;
 
288
SELECT a FROM t1 GROUP BY 1;
 
289
SELECT a,count(*) FROM t1 GROUP BY 1;
292
290
# Do the same tests with MyISAM temporary tables
293
291
SELECT a FROM t1 GROUP BY a;
294
292
SELECT a,count(*) FROM t1 GROUP BY a;
295
 
SELECT a FROM t1 GROUP BY binary a;
296
 
SELECT a,count(*) FROM t1 GROUP BY binary a;
297
 
SELECT binary a FROM t1 GROUP BY 1;
298
 
SELECT binary a,count(*) FROM t1 GROUP BY 1;
 
293
SELECT a FROM t1 GROUP BY a;
 
294
SELECT a,count(*) FROM t1 GROUP BY a;
 
295
SELECT a FROM t1 GROUP BY 1;
 
296
SELECT a,count(*) FROM t1 GROUP BY 1;
299
297
drop table t1;
300
298
 
301
299
#
347
345
# Problem with MAX and LEFT JOIN
348
346
#
349
347
 
350
 
CREATE TABLE t1 (
 
348
CREATE TEMPORARY TABLE t1 (
351
349
  pid int NOT NULL default '0',
352
350
  c1id int default NULL,
353
351
  c2id int default NULL,
358
356
 
359
357
INSERT INTO t1 VALUES (1, 1, NULL, 1),(1, 2, NULL, 2),(1, NULL, 3, 3),(1, 4, NULL, 4),(1, 5, NULL, 5);
360
358
 
361
 
CREATE TABLE t2 (
 
359
CREATE TEMPORARY TABLE t2 (
362
360
  id int NOT NULL default '0',
363
361
  active enum('Yes','No') NOT NULL default 'Yes',
364
362
  PRIMARY KEY  (id)
402
400
insert into t2 values (1,3),(3,1),(2,2),(1,1);
403
401
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
404
402
select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
 
403
--sorted_result
405
404
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
 
405
--sorted_result
406
406
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
407
407
drop table t1,t2;
408
408
 
512
512
 
513
513
delete from t2  where a = 2 and b = 'val-2' order by a,b,c,d limit 30;
514
514
 
 
515
--replace_column 4 # 7 # 9 # 10 #
515
516
explain select c from t2 where a = 2 and b = 'val-2' group by c;
516
517
select c from t2 where a = 2 and b = 'val-2' group by c;
517
518
drop table t1,t2;
955
956
EXPLAIN SELECT 1 FROM t2 WHERE a IN
956
957
  (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
957
958
 
958
 
SHOW VARIABLES LIKE 'old';  
959
 
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
960
 
SET @@old = off;  
961
 
 
962
959
DROP TABLE t1, t2;
963
960
 
964
961
#
1003
1000
EXPLAIN SELECT b from t2 GROUP BY b;
1004
1001
SELECT b from t2 GROUP BY b;
1005
1002
 
1006
 
DROP TABLE t1;
 
1003
DROP TABLE t1,t2;
1007
1004
 
1008
1005
#
1009
1006
# Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING