~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/group_by.result

  • Committer: Monty Taylor
  • Date: 2008-11-16 05:36:13 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116053613-bld4rqxhlkb49c02
Split out cache_row and type_holder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
lsg char(40),
9
9
date date
10
10
);
11
 
INSERT INTO t1 VALUES (1,1,1,'',NULL);
12
 
INSERT INTO t1 VALUES (2,2,2,'',NULL);
13
 
INSERT INTO t1 VALUES (2,1,1,'',NULL);
14
 
INSERT INTO t1 VALUES (3,3,3,'',NULL);
 
11
INSERT INTO t1 VALUES (1,1,1,'','0000-00-00');
 
12
INSERT INTO t1 VALUES (2,2,2,'','0000-00-00');
 
13
INSERT INTO t1 VALUES (2,1,1,'','0000-00-00');
 
14
INSERT INTO t1 VALUES (3,3,3,'','0000-00-00');
15
15
CREATE TABLE t2 (
16
16
userID int NOT NULL auto_increment,
17
17
niName char(15),
60
60
drop table t1,t2;
61
61
CREATE TABLE t1 (
62
62
PID int NOT NULL auto_increment,
63
 
payDate date,
64
 
recDate datetime,
 
63
payDate date DEFAULT '0000-00-00' NOT NULL,
 
64
recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
65
65
URID int DEFAULT '0' NOT NULL,
66
66
CRID int DEFAULT '0' NOT NULL,
67
67
amount int DEFAULT '0' NOT NULL,
68
68
operator int,
69
69
method enum('unknown','cash','dealer','check','card','lazy','delayed','test') DEFAULT 'unknown' NOT NULL,
70
70
DIID int,
71
 
reason char(1) DEFAULT '' NOT NULL,
 
71
reason char(1) binary DEFAULT '' NOT NULL,
72
72
code_id int,
73
73
qty int DEFAULT '0' NOT NULL,
74
74
PRIMARY KEY (PID),
95
95
PRIMARY KEY (call_id),
96
96
KEY contact_id (contact_id)
97
97
);
 
98
lock tables t1 read,t2 write;
98
99
INSERT INTO t2 VALUES (10,2);
99
100
INSERT INTO t2 VALUES (18,2);
100
101
INSERT INTO t2 VALUES (62,2);
104
105
cid     CONCAT(firstname, ' ', surname) COUNT(call_id)
105
106
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;
106
107
cid     CONCAT(firstname, ' ', surname) COUNT(call_id)
107
 
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;
 
108
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;
108
109
cid     CONCAT(firstname, ' ', surname) COUNT(call_id)
109
110
drop table t2;
 
111
unlock tables;
110
112
drop table t1;
111
113
create table t1 (foo int);
112
114
insert into t1 values (1);
205
207
NULL    3
206
208
A       5
207
209
B       5
208
 
SELECT a FROM t1 GROUP BY a;
209
 
a
210
 
NULL
211
 
A
212
 
B
213
 
SELECT a,count(*) FROM t1 GROUP BY a;
214
 
a       count(*)
215
 
NULL    3
216
 
A       5
217
 
B       5
218
 
SELECT a FROM t1 GROUP BY 1;
219
 
a
220
 
NULL
221
 
A
222
 
B
223
 
SELECT a,count(*) FROM t1 GROUP BY 1;
224
 
a       count(*)
225
 
NULL    3
226
 
A       5
227
 
B       5
228
 
SELECT a FROM t1 GROUP BY a;
229
 
a
230
 
NULL
231
 
A
232
 
B
233
 
SELECT a,count(*) FROM t1 GROUP BY a;
234
 
a       count(*)
235
 
NULL    3
236
 
A       5
237
 
B       5
238
 
SELECT a FROM t1 GROUP BY a;
239
 
a
240
 
NULL
241
 
A
242
 
B
243
 
SELECT a,count(*) FROM t1 GROUP BY a;
244
 
a       count(*)
245
 
NULL    3
246
 
A       5
247
 
B       5
248
 
SELECT a FROM t1 GROUP BY 1;
249
 
a
250
 
NULL
251
 
A
252
 
B
253
 
SELECT a,count(*) FROM t1 GROUP BY 1;
254
 
a       count(*)
255
 
NULL    3
256
 
A       5
257
 
B       5
 
210
SELECT a FROM t1 GROUP BY binary a;
 
211
a
 
212
NULL
 
213
A
 
214
B
 
215
a
 
216
b
 
217
SELECT a,count(*) FROM t1 GROUP BY binary a;
 
218
a       count(*)
 
219
NULL    3
 
220
A       4
 
221
B       4
 
222
a       1
 
223
b       1
 
224
SELECT binary a FROM t1 GROUP BY 1;
 
225
binary a 
 
226
NULL
 
227
A
 
228
B
 
229
a
 
230
b
 
231
SELECT binary a,count(*) FROM t1 GROUP BY 1;
 
232
binary a        count(*)
 
233
NULL    3
 
234
A       4
 
235
B       4
 
236
a       1
 
237
b       1
 
238
SELECT a FROM t1 GROUP BY a;
 
239
a
 
240
NULL
 
241
A
 
242
B
 
243
SELECT a,count(*) FROM t1 GROUP BY a;
 
244
a       count(*)
 
245
NULL    3
 
246
A       5
 
247
B       5
 
248
SELECT a FROM t1 GROUP BY binary a;
 
249
a
 
250
NULL
 
251
A
 
252
B
 
253
a
 
254
b
 
255
SELECT a,count(*) FROM t1 GROUP BY binary a;
 
256
a       count(*)
 
257
NULL    3
 
258
A       4
 
259
B       4
 
260
a       1
 
261
b       1
 
262
SELECT binary a FROM t1 GROUP BY 1;
 
263
binary a 
 
264
NULL
 
265
A
 
266
B
 
267
a
 
268
b
 
269
SELECT binary a,count(*) FROM t1 GROUP BY 1;
 
270
binary a        count(*)
 
271
NULL    3
 
272
A       4
 
273
B       4
 
274
a       1
 
275
b       1
258
276
drop table t1;
259
277
CREATE TABLE t1 (
260
278
`a` char(193) default NULL,
326
344
3       134     ***
327
345
4       185     ****
328
346
drop table t1;
329
 
CREATE TEMPORARY TABLE t1 (
 
347
CREATE TABLE t1 (
330
348
pid int NOT NULL default '0',
331
349
c1id int default NULL,
332
350
c2id int default NULL,
335
353
UNIQUE KEY pid (pid,value)
336
354
) ENGINE=MyISAM;
337
355
INSERT INTO t1 VALUES (1, 1, NULL, 1),(1, 2, NULL, 2),(1, NULL, 3, 3),(1, 4, NULL, 4),(1, 5, NULL, 5);
338
 
CREATE TEMPORARY TABLE t2 (
 
356
CREATE TABLE t2 (
339
357
id int NOT NULL default '0',
340
358
active enum('Yes','No') NOT NULL default 'Yes',
341
359
PRIMARY KEY  (id)
543
561
primary key (a,b(132),c,d),
544
562
key a (a,b)
545
563
);
 
564
Warnings:
 
565
Warning 1071    Specified key was too long; max key length is 767 bytes
546
566
insert into t2 select 
547
567
x3.a,  -- 3
548
568
concat('val-', x3.a + 3*x4.a), -- 12
552
572
delete from t2  where a = 2 and b = 'val-2' order by a,b,c,d limit 30;
553
573
explain select c from t2 where a = 2 and b = 'val-2' group by c;
554
574
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
555
 
1       SIMPLE  t2      #       PRIMARY,a       a       #       const,const     #       #
 
575
1       SIMPLE  t2      ref     PRIMARY,a       a       770     const,const     36      Using where; Using index
556
576
select c from t2 where a = 2 and b = 'val-2' group by c;
557
577
c
558
578
val-74
895
915
f1      f2
896
916
select * from t1 group by f1, f2;
897
917
f1      f2
898
 
select t1.f1,t.* from t1, t1 t where t1.f1 >= 0 group by 1;
 
918
select t1.f1,t.* from t1, t1 t group by 1;
899
919
f1      f1      f2
900
920
drop table t1;
901
921
CREATE TABLE t1(
1344
1364
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1345
1365
1       SIMPLE  t1      index   NULL    PRIMARY 4       NULL    144     
1346
1366
EXPLAIN SELECT a FROM t1 FORCE INDEX ();
1347
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ')' at line 1
 
1367
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
1348
1368
EXPLAIN SELECT a FROM t1 IGNORE INDEX ();
1349
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ')' at line 1
 
1369
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
1350
1370
EXPLAIN SELECT a FROM t1 USE INDEX FOR JOIN (i2) 
1351
1371
USE INDEX FOR GROUP BY (i2) GROUP BY a;
1352
1372
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1376
1396
EXPLAIN SELECT 1 FROM t1 WHERE a IN
1377
1397
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
1378
1398
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1379
 
1       PRIMARY t1      index   NULL    PRIMARY 4       NULL    144     Using where; Using index
1380
 
2       SUBQUERY        t1      ALL     NULL    NULL    NULL    NULL    144     
 
1399
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    144     Start temporary
 
1400
1       PRIMARY t1      eq_ref  PRIMARY,i2      PRIMARY 4       test.t1.a       1       Using index; End temporary
1381
1401
CREATE TABLE t2 (a INT, b INT, KEY(a));
1382
1402
INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4);
1383
1403
EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2;
1389
1409
EXPLAIN SELECT 1 FROM t2 WHERE a IN
1390
1410
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
1391
1411
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1392
 
1       PRIMARY t2      index   NULL    a       5       NULL    4       Using where; Using index
1393
 
2       SUBQUERY        t1      ALL     NULL    NULL    NULL    NULL    144     
 
1412
1       PRIMARY t2      index   a       a       5       NULL    4       Using index; Start temporary
 
1413
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    144     Using where; End temporary; Using join buffer
 
1414
SHOW VARIABLES LIKE 'old';
 
1415
Variable_name   Value
 
1416
old     OFF
 
1417
SET @@old = off;
 
1418
ERROR HY000: Variable 'old' is a read only variable
1394
1419
DROP TABLE t1, t2;
1395
1420
CREATE TABLE t1(
1396
1421
a INT, 
1482
1507
NULL
1483
1508
1
1484
1509
2
1485
 
DROP TABLE t1,t2;
 
1510
DROP TABLE t1;
1486
1511
CREATE TABLE t1 ( a INT, b INT );
1487
1512
SELECT b c, (SELECT a FROM t1 WHERE b = c)
1488
1513
FROM t1;