Skip to content

Commit bc790c9

Browse files
Alexey KopytovAlexey Kopytov
Alexey Kopytov
authored and
Alexey Kopytov
committed
Merge into dev tree.
2 parents 7b6ff85 + 30ac490 commit bc790c9

13 files changed

+58
-45
lines changed

client/sql_string.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
125125
str_charset=cs;
126126
if (decimals >= NOT_FIXED_DEC)
127127
{
128-
uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME
128+
uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
129129
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
130130
}
131131
#ifdef HAVE_FCONVERT
@@ -677,7 +677,7 @@ void String::qs_append(const char *str, uint32 len)
677677
void String::qs_append(double d)
678678
{
679679
char *buff = Ptr + str_length;
680-
str_length+= my_sprintf(buff, (buff, "%.14g", d));
680+
str_length+= my_sprintf(buff, (buff, "%.15g", d));
681681
}
682682

683683
void String::qs_append(double *d)

libmysql/libmysql.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3833,13 +3833,13 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
38333833
#undef NOT_FIXED_DEC
38343834
{
38353835
/*
3836-
The 14 below is to ensure that the server and client has the same
3836+
DBL_DIG below is to ensure that the server and client has the same
38373837
precisions. This will ensure that on the same machine you get the
38383838
same value as a string independent of the protocol you use.
38393839
*/
38403840
sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
38413841
param->buffer_length),
3842-
min(14,width), value);
3842+
min(DBL_DIG, width), value);
38433843
end= strcend(buff, ' ');
38443844
*end= 0;
38453845
}

mysql-test/r/archive_gis.result

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
292292
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
293293
fid AsText(Centroid(g))
294294
108 POINT(15 15)
295-
109 POINT(25.416666666667 25.416666666667)
295+
109 POINT(25.4166666666667 25.4166666666667)
296296
110 POINT(20 10)
297297
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
298298
fid Area(g)
@@ -326,8 +326,8 @@ fid IsClosed(g)
326326
116 0
327327
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
328328
fid AsText(Centroid(g))
329-
117 POINT(55.588527753042 17.426536064114)
330-
118 POINT(55.588527753042 17.426536064114)
329+
117 POINT(55.5885277530424 17.426536064114)
330+
118 POINT(55.5885277530424 17.426536064114)
331331
119 POINT(2 2)
332332
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
333333
fid Area(g)

mysql-test/r/func_group.result

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ grp sum
6161
NULL NULL
6262
1 7
6363
2 20.25
64-
3 45.483163247594
64+
3 45.4831632475944
6565
create table t2 (grp int, a bigint unsigned, c char(10));
6666
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
6767
replace into t2 select grp, a, c from t1 limit 2,1;
@@ -1186,7 +1186,7 @@ std(s1/s2)
11861186
0.21325764
11871187
select std(o1/o2) from bug22555;
11881188
std(o1/o2)
1189-
0.21325763586649
1189+
0.213257635866493
11901190
select std(e1/e2) from bug22555;
11911191
std(e1/e2)
11921192
0.21325764
@@ -1212,7 +1212,7 @@ round(std(s1/s2), 17)
12121212
0.21325763586649341
12131213
select std(o1/o2) from bug22555;
12141214
std(o1/o2)
1215-
0.21325763586649
1215+
0.213257635866493
12161216
select round(std(e1/e2), 17) from bug22555;
12171217
round(std(e1/e2), 17)
12181218
0.21325763586649341
@@ -1237,7 +1237,7 @@ round(std(s1/s2), 17)
12371237
0.21325763586649341
12381238
select std(o1/o2) from bug22555;
12391239
std(o1/o2)
1240-
0.21325763586649
1240+
0.213257635866493
12411241
select round(std(e1/e2), 17) from bug22555;
12421242
round(std(e1/e2), 17)
12431243
0.21325763586649341

mysql-test/r/func_math.result

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ Warnings:
6060
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
6161
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
6262
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
63-
3 3.9068905956085 NULL NULL NULL
63+
3 3.90689059560852 NULL NULL NULL
6464
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
6565
id select_type table type possible_keys key key_len ref rows filtered Extra
6666
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
6767
Warnings:
6868
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
6969
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
7070
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
71-
2 1.2552725051033 NULL NULL NULL
71+
2 1.25527250510331 NULL NULL NULL
7272
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
7373
id select_type table type possible_keys key key_len ref rows filtered Extra
7474
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -85,7 +85,7 @@ Note 1003 select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4
8585
set @@rand_seed1=10000000,@@rand_seed2=1000000;
8686
select rand(999999),rand();
8787
rand(999999) rand()
88-
0.014231365187309 0.028870999839968
88+
0.0142313651873091 0.028870999839968
8989
explain extended select rand(999999),rand();
9090
id select_type table type possible_keys key key_len ref rows filtered Extra
9191
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -101,7 +101,7 @@ Warnings:
101101
Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format((1 / tan(1)),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
102102
select degrees(pi()),radians(360);
103103
degrees(pi()) radians(360)
104-
180 6.2831853071796
104+
180 6.28318530717959
105105
select format(atan(-2, 2), 6);
106106
format(atan(-2, 2), 6)
107107
-0.785398
@@ -368,7 +368,7 @@ mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
368368
5 5 1
369369
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
370370
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
371-
2.1359870359209e+96 2.1359870359209e+96 -32
371+
2.13598703592091e+96 2.13598703592091e+96 -32
372372
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
373373
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
374374
SELECT a DIV 900 y FROM t1 GROUP BY y;

mysql-test/r/func_str.result

+2-2
Original file line numberDiff line numberDiff line change
@@ -1351,10 +1351,10 @@ cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2))
13511351
20.06
13521352
select conv("18383815659218730760",10,10) + 0;
13531353
conv("18383815659218730760",10,10) + 0
1354-
1.8383815659219e+19
1354+
1.83838156592187e+19
13551355
select "18383815659218730760" + 0;
13561356
"18383815659218730760" + 0
1357-
1.8383815659219e+19
1357+
1.83838156592187e+19
13581358
CREATE TABLE t1 (code varchar(10));
13591359
INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
13601360
SELECT ASCII(code), code FROM t1 WHERE code='A12';

mysql-test/r/gis.result

+5-5
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
284284
SELECT fid, AsText(Centroid(g)) FROM gis_polygon;
285285
fid AsText(Centroid(g))
286286
108 POINT(15 15)
287-
109 POINT(25.416666666667 25.416666666667)
287+
109 POINT(25.4166666666667 25.4166666666667)
288288
110 POINT(20 10)
289289
SELECT fid, Area(g) FROM gis_polygon;
290290
fid Area(g)
@@ -318,8 +318,8 @@ fid IsClosed(g)
318318
116 0
319319
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
320320
fid AsText(Centroid(g))
321-
117 POINT(55.588527753042 17.426536064114)
322-
118 POINT(55.588527753042 17.426536064114)
321+
117 POINT(55.5885277530424 17.426536064114)
322+
118 POINT(55.5885277530424 17.426536064114)
323323
119 POINT(2 2)
324324
SELECT fid, Area(g) FROM gis_multi_polygon;
325325
fid Area(g)
@@ -651,11 +651,11 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
651651
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
652652
t1 where object_id=85998;
653653
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
654-
85998 MULTIPOLYGON 0 POINT(115.31877315203 -36.237472821022)
654+
85998 MULTIPOLYGON 0 POINT(115.318773152032 -36.2374728210215)
655655
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
656656
t1 where object_id=85984;
657657
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
658-
85984 MULTIPOLYGON 0 POINT(-114.87787186923 36.33101763469)
658+
85984 MULTIPOLYGON 0 POINT(-114.877871869233 36.3310176346905)
659659
drop table t1;
660660
create table t1 (fl geometry not null);
661661
insert into t1 values (1);

mysql-test/r/innodb_gis.result

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
292292
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
293293
fid AsText(Centroid(g))
294294
108 POINT(15 15)
295-
109 POINT(25.416666666667 25.416666666667)
295+
109 POINT(25.4166666666667 25.4166666666667)
296296
110 POINT(20 10)
297297
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
298298
fid Area(g)
@@ -326,8 +326,8 @@ fid IsClosed(g)
326326
116 0
327327
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
328328
fid AsText(Centroid(g))
329-
117 POINT(55.588527753042 17.426536064114)
330-
118 POINT(55.588527753042 17.426536064114)
329+
117 POINT(55.5885277530424 17.426536064114)
330+
118 POINT(55.5885277530424 17.426536064114)
331331
119 POINT(2 2)
332332
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
333333
fid Area(g)

mysql-test/r/select.result

+7-7
Original file line numberDiff line numberDiff line change
@@ -2784,26 +2784,26 @@ id select_type table type possible_keys key key_len ref rows Extra
27842784
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
27852785
select max(key1) from t1 where key1 <= 0.6158;
27862786
max(key1)
2787-
0.61580002307892
2787+
0.615800023078918
27882788
select max(key2) from t2 where key2 <= 1.6158;
27892789
max(key2)
2790-
1.6158000230789
2790+
1.61580002307892
27912791
select min(key1) from t1 where key1 >= 0.3762;
27922792
min(key1)
2793-
0.37619999051094
2793+
0.376199990510941
27942794
select min(key2) from t2 where key2 >= 1.3762;
27952795
min(key2)
2796-
1.3761999607086
2796+
1.37619996070862
27972797
select max(key1), min(key2) from t1, t2
27982798
where key1 <= 0.6158 and key2 >= 1.3762;
27992799
max(key1) min(key2)
2800-
0.61580002307892 1.3761999607086
2800+
0.615800023078918 1.37619996070862
28012801
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
28022802
max(key1)
2803-
0.61580002307892
2803+
0.615800023078918
28042804
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
28052805
min(key1)
2806-
0.37619999051094
2806+
0.376199990510941
28072807
DROP TABLE t1,t2;
28082808
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
28092809
INSERT INTO t1 VALUES (10);

mysql-test/r/sp.result

+4-4
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ return 2.7182818284590452354|
581581
set @e = e()|
582582
select e(), @e|
583583
e() @e
584-
2.718281828459 2.718281828459
584+
2.71828182845905 2.71828182845905
585585
drop function if exists inc|
586586
create function inc(i int) returns int
587587
return i+1|
@@ -618,7 +618,7 @@ create function fun(d double, i int, u int unsigned) returns double
618618
return mul(inc(i), fac(u)) / e()|
619619
select fun(2.3, 3, 5)|
620620
fun(2.3, 3, 5)
621-
176.58213176229
621+
176.582131762292
622622
insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
623623
insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
624624
select * from t2 where s = append("a", "b")|
@@ -6018,9 +6018,9 @@ CREATE TABLE t3 (f1 INT, f2 FLOAT)|
60186018
INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)|
60196019
SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP|
60206020
SUM(f2) bug25373(f1)
6021-
6.3000000715256 1
6021+
6.30000007152557 1
60226022
15 2
6023-
21.300000071526 NULL
6023+
21.3000000715256 NULL
60246024
DROP FUNCTION bug25373|
60256025
DROP TABLE t3|
60266026
DROP DATABASE IF EXISTS mysqltest1|

mysql-test/r/type_float.result

+11-6
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,12 @@ Warning 1264 Out of range value for column 'f1' at row 1
385385
Warning 1264 Out of range value for column 'f1' at row 2
386386
select f1 + 0e0 from t1;
387387
f1 + 0e0
388-
1.0000000150475e+29
389-
-1.0000000150475e+29
390-
1.0000000150475e+30
391-
-1.0000000150475e+30
392-
1.0000000150475e+30
393-
-1.0000000150475e+30
388+
1.00000001504747e+29
389+
-1.00000001504747e+29
390+
1.00000001504747e+30
391+
-1.00000001504747e+30
392+
1.00000001504747e+30
393+
-1.00000001504747e+30
394394
drop table t1;
395395
create table t1(d double, u bigint unsigned);
396396
insert into t1(d) values (9.22337203685479e18),
@@ -401,4 +401,9 @@ u
401401
9223372036854790144
402402
18400000000000000000
403403
drop table t1;
404+
CREATE TABLE t1 (f1 DOUBLE);
405+
INSERT INTO t1 VALUES(-1.79769313486231e+308);
406+
SELECT f1 FROM t1;
407+
f1
408+
-1.79769313486231e+308
404409
End of 5.0 tests

mysql-test/t/type_float.test

+8
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,12 @@ select u from t1;
267267

268268
drop table t1;
269269

270+
#
271+
# Bug #21205: Different number of digits for float/doble/real in --ps-protocol
272+
#
273+
274+
CREATE TABLE t1 (f1 DOUBLE);
275+
INSERT INTO t1 VALUES(-1.79769313486231e+308);
276+
SELECT f1 FROM t1;
277+
270278
--echo End of 5.0 tests

sql/sql_string.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ bool String::set_real(double num,uint decimals, CHARSET_INFO *cs)
115115
str_charset=cs;
116116
if (decimals >= NOT_FIXED_DEC)
117117
{
118-
uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME
118+
uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
119119
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
120120
}
121121
#ifdef HAVE_FCONVERT
@@ -667,7 +667,7 @@ void String::qs_append(const char *str, uint32 len)
667667
void String::qs_append(double d)
668668
{
669669
char *buff = Ptr + str_length;
670-
str_length+= my_sprintf(buff, (buff, "%.14g", d));
670+
str_length+= my_sprintf(buff, (buff, "%.15g", d));
671671
}
672672

673673
void String::qs_append(double *d)

0 commit comments

Comments
 (0)