1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

String::set(double) and set(longlong) -> set_real() and set_int()

fix Field::store(double) being used instead of store(longlong)

NB: overloading functions is evil
This commit is contained in:
serg@serg.mylan
2006-06-16 12:17:20 +02:00
parent 0845bc4936
commit d00b56549c
16 changed files with 83 additions and 83 deletions

View File

@ -128,9 +128,9 @@ public:
String *avg(String *s, ha_rows rows)
{
if (!(rows - nulls))
s->set((double) 0.0, 1,my_thd_charset);
s->set_real((double) 0.0, 1,my_thd_charset);
else
s->set((ulonglong2double(sum) / ulonglong2double(rows - nulls)),
s->set_real((ulonglong2double(sum) / ulonglong2double(rows - nulls)),
DEC_IN_AVG,my_thd_charset);
return s;
}
@ -190,34 +190,34 @@ public:
void add();
void get_opt_type(String*, ha_rows);
String *get_min_arg(String *s)
{
s->set(min_arg, item->decimals,my_thd_charset);
return s;
String *get_min_arg(String *s)
{
s->set_real(min_arg, item->decimals, my_thd_charset);
return s;
}
String *get_max_arg(String *s)
{
s->set(max_arg, item->decimals,my_thd_charset);
return s;
String *get_max_arg(String *s)
{
s->set_real(max_arg, item->decimals, my_thd_charset);
return s;
}
String *avg(String *s, ha_rows rows)
{
if (!(rows - nulls))
s->set((double) 0.0, 1,my_thd_charset);
s->set_real((double) 0.0, 1,my_thd_charset);
else
s->set(((double)sum / (double) (rows - nulls)), item->decimals,my_thd_charset);
s->set_real(((double)sum / (double) (rows - nulls)), item->decimals,my_thd_charset);
return s;
}
String *std(String *s, ha_rows rows)
{
double tmp = ulonglong2double(rows);
if (!(tmp - nulls))
s->set((double) 0.0, 1,my_thd_charset);
s->set_real((double) 0.0, 1,my_thd_charset);
else
{
double tmp2 = ((sum_sqr - sum * sum / (tmp - nulls)) /
(tmp - nulls));
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), item->decimals,my_thd_charset);
s->set_real(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), item->decimals,my_thd_charset);
}
return s;
}
@ -249,21 +249,21 @@ public:
String *avg(String *s, ha_rows rows)
{
if (!(rows - nulls))
s->set((double) 0.0, 1,my_thd_charset);
s->set_real((double) 0.0, 1,my_thd_charset);
else
s->set(((double) sum / (double) (rows - nulls)), DEC_IN_AVG,my_thd_charset);
s->set_real(((double) sum / (double) (rows - nulls)), DEC_IN_AVG,my_thd_charset);
return s;
}
String *std(String *s, ha_rows rows)
{
double tmp = ulonglong2double(rows);
if (!(tmp - nulls))
s->set((double) 0.0, 1,my_thd_charset);
s->set_real((double) 0.0, 1,my_thd_charset);
else
{
double tmp2 = ((sum_sqr - sum * sum / (tmp - nulls)) /
(tmp - nulls));
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), DEC_IN_AVG,my_thd_charset);
s->set_real(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), DEC_IN_AVG,my_thd_charset);
}
return s;
}
@ -293,9 +293,9 @@ public:
String *avg(String *s, ha_rows rows)
{
if (!(rows - nulls))
s->set((double) 0.0, 1,my_thd_charset);
s->set_real((double) 0.0, 1,my_thd_charset);
else
s->set((ulonglong2double(sum) / ulonglong2double(rows - nulls)),
s->set_real((ulonglong2double(sum) / ulonglong2double(rows - nulls)),
DEC_IN_AVG,my_thd_charset);
return s;
}
@ -303,13 +303,13 @@ public:
{
double tmp = ulonglong2double(rows);
if (!(tmp - nulls))
s->set((double) 0.0, 1,my_thd_charset);
s->set_real((double) 0.0, 1,my_thd_charset);
else
{
double tmp2 = ((ulonglong2double(sum_sqr) -
ulonglong2double(sum * sum) / (tmp - nulls)) /
(tmp - nulls));
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), DEC_IN_AVG,my_thd_charset);
s->set_real(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), DEC_IN_AVG,my_thd_charset);
}
return s;
}