~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
396 by Brian Aker
Cleanup tiny and small int.
10
CREATE TABLE t1 (id INTEGER, grp int, id_rev INTEGER);
1 by brian
clean slate
11
12
--disable_query_log
13
SET @rnd_max= 2147483647;
14
let $1 = 1000;
590.1.6 by Stewart Smith
reduce data used in count_distinct3 to make test 60 times faster to run.
15
begin;
1 by brian
clean slate
16
while ($1)
17
{
18
  SET @rnd= RAND();
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
19
  SET @id = @rnd * @rnd_max;
1 by brian
clean slate
20
  SET @id_rev= @rnd_max - @id;
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
21
  SET @grp= 127.0 * @rnd;
1 by brian
clean slate
22
  INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); 
23
  dec $1;
24
}
590.1.6 by Stewart Smith
reduce data used in count_distinct3 to make test 60 times faster to run.
25
commit;
1 by brian
clean slate
26
set @@read_buffer_size=2*1024*1024;
27
CREATE TABLE t2 SELECT * 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
DROP TABLE t2;
35
--enable_query_log
36
37
SELECT COUNT(*) FROM t1;
38
39
# As t1 contains random numbers, results are different from test to test. 
40
# That's okay, because we test only that select doesn't yield an
41
# error. Note, that --disable_result_log doesn't suppress error output.
42
43
--disable_result_log
44
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
45
--enable_result_log
46
DROP TABLE t1;
47
48
set @@read_buffer_size=default;
49
50
# End of 4.1 tests