~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/group_by.test

  • Committer: Brian Aker
  • Date: 2009-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

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,'',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);
 
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');
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,
66
 
  recDate datetime,
 
65
  payDate date DEFAULT '0000-00-00' NOT NULL,
 
66
  recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
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) DEFAULT '' NOT NULL,
 
73
  reason char(1) binary DEFAULT '' NOT NULL,
74
74
  code_id int,
75
75
  qty int DEFAULT '0' NOT NULL,
76
76
  PRIMARY KEY (PID),
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.
94
93
#
95
94
 
96
95
CREATE TABLE t1 (
109
108
  KEY contact_id (contact_id)
110
109
);
111
110
 
 
111
lock tables t1 read,t2 write;
 
112
 
112
113
INSERT INTO t2 VALUES (10,2);
113
114
INSERT INTO t2 VALUES (18,2);
114
115
INSERT INTO t2 VALUES (62,2);
117
118
 
118
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;
119
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 NULL;
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;
 
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;
121
122
 
122
123
drop table t2;
 
124
unlock tables;
123
125
drop table t1;
124
126
 
125
127
# Test needs to be rewritten
283
285
INSERT INTO t1 VALUES ('A'),('B'),('A'),('B'),('A'),('B'),(NULL),('a'),('b'),(NULL),('A'),('B'),(NULL);
284
286
SELECT a FROM t1 GROUP BY a;
285
287
SELECT a,count(*) FROM t1 GROUP BY a;
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;
 
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;
290
292
# Do the same tests with MyISAM temporary tables
291
293
SELECT a FROM t1 GROUP BY a;
292
294
SELECT a,count(*) FROM t1 GROUP BY a;
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;
 
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;
297
299
drop table t1;
298
300
 
299
301
#
345
347
# Problem with MAX and LEFT JOIN
346
348
#
347
349
 
348
 
CREATE TEMPORARY TABLE t1 (
 
350
CREATE TABLE t1 (
349
351
  pid int NOT NULL default '0',
350
352
  c1id int default NULL,
351
353
  c2id int default NULL,
356
358
 
357
359
INSERT INTO t1 VALUES (1, 1, NULL, 1),(1, 2, NULL, 2),(1, NULL, 3, 3),(1, 4, NULL, 4),(1, 5, NULL, 5);
358
360
 
359
 
CREATE TEMPORARY TABLE t2 (
 
361
CREATE TABLE t2 (
360
362
  id int NOT NULL default '0',
361
363
  active enum('Yes','No') NOT NULL default 'Yes',
362
364
  PRIMARY KEY  (id)
953
955
EXPLAIN SELECT 1 FROM t2 WHERE a IN
954
956
  (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
955
957
 
 
958
SHOW VARIABLES LIKE 'old';  
 
959
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
 
960
SET @@old = off;  
 
961
 
956
962
DROP TABLE t1, t2;
957
963
 
958
964
#
997
1003
EXPLAIN SELECT b from t2 GROUP BY b;
998
1004
SELECT b from t2 GROUP BY b;
999
1005
 
1000
 
DROP TABLE t1,t2;
 
1006
DROP TABLE t1;
1001
1007
 
1002
1008
#
1003
1009
# Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING