diff options
author | unknown <konstantin@mysql.com> | 2005-03-15 03:46:19 +0300 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2005-03-15 03:46:19 +0300 |
commit | 897849e5d8802ebe6a42803cba72caa80cd23415 (patch) | |
tree | 7afe84de6147f4619865e4f759eb1d0ad2f376f8 /mysql-test/t/sum_distinct.test | |
parent | ce4f43cb860e71a3d5e48773e305ff8e5e130872 (diff) | |
download | mariadb-git-897849e5d8802ebe6a42803cba72caa80cd23415.tar.gz |
WL#926 "AVG(DISTINCT) and other distincts", part 2 (out of 3): clean up
Item_sum_count_distinct, and
deploy Unique for use with COUNT(DISTINCT) if there is no blob
column in the list of DISTINCT arguments.
mysql-test/r/count_distinct2.result:
Test results fixed.
mysql-test/r/func_group.result:
Updated.
mysql-test/r/sum_distinct.result:
Updated.
mysql-test/t/func_group.test:
Add a test for COUNT(DISTINCT) and true varchar and case-insensitive
collation. The table in the test contains only two distinct values.
mysql-test/t/sum_distinct.test:
Since now we support INSERT INTO t1 (a) SELECT a+1 FROM t1, shorten
the test.
Add a nominal test for AVG(DISTINCT)
sql/item_sum.cc:
Implementation of cleaned up Item_sum_count_distinct.
Fixed a bug with COUNT(DISTINCT) and new VARCHAR and collations.
Fixed a bug wiht AVG(DISTINCT) and wrong number of output digits
after decimal point.
sql/item_sum.h:
Cleanup for Item_sum_count_distinct.
Now if the list of distinct arguments doesn't contain a blob column,
we always use Unique and merge-sort to find distinct values.
sql/sql_class.h:
Added a short-cut to find number of elements in Unique if all elements fit
into memory.
Diffstat (limited to 'mysql-test/t/sum_distinct.test')
-rw-r--r-- | mysql-test/t/sum_distinct.test | 82 |
1 files changed, 24 insertions, 58 deletions
diff --git a/mysql-test/t/sum_distinct.test b/mysql-test/t/sum_distinct.test index 964da9defa6..3b9f12354e8 100644 --- a/mysql-test/t/sum_distinct.test +++ b/mysql-test/t/sum_distinct.test @@ -103,64 +103,30 @@ CREATE TABLE t1 (id INTEGER); CREATE TABLE t2 (id INTEGER); INSERT INTO t1 (id) VALUES (1), (1), (1),(1); -INSERT INTO t2 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t2; /* 8 */ -INSERT INTO t1 (id) SELECT id FROM t2; /* 12 */ -INSERT INTO t1 (id) SELECT id FROM t2; /* 16 */ -INSERT INTO t1 (id) SELECT id FROM t2; /* 20 */ -INSERT INTO t1 (id) SELECT id FROM t2; /* 24 */ -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+1 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+2 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+4 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+8 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+16 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+32 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+64 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+128 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+256 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+512 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+1024 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+2048 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+4096 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -INSERT INTO t2 (id) SELECT id+8192 FROM t1; -INSERT INTO t1 SELECT id FROM t2; -DELETE FROM t2; -#INSERT INTO t2 (id) SELECT id+16384 FROM t1; -#INSERT INTO t1 SELECT id FROM t2; -#DELETE FROM t2; -#INSERT INTO t2 (id) SELECT id+32768 FROM t1; -#INSERT INTO t1 SELECT id FROM t2; -#DELETE FROM t2; -#INSERT INTO t2 (id) SELECT id+65536 FROM t1; -#INSERT INTO t1 SELECT id FROM t2; -#DELETE FROM t2; +INSERT INTO t1 (id) SELECT id FROM t1; /* 8 */ +INSERT INTO t1 (id) SELECT id FROM t1; /* 12 */ +INSERT INTO t1 (id) SELECT id FROM t1; /* 16 */ +INSERT INTO t1 (id) SELECT id FROM t1; /* 20 */ +INSERT INTO t1 (id) SELECT id FROM t1; /* 24 */ +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; + +# Just test that AVG(DISTINCT) is there +SELECT AVG(DISTINCT id) FROM t1 GROUP BY id % 13; +SELECT SUM(DISTINCT id)/COUNT(DISTINCT id) FROM t1 GROUP BY id % 13; + +INSERT INTO t1 SELECT id+1024 FROM t1; +INSERT INTO t1 SELECT id+2048 FROM t1; +INSERT INTO t1 SELECT id+4096 FROM t1; +INSERT INTO t1 SELECT id+8192 FROM t1; INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand(); # SELECT '++++++++++++++++++++++++++++++++++++++++++++++++++'; |