~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/count_distinct3.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Bug #958 a big table without indices and select with group by doesnt work
 
2
# this is a test for error 1032 in count(distinct) + group by, introduced in 
 
3
# mysql-4.1
 
4
#
 
5
 
 
6
--source include/big_test.inc
 
7
 
 
8
--disable_warnings
 
9
DROP TABLE IF EXISTS t1, t2;
 
10
--enable_warnings
 
11
 
 
12
CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
 
13
 
 
14
--disable_query_log
 
15
SET @rnd_max= 2147483647;
 
16
let $1 = 1000;
 
17
while ($1)
 
18
{
 
19
  SET @rnd= RAND();
 
20
  SET @id = CAST(@rnd * @rnd_max AS UNSIGNED);
 
21
  SET @id_rev= @rnd_max - @id;
 
22
  SET @grp= CAST(127.0 * @rnd AS UNSIGNED); 
 
23
  INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); 
 
24
  dec $1;
 
25
}
 
26
 
 
27
# We increase the size of t1 here.
 
28
SET @orig_myisam_sort_buffer_size = @@session.myisam_sort_buffer_size;
 
29
SET session myisam_sort_buffer_size=20000000;
 
30
INSERT INTO t1
 
31
SELECT A.id, A.grp, A.id_rev
 
32
FROM 
 
33
  t1 A,
 
34
  (SELECT * FROM t1 B LIMIT 100) B,
 
35
  (SELECT * FROM t1 Z LIMIT 42) Z;
 
36
--enable_query_log
 
37
 
 
38
SELECT COUNT(*) FROM t1;
 
39
 
 
40
# As t1 contains random numbers, results are different from test to test. 
 
41
# That's okay, because we test only that select doesn't yield an
 
42
# error. Note, that --disable_result_log doesn't suppress error output.
 
43
--disable_result_log
 
44
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
 
45
--enable_result_log
 
46
 
 
47
--echo # Begin cleanup
 
48
SET session myisam_sort_buffer_size = @orig_myisam_sort_buffer_size;
 
49
DROP TABLE t1;
 
50
 
 
51
# End of 4.1 tests