Commit 8a27426f authored by unknown's avatar unknown

Tests and results fixed with last precision/decimal related modifications


mysql-test/r/case.result:
  test result fixed
mysql-test/r/create.result:
  test result fixed
mysql-test/r/distinct.result:
  test result fixed
mysql-test/r/func_group.result:
  test result fixed
mysql-test/r/func_op.result:
  test result fixed
mysql-test/r/group_by.result:
  test result fixed
mysql-test/r/metadata.result:
  test result fixed
mysql-test/r/olap.result:
  test result fixed
mysql-test/r/ps_2myisam.result:
  test result fixed
mysql-test/r/ps_3innodb.result:
  test result fixed
mysql-test/r/ps_4heap.result:
  test result fixed
mysql-test/r/ps_5merge.result:
  test result fixed
mysql-test/r/ps_6bdb.result:
  test result fixed
mysql-test/r/ps_7ndb.result:
  test result fixed
mysql-test/r/select.result:
  test result fixed
mysql-test/r/sp.result:
  test result fixed
mysql-test/r/type_decimal.result:
  test result fixed
mysql-test/r/type_newdecimal.result:
  test result fixed
mysql-test/r/union.result:
  test result fixed
mysql-test/r/variables.result:
  test result fixed
mysql-test/t/func_group.test:
  test modified
mysql-test/t/olap.test:
  test modified
mysql-test/t/type_decimal.test:
  test modified
parent a8e4fbcb
...@@ -105,9 +105,9 @@ t1 CREATE TABLE `t1` ( ...@@ -105,9 +105,9 @@ t1 CREATE TABLE `t1` (
`c4` varbinary(1) NOT NULL default '', `c4` varbinary(1) NOT NULL default '',
`c5` varbinary(4) NOT NULL default '', `c5` varbinary(4) NOT NULL default '',
`c6` varbinary(4) NOT NULL default '', `c6` varbinary(4) NOT NULL default '',
`c7` decimal(5,1) NOT NULL default '0.0', `c7` decimal(2,1) NOT NULL default '0.0',
`c8` decimal(5,1) NOT NULL default '0.0', `c8` decimal(2,1) NOT NULL default '0.0',
`c9` decimal(5,1) default NULL, `c9` decimal(2,1) default NULL,
`c10` double NOT NULL default '0', `c10` double NOT NULL default '0',
`c11` double NOT NULL default '0', `c11` double NOT NULL default '0',
`c12` varbinary(5) NOT NULL default '' `c12` varbinary(5) NOT NULL default ''
...@@ -152,9 +152,9 @@ SHOW CREATE TABLE t1; ...@@ -152,9 +152,9 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`COALESCE(1)` int(1) NOT NULL default '0', `COALESCE(1)` int(1) NOT NULL default '0',
`COALESCE(1.0)` decimal(5,1) NOT NULL default '0.0', `COALESCE(1.0)` decimal(2,1) NOT NULL default '0.0',
`COALESCE('a')` varchar(1) NOT NULL default '', `COALESCE('a')` varchar(1) NOT NULL default '',
`COALESCE(1,1.0)` decimal(5,1) NOT NULL default '0.0', `COALESCE(1,1.0)` decimal(2,1) NOT NULL default '0.0',
`COALESCE(1,'1')` varbinary(1) NOT NULL default '', `COALESCE(1,'1')` varbinary(1) NOT NULL default '',
`COALESCE(1.1,'1')` varbinary(4) NOT NULL default '', `COALESCE(1.1,'1')` varbinary(4) NOT NULL default '',
`COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate latin1_bin NOT NULL default '' `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate latin1_bin NOT NULL default ''
......
...@@ -115,9 +115,9 @@ Field Type Null Key Default Extra ...@@ -115,9 +115,9 @@ Field Type Null Key Default Extra
a datetime NO 0000-00-00 00:00:00 a datetime NO 0000-00-00 00:00:00
b time NO 00:00:00 b time NO 00:00:00
c date NO 0000-00-00 c date NO 0000-00-00
d int(2) NO 0 d int(3) NO 0
e decimal(6,1) NO 0.0 e decimal(3,1) NO 0.0
f bigint(18) NO 0 f bigint(19) NO 0
drop table t2; drop table t2;
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt; create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt;
describe t2; describe t2;
...@@ -453,7 +453,7 @@ t2 CREATE TABLE `t2` ( ...@@ -453,7 +453,7 @@ t2 CREATE TABLE `t2` (
`ifnull(e,e)` bigint(20) default NULL, `ifnull(e,e)` bigint(20) default NULL,
`ifnull(f,f)` float(3,2) default NULL, `ifnull(f,f)` float(3,2) default NULL,
`ifnull(g,g)` double(4,3) default NULL, `ifnull(g,g)` double(4,3) default NULL,
`ifnull(h,h)` decimal(6,4) default NULL, `ifnull(h,h)` decimal(5,4) default NULL,
`ifnull(i,i)` year(4) default NULL, `ifnull(i,i)` year(4) default NULL,
`ifnull(j,j)` date default NULL, `ifnull(j,j)` date default NULL,
`ifnull(k,k)` datetime NOT NULL default '0000-00-00 00:00:00', `ifnull(k,k)` datetime NOT NULL default '0000-00-00 00:00:00',
......
...@@ -462,5 +462,5 @@ rout int(11) default '0' ...@@ -462,5 +462,5 @@ rout int(11) default '0'
INSERT INTO t1 VALUES ('1',1,0); INSERT INTO t1 VALUES ('1',1,0);
SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
html prod html prod
1 0.00000 1 0.0000
drop table t1; drop table t1;
drop table if exists t1,t2; drop table if exists t1,t2;
set @sav_dpi= @@div_precision_increment;
set div_precision_increment= 5;
show variables like 'div_precision_increment';
Variable_name Value
div_precision_increment 5
create table t1 (grp int, a bigint unsigned, c char(10) not null); create table t1 (grp int, a bigint unsigned, c char(10) not null);
insert into t1 values (1,1,"a"); insert into t1 values (1,1,"a");
insert into t1 values (2,2,"b"); insert into t1 values (2,2,"b");
...@@ -44,13 +49,13 @@ count(distinct a) count(distinct grp) ...@@ -44,13 +49,13 @@ count(distinct a) count(distinct grp)
6 3 6 3
select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1; select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c) sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c)
21 6 3.5000 1.7078 2.9167 7 0 1 6 E 21 6 3.50000 1.70783 2.91667 7 0 1 6 E
select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c) grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
NULL NULL 0 NULL NULL NULL 0 18446744073709551615 NULL NULL NULL NULL 0 NULL NULL NULL 0 18446744073709551615 NULL NULL
1 1 1 1.0000 0.0000 0.0000 1 1 1 1 a a 1 1 1 1.00000 0.00000 0.00000 1 1 1 1 a a
2 5 2 2.5000 0.5000 0.2500 3 2 2 3 b c 2 5 2 2.50000 0.50000 0.25000 3 2 2 3 b c
3 15 3 5.0000 0.8165 0.6667 7 4 4 6 C E 3 15 3 5.00000 0.81650 0.66667 7 4 4 6 C E
select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp; select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
grp sum grp sum
NULL NULL NULL NULL
...@@ -74,12 +79,12 @@ CREATE TABLE t2 (id int(11),name char(20)); ...@@ -74,12 +79,12 @@ CREATE TABLE t2 (id int(11),name char(20));
INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two'); INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two');
select id, avg(value1), std(value1), variance(value1) from t1 group by id; select id, avg(value1), std(value1), variance(value1) from t1 group by id;
id avg(value1) std(value1) variance(value1) id avg(value1) std(value1) variance(value1)
1 1.000000 0.816497 0.666667 1 1.0000000 0.816497 0.666667
2 11.000000 0.816497 0.666667 2 11.0000000 0.816497 0.666667
select name, avg(value1), std(value1), variance(value1) from t1, t2 where t1.id = t2.id group by t1.id; select name, avg(value1), std(value1), variance(value1) from t1, t2 where t1.id = t2.id group by t1.id;
name avg(value1) std(value1) variance(value1) name avg(value1) std(value1) variance(value1)
Set One 1.000000 0.816497 0.666667 Set One 1.0000000 0.816497 0.666667
Set Two 11.000000 0.816497 0.666667 Set Two 11.0000000 0.816497 0.666667
drop table t1,t2; drop table t1,t2;
create table t1 (id int not null); create table t1 (id int not null);
create table t2 (id int not null,rating int null); create table t2 (id int not null,rating int null);
...@@ -87,19 +92,19 @@ insert into t1 values(1),(2),(3); ...@@ -87,19 +92,19 @@ insert into t1 values(1),(2),(3);
insert into t2 values(1, 3),(2, NULL),(2, NULL),(3, 2),(3, NULL); insert into t2 values(1, 3),(2, NULL),(2, NULL),(3, 2),(3, NULL);
select t1.id, avg(rating) from t1 left join t2 on ( t1.id = t2.id ) group by t1.id; select t1.id, avg(rating) from t1 left join t2 on ( t1.id = t2.id ) group by t1.id;
id avg(rating) id avg(rating)
1 3.0000 1 3.00000
2 NULL 2 NULL
3 2.0000 3 2.00000
select sql_small_result t2.id, avg(rating) from t2 group by t2.id; select sql_small_result t2.id, avg(rating) from t2 group by t2.id;
id avg(rating) id avg(rating)
1 3.0000 1 3.00000
2 NULL 2 NULL
3 2.0000 3 2.00000
select sql_big_result t2.id, avg(rating) from t2 group by t2.id; select sql_big_result t2.id, avg(rating) from t2 group by t2.id;
id avg(rating) id avg(rating)
1 3.0000 1 3.00000
2 NULL 2 NULL
3 2.0000 3 2.00000
select sql_small_result t2.id, avg(rating+0.0e0) from t2 group by t2.id; select sql_small_result t2.id, avg(rating+0.0e0) from t2 group by t2.id;
id avg(rating+0.0e0) id avg(rating+0.0e0)
1 3 1 3
...@@ -265,22 +270,22 @@ insert into t1 values (2,1); ...@@ -265,22 +270,22 @@ insert into t1 values (2,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 1 2 1 1 1.00000 0.00000 1 1 1 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 1 2 1 1 1.00000 0.00000 1 1 1 1
insert into t1 values (3,1); insert into t1 values (3,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 1 2 1 1 1.00000 0.00000 1 1 1 1
3 1 1 1.0000 0.0000 1 1 1 1 3 1 1 1.00000 0.00000 1 1 1 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a; select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) bit_xor(b) a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) bit_xor(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 0 1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 0
2 1 1 1.0000 0.0000 1 1 1 1 1 2 1 1 1.00000 0.00000 1 1 1 1 1
3 1 1 1.0000 0.0000 1 1 1 1 1 3 1 1 1.00000 0.00000 1 1 1 1 1
explain extended select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a; explain extended select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
...@@ -837,10 +842,10 @@ INSERT INTO t1 VALUES (-5.00000000001),(-5.00000000002),(-5.00000000003),(-5.000 ...@@ -837,10 +842,10 @@ INSERT INTO t1 VALUES (-5.00000000001),(-5.00000000002),(-5.00000000003),(-5.000
insert into t1 select * from t1; insert into t1 select * from t1;
select col1,count(col1),sum(col1),avg(col1) from t1 group by col1; select col1,count(col1),sum(col1),avg(col1) from t1 group by col1;
col1 count(col1) sum(col1) avg(col1) col1 count(col1) sum(col1) avg(col1)
-5.000000000030 2 -10.000000000060 -5.0000000000300000 -5.000000000030 2 -10.000000000060 -5.00000000003000000
-5.000000000020 4 -20.000000000080 -5.0000000000200000 -5.000000000020 4 -20.000000000080 -5.00000000002000000
-5.000000000010 4 -20.000000000040 -5.0000000000100000 -5.000000000010 4 -20.000000000040 -5.00000000001000000
-5.000000000000 2 -10.000000000000 -5.0000000000000000 -5.000000000000 2 -10.000000000000 -5.00000000000000000
DROP TABLE t1; DROP TABLE t1;
create table t1 (col1 decimal(16,12)); create table t1 (col1 decimal(16,12));
insert into t1 values (-5.00000000001); insert into t1 values (-5.00000000001);
...@@ -947,3 +952,4 @@ SUM(a) ...@@ -947,3 +952,4 @@ SUM(a)
6 6
6 6
DROP TABLE t1; DROP TABLE t1;
set div_precision_increment= @sav_dpi;
select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2; select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
1+1 1-1 1+1*2 8/5 8%5 mod(8,5) mod(8,5)|0 -(1+1)*-2 1+1 1-1 1+1*2 8/5 8%5 mod(8,5) mod(8,5)|0 -(1+1)*-2
2 0 3 1.60000 3 3 3 4 2 0 3 1.6000 3 3 3 4
explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2; explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
......
...@@ -440,12 +440,12 @@ create table t2 (user_id integer not null, date date); ...@@ -440,12 +440,12 @@ create table t2 (user_id integer not null, date date);
insert into t2 values (1, '2002-06-09'),(2, '2002-06-09'),(1, '2002-06-09'),(3, '2002-06-09'),(4, '2002-06-09'),(4, '2002-06-09'); insert into t2 values (1, '2002-06-09'),(2, '2002-06-09'),(1, '2002-06-09'),(3, '2002-06-09'),(4, '2002-06-09'),(4, '2002-06-09');
select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender; select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender;
gender dist_count percentage gender dist_count percentage
F 3 60.00000 F 3 60.0000
M 1 20.00000 M 1 20.0000
select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender order by percentage; select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender order by percentage;
gender dist_count percentage gender dist_count percentage
M 1 20.00000 M 1 20.0000
F 3 60.00000 F 3 60.0000
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 (ID1 int, ID2 int, ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID CREATE TABLE t1 (ID1 int, ID2 int, ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID
)); ));
......
...@@ -2,7 +2,7 @@ drop table if exists t1,t2; ...@@ -2,7 +2,7 @@ drop table if exists t1,t2;
select 1, 1.0, -1, "hello", NULL; select 1, 1.0, -1, "hello", NULL;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def 1 8 1 1 N 32897 0 63 def 1 8 1 1 N 32897 0 63
def 1.0 246 4 3 N 161 1 63 def 1.0 246 4 3 N 129 1 63
def -1 8 2 2 N 32897 0 63 def -1 8 2 2 N 32897 0 63
def hello 253 5 5 N 1 31 8 def hello 253 5 5 N 1 31 8
def NULL 6 0 0 Y 32896 0 63 def NULL 6 0 0 Y 32896 0 63
...@@ -18,7 +18,7 @@ def test t1 t1 d d 3 11 0 Y 32768 0 63 ...@@ -18,7 +18,7 @@ def test t1 t1 d d 3 11 0 Y 32768 0 63
def test t1 t1 e e 8 20 0 Y 32768 0 63 def test t1 t1 e e 8 20 0 Y 32768 0 63
def test t1 t1 f f 4 3 0 Y 32768 2 63 def test t1 t1 f f 4 3 0 Y 32768 2 63
def test t1 t1 g g 5 4 0 Y 32768 3 63 def test t1 t1 g g 5 4 0 Y 32768 3 63
def test t1 t1 h h 246 5 0 Y 0 4 63 def test t1 t1 h h 246 7 0 Y 0 4 63
def test t1 t1 i i 13 4 0 Y 32864 0 63 def test t1 t1 i i 13 4 0 Y 32864 0 63
def test t1 t1 j j 10 10 0 Y 128 0 63 def test t1 t1 j j 10 10 0 Y 128 0 63
def test t1 t1 k k 7 19 0 N 1249 0 63 def test t1 t1 k k 7 19 0 N 1249 0 63
......
drop table if exists t1,t2; drop table if exists t1,t2;
set @sav_dpi= @@div_precision_increment;
set div_precision_increment= 5;
show variables like 'div_precision_increment';
Variable_name Value
div_precision_increment 5
create table t1 (product varchar(32), country_id int not null, year int, profit int); create table t1 (product varchar(32), country_id int not null, year int, profit int);
insert into t1 values ( 'Computer', 2,2000, 1200), insert into t1 values ( 'Computer', 2,2000, 1200),
( 'TV', 1, 1999, 150), ( 'TV', 1, 1999, 150),
...@@ -40,11 +45,11 @@ TV 600 ...@@ -40,11 +45,11 @@ TV 600
NULL 7785 NULL 7785
select product, sum(profit),avg(profit) from t1 group by product with rollup; select product, sum(profit),avg(profit) from t1 group by product with rollup;
product sum(profit) avg(profit) product sum(profit) avg(profit)
Calculator 275 68.7500 Calculator 275 68.75000
Computer 6900 1380.0000 Computer 6900 1380.00000
Phone 10 10.0000 Phone 10 10.00000
TV 600 120.0000 TV 600 120.00000
NULL 7785 519.0000 NULL 7785 519.00000
select product, country_id , year, sum(profit) from t1 group by product, country_id, year; select product, country_id , year, sum(profit) from t1 group by product, country_id, year;
product country_id year sum(profit) product country_id year sum(profit)
Calculator 1 1999 50 Calculator 1 1999 50
...@@ -244,11 +249,11 @@ select product, country_id , year, sum(profit) from t1 group by product, country ...@@ -244,11 +249,11 @@ select product, country_id , year, sum(profit) from t1 group by product, country
product country_id year sum(profit) product country_id year sum(profit)
select concat(':',product,':'), sum(profit),avg(profit) from t1 group by product with rollup; select concat(':',product,':'), sum(profit),avg(profit) from t1 group by product with rollup;
concat(':',product,':') sum(profit) avg(profit) concat(':',product,':') sum(profit) avg(profit)
:Calculator: 275 68.7500 :Calculator: 275 68.75000
:Computer: 6900 1380.0000 :Computer: 6900 1380.00000
:Phone: 10 10.0000 :Phone: 10 10.00000
:TV: 600 120.0000 :TV: 600 120.00000
:TV: 7785 519.0000 :TV: 7785 519.00000
select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube; select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
ERROR 42000: This version of MySQL doesn't yet support 'CUBE' ERROR 42000: This version of MySQL doesn't yet support 'CUBE'
explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube; explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
...@@ -450,3 +455,4 @@ a m ...@@ -450,3 +455,4 @@ a m
2 2 2 2
NULL 3 NULL 3
DROP TABLE t1; DROP TABLE t1;
set div_precision_increment= @sav_dpi;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -1672,7 +1672,7 @@ fld1 count(*) ...@@ -1672,7 +1672,7 @@ fld1 count(*)
158402 4181 158402 4181
select sum(Period)/count(*) from t1; select sum(Period)/count(*) from t1;
sum(Period)/count(*) sum(Period)/count(*)
9410.00000 9410.0000
select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
companynr count sum diff func companynr count sum diff func
37 12543 309394878010 0.0000 464091 37 12543 309394878010 0.0000 464091
...@@ -1684,7 +1684,7 @@ companynr count sum diff func ...@@ -1684,7 +1684,7 @@ companynr count sum diff func
512 4181 3288532102 0.0000 2140672 512 4181 3288532102 0.0000 2140672
select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg;
companynr avg companynr avg
154 983543950.00 154 983543950.0000
select companynr,count(*) from t2 group by companynr order by 2 desc; select companynr,count(*) from t2 group by companynr order by 2 desc;
companynr count(*) companynr count(*)
37 588 37 588
......
...@@ -2913,10 +2913,10 @@ select @sptmp| ...@@ -2913,10 +2913,10 @@ select @sptmp|
10 10
call bug9674_2()| call bug9674_2()|
v/10 v/10
10.00000 10.0000
call bug9674_2()| call bug9674_2()|
v/10 v/10
10.00000 10.0000
drop procedure bug9674_1| drop procedure bug9674_1|
drop procedure bug9674_2| drop procedure bug9674_2|
drop procedure if exists bug9598_1| drop procedure if exists bug9598_1|
......
...@@ -731,7 +731,7 @@ t1 CREATE TABLE `t1` ( ...@@ -731,7 +731,7 @@ t1 CREATE TABLE `t1` (
`d` decimal(10,0) default NULL `d` decimal(10,0) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 (d decimal(65,0)); create table t1 (d decimal(66,0));
ERROR 42000: Incorrect column specifier for column 'd' ERROR 42000: Incorrect column specifier for column 'd'
CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2)); CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00), INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
......
...@@ -52,13 +52,13 @@ if(1, 1.1, 1.2) if(0, 1.1, 1.2) if(0.1, 1.1, 1.2) if(0, 1, 1.1) if(0, NULL, 1.2) ...@@ -52,13 +52,13 @@ if(1, 1.1, 1.2) if(0, 1.1, 1.2) if(0.1, 1.1, 1.2) if(0, 1, 1.1) if(0, NULL, 1.2)
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`if(1, 1.1, 1.2)` decimal(5,1) NOT NULL default '0.0', `if(1, 1.1, 1.2)` decimal(2,1) NOT NULL default '0.0',
`if(0, 1.1, 1.2)` decimal(5,1) NOT NULL default '0.0', `if(0, 1.1, 1.2)` decimal(2,1) NOT NULL default '0.0',
`if(0.1, 1.1, 1.2)` decimal(5,1) NOT NULL default '0.0', `if(0.1, 1.1, 1.2)` decimal(2,1) NOT NULL default '0.0',
`if(0, 1, 1.1)` decimal(5,1) NOT NULL default '0.0', `if(0, 1, 1.1)` decimal(2,1) NOT NULL default '0.0',
`if(0, NULL, 1.2)` decimal(5,1) default NULL, `if(0, NULL, 1.2)` decimal(2,1) default NULL,
`if(1, 0.22e1, 1.1)` double NOT NULL default '0', `if(1, 0.22e1, 1.1)` double NOT NULL default '0',
`if(1E0, 1.1, 1.2)` decimal(5,1) NOT NULL default '0.0' `if(1E0, 1.1, 1.2)` decimal(2,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 select nullif(1.1, 1.1), nullif(1.1, 1.2), nullif(1.1, 0.11e1), nullif(1.0, 1), nullif(1, 1.0), nullif(1, 1.1); create table t1 select nullif(1.1, 1.1), nullif(1.1, 1.2), nullif(1.1, 0.11e1), nullif(1.0, 1), nullif(1, 1.0), nullif(1, 1.1);
...@@ -68,12 +68,12 @@ NULL 1.1 NULL NULL NULL 1 ...@@ -68,12 +68,12 @@ NULL 1.1 NULL NULL NULL 1
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`nullif(1.1, 1.1)` decimal(5,1) default NULL, `nullif(1.1, 1.1)` decimal(2,1) default NULL,
`nullif(1.1, 1.2)` decimal(5,1) default NULL, `nullif(1.1, 1.2)` decimal(2,1) default NULL,
`nullif(1.1, 0.11e1)` double(4,1) default NULL, `nullif(1.1, 0.11e1)` decimal(2,1) default NULL,
`nullif(1.0, 1)` decimal(5,1) default NULL, `nullif(1.0, 1)` decimal(2,1) default NULL,
`nullif(1, 1.0)` decimal(1,0) default NULL, `nullif(1, 1.0)` int(1) default NULL,
`nullif(1, 1.1)` decimal(1,0) default NULL `nullif(1, 1.1)` int(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t1 (a decimal(4,2)); create table t1 (a decimal(4,2));
...@@ -174,10 +174,10 @@ create table t1 select round(15.4,-1), truncate(-5678.123451,-3), abs(-1.1), -(- ...@@ -174,10 +174,10 @@ create table t1 select round(15.4,-1), truncate(-5678.123451,-3), abs(-1.1), -(-
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`round(15.4,-1)` decimal(5,0) NOT NULL default '0', `round(15.4,-1)` decimal(3,0) NOT NULL default '0',
`truncate(-5678.123451,-3)` decimal(13,0) NOT NULL default '0', `truncate(-5678.123451,-3)` decimal(4,0) NOT NULL default '0',
`abs(-1.1)` decimal(6,1) NOT NULL default '0.0', `abs(-1.1)` decimal(3,1) NOT NULL default '0.0',
`-(-1.1)` decimal(7,1) NOT NULL default '0.0' `-(-1.1)` decimal(2,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
set session sql_mode='traditional'; set session sql_mode='traditional';
...@@ -375,7 +375,7 @@ col1 ...@@ -375,7 +375,7 @@ col1
drop table wl1612; drop table wl1612;
select 1/3; select 1/3;
1/3 1/3
0.33333 0.3333
select 0.8=0.7+0.1; select 0.8=0.7+0.1;
0.8=0.7+0.1 0.8=0.7+0.1
1 1
...@@ -398,7 +398,7 @@ select 0.07*0.07 from wl1612_1; ...@@ -398,7 +398,7 @@ select 0.07*0.07 from wl1612_1;
0.0049 0.0049
select 0.07/0.07 from wl1612_1; select 0.07/0.07 from wl1612_1;
0.07/0.07 0.07/0.07
1.000000000 1.000000
drop table wl1612_1; drop table wl1612_1;
create table wl1612_2 (col1 decimal(10,2), col2 numeric(10,2)); create table wl1612_2 (col1 decimal(10,2), col2 numeric(10,2));
insert into wl1612_2 values(1,1); insert into wl1612_2 values(1,1);
...@@ -626,16 +626,16 @@ create table wl1612_4 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); ...@@ -626,16 +626,16 @@ create table wl1612_4 (col1 int, col2 decimal(30,25), col3 numeric(30,25));
insert into wl1612_4 values(1,0.0123456789012345678912345,0.0123456789012345678912345); insert into wl1612_4 values(1,0.0123456789012345678912345,0.0123456789012345678912345);
select col2/9999999999 from wl1612_4 where col1=1; select col2/9999999999 from wl1612_4 where col1=1;
col2/9999999999 col2/9999999999
0.0000000000012345678902469135781481410000000000000000000 0.00000000000123456789024691358
select col3/9999999999 from wl1612_4 where col1=1; select col3/9999999999 from wl1612_4 where col1=1;
col3/9999999999 col3/9999999999
0.0000000000012345678902469135781481410000000000000000000 0.00000000000123456789024691358
select 9999999999/col2 from wl1612_4 where col1=1; select 9999999999/col2 from wl1612_4 where col1=1;
9999999999/col2 9999999999/col2
810000007209.00007 810000007209.0001
select 9999999999/col3 from wl1612_4 where col1=1; select 9999999999/col3 from wl1612_4 where col1=1;
9999999999/col3 9999999999/col3
810000007209.00007 810000007209.0001
select col2*9999999999 from wl1612_4 where col1=1; select col2*9999999999 from wl1612_4 where col1=1;
col2*9999999999 col2*9999999999
123456789.0000000000111104321087655 123456789.0000000000111104321087655
...@@ -645,16 +645,16 @@ col3*9999999999 ...@@ -645,16 +645,16 @@ col3*9999999999
insert into wl1612_4 values(2,55555.0123456789012345678912345,55555.0123456789012345678912345); insert into wl1612_4 values(2,55555.0123456789012345678912345,55555.0123456789012345678912345);
select col2/9999999999 from wl1612_4 where col1=2; select col2/9999999999 from wl1612_4 where col1=2;
col2/9999999999 col2/9999999999
0.0000055555012351234402469691331481460000000000000000000 0.00000555550123512344024696913
select col3/9999999999 from wl1612_4 where col1=2; select col3/9999999999 from wl1612_4 where col1=2;
col3/9999999999 col3/9999999999
0.0000055555012351234402469691331481460000000000000000000 0.00000555550123512344024696913
select 9999999999/col2 from wl1612_4 where col1=2; select 9999999999/col2 from wl1612_4 where col1=2;
9999999999/col2 9999999999/col2
180001.76000 180001.7600
select 9999999999/col3 from wl1612_4 where col1=2; select 9999999999/col3 from wl1612_4 where col1=2;
9999999999/col3 9999999999/col3
180001.76000 180001.7600
select col2*9999999999 from wl1612_4 where col1=2; select col2*9999999999 from wl1612_4 where col1=2;
col2*9999999999 col2*9999999999
555550123401234.0000000000111104321087655 555550123401234.0000000000111104321087655
...@@ -712,7 +712,7 @@ select .7777777777777777777777777777777777777 * ...@@ -712,7 +712,7 @@ select .7777777777777777777777777777777777777 *
1000000000000000000; 1000000000000000000;
.7777777777777777777777777777777777777 * .7777777777777777777777777777777777777 *
1000000000000000000 1000000000000000000
777777777777777777.7777777777777777777000000000000000000 777777777777777777.777777777777777777700000000000
select .7777777777777777777777777777777777777 - 0.1; select .7777777777777777777777777777777777777 - 0.1;
.7777777777777777777777777777777777777 - 0.1 .7777777777777777777777777777777777777 - 0.1
0.6777777777777777777777777777777777777 0.6777777777777777777777777777777777777
...@@ -772,10 +772,10 @@ round(-99999999999999999.999,3) ...@@ -772,10 +772,10 @@ round(-99999999999999999.999,3)
-99999999999999999.999 -99999999999999999.999
select truncate(99999999999999999999999999999999999999,31); select truncate(99999999999999999999999999999999999999,31);
truncate(99999999999999999999999999999999999999,31) truncate(99999999999999999999999999999999999999,31)
99999999999999999999999999999999999999.000000000000000000000000000 99999999999999999999999999999999999999.000000000000000000000000000000
select truncate(99.999999999999999999999999999999999999,31); select truncate(99.999999999999999999999999999999999999,31);
truncate(99.999999999999999999999999999999999999,31) truncate(99.999999999999999999999999999999999999,31)
99.9999999999999999999999999999999 100.000000000000000000000000000000
select truncate(99999999999999999999999999999999999999,-31); select truncate(99999999999999999999999999999999999999,-31);
truncate(99999999999999999999999999999999999999,-31) truncate(99999999999999999999999999999999999999,-31)
99999990000000000000000000000000000000 99999990000000000000000000000000000000
...@@ -783,7 +783,7 @@ create table t1 as select 0.5; ...@@ -783,7 +783,7 @@ create table t1 as select 0.5;
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`0.5` decimal(3,1) NOT NULL default '0.0' `0.5` decimal(2,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
select round(1.5),round(2.5); select round(1.5),round(2.5);
...@@ -841,4 +841,4 @@ ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1 ...@@ -841,4 +841,4 @@ ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1
drop table Sow6_2f; drop table Sow6_2f;
select 10.3330000000000/12.34500000; select 10.3330000000000/12.34500000;
10.3330000000000/12.34500000 10.3330000000000/12.34500000
0.8370190360469825840421223160000 0.83701903604698258
...@@ -565,7 +565,7 @@ a ...@@ -565,7 +565,7 @@ a
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` decimal(19,1) NOT NULL default '0.0' `a` decimal(3,1) NOT NULL default '0.0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text); create table t2 (it1 tinyint, it2 tinyint not null, i int not null, ib bigint, f float, d double, y year, da date, dt datetime, sc char(10), sv varchar(10), b blob, tx text);
...@@ -792,7 +792,7 @@ d ...@@ -792,7 +792,7 @@ d
show create table t3; show create table t3;
Table Create Table Table Create Table
t3 CREATE TABLE `t3` ( t3 CREATE TABLE `t3` (
`d` decimal(19,9) default NULL `d` decimal(18,9) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1,t2,t3; drop table t1,t2,t3;
create table t1 select 1 union select -1; create table t1 select 1 union select -1;
......
...@@ -504,7 +504,7 @@ show create table t1; ...@@ -504,7 +504,7 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`c1` bigint(20) default NULL, `c1` bigint(20) default NULL,
`c2` decimal(64,30) default NULL, `c2` decimal(65,30) default NULL,
`c3` longtext, `c3` longtext,
`c4` double default NULL `c4` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
drop table if exists t1,t2; drop table if exists t1,t2;
--enable_warnings --enable_warnings
set @sav_dpi= @@div_precision_increment;
set div_precision_increment= 5;
show variables like 'div_precision_increment';
create table t1 (grp int, a bigint unsigned, c char(10) not null); create table t1 (grp int, a bigint unsigned, c char(10) not null);
insert into t1 values (1,1,"a"); insert into t1 values (1,1,"a");
insert into t1 values (2,2,"b"); insert into t1 values (2,2,"b");
...@@ -623,4 +626,5 @@ SELECT b/c as v, SUM(a) FROM t1 GROUP BY v; ...@@ -623,4 +626,5 @@ SELECT b/c as v, SUM(a) FROM t1 GROUP BY v;
SELECT SUM(a) FROM t1 GROUP BY b/c; SELECT SUM(a) FROM t1 GROUP BY b/c;
DROP TABLE t1; DROP TABLE t1;
set div_precision_increment= @sav_dpi;
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
drop table if exists t1,t2; drop table if exists t1,t2;
--enable_warnings --enable_warnings
set @sav_dpi= @@div_precision_increment;
set div_precision_increment= 5;
show variables like 'div_precision_increment';
create table t1 (product varchar(32), country_id int not null, year int, profit int); create table t1 (product varchar(32), country_id int not null, year int, profit int);
insert into t1 values ( 'Computer', 2,2000, 1200), insert into t1 values ( 'Computer', 2,2000, 1200),
( 'TV', 1, 1999, 150), ( 'TV', 1, 1999, 150),
...@@ -191,3 +195,4 @@ SELECT a, SUM(a) m FROM t1 GROUP BY a WITH ROLLUP; ...@@ -191,3 +195,4 @@ SELECT a, SUM(a) m FROM t1 GROUP BY a WITH ROLLUP;
SELECT * FROM ( SELECT a, SUM(a) m FROM t1 GROUP BY a WITH ROLLUP ) t2; SELECT * FROM ( SELECT a, SUM(a) m FROM t1 GROUP BY a WITH ROLLUP ) t2;
DROP TABLE t1; DROP TABLE t1;
set div_precision_increment= @sav_dpi;
...@@ -308,7 +308,7 @@ create table t1 (d decimal); ...@@ -308,7 +308,7 @@ create table t1 (d decimal);
show create table t1; show create table t1;
drop table t1; drop table t1;
--error 1063 --error 1063
create table t1 (d decimal(65,0)); create table t1 (d decimal(66,0));
# #
# Test example from manual # Test example from manual
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment