~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# this is a test for error 1032 in count(distinct) + group by, introduced in 
3
# mysql-4.1
4
#
5
6
--disable_warnings
7
DROP TABLE IF EXISTS t1, t2;
8
--enable_warnings
9
10
CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
11
12
--disable_query_log
13
SET @rnd_max= 2147483647;
14
let $1 = 1000;
15
while ($1)
16
{
17
  SET @rnd= RAND();
18
  SET @id = CAST(@rnd * @rnd_max AS UNSIGNED);
19
  SET @id_rev= @rnd_max - @id;
20
  SET @grp= CAST(127.0 * @rnd AS UNSIGNED); 
21
  INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); 
22
  dec $1;
23
}
24
set @@read_buffer_size=2*1024*1024;
25
CREATE TABLE t2 SELECT * FROM t1;
26
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
27
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
28
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
29
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
30
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
31
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
32
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
33
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
34
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
35
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
36
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
37
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
38
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
39
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
40
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
41
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
42
INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
43
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
44
DROP TABLE t2;
45
--enable_query_log
46
47
SELECT COUNT(*) FROM t1;
48
49
# As t1 contains random numbers, results are different from test to test. 
50
# That's okay, because we test only that select doesn't yield an
51
# error. Note, that --disable_result_log doesn't suppress error output.
52
53
--disable_result_log
54
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
55
--enable_result_log
56
DROP TABLE t1;
57
58
set @@read_buffer_size=default;
59
60
# End of 4.1 tests