summaryrefslogtreecommitdiff
path: root/sql/sql_analyse.cc
diff options
context:
space:
mode:
authorunknown <iggy@rolltop.ignatz42.dyndns.org>2006-09-28 14:30:20 -0400
committerunknown <iggy@rolltop.ignatz42.dyndns.org>2006-09-28 14:30:20 -0400
commit314e10592ceac7def3ea4863d5a1f8b23464bf30 (patch)
tree00d8223a8610a3b2bcfad70184770c407e986575 /sql/sql_analyse.cc
parent418ae41b4867e53e770d79f66e6d9ba3f7b8974b (diff)
downloadmariadb-git-314e10592ceac7def3ea4863d5a1f8b23464bf30.tar.gz
Bug#20305: PROCEDURE ANALYSE() returns wrong M for FLOAT(M, D) and DOUBLE(M, D)
mysql-test/r/analyse.result: Added Results mysql-test/t/analyse.test: Added test cases to make sure field_str and field_real return correctly. sql/sql_analyse.cc: According the manaul, when declaring a FLOAT(M, N), N equals the number of decimal places and M equals the total number of digits in the number.
Diffstat (limited to 'sql/sql_analyse.cc')
-rw-r--r--sql/sql_analyse.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index d2237c24139..3420368a026 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -709,9 +709,9 @@ void field_str::get_opt_type(String *answer, ha_rows total_rows)
else if (num_info.decimals) // DOUBLE(%d,%d) sometime
{
if (num_info.dval > -FLT_MAX && num_info.dval < FLT_MAX)
- sprintf(buff, "FLOAT(%d,%d)", num_info.integers, num_info.decimals);
+ sprintf(buff, "FLOAT(%d,%d)", (num_info.integers + num_info.decimals), num_info.decimals);
else
- sprintf(buff, "DOUBLE(%d,%d)", num_info.integers, num_info.decimals);
+ sprintf(buff, "DOUBLE(%d,%d)", (num_info.integers + num_info.decimals), num_info.decimals);
}
else if (ev_num_info.llval >= -128 &&
ev_num_info.ullval <=
@@ -818,10 +818,10 @@ void field_real::get_opt_type(String *answer,
else
{
if (min_arg >= -FLT_MAX && max_arg <= FLT_MAX)
- sprintf(buff, "FLOAT(%d,%d)", (int) max_length - (item->decimals + 1),
+ sprintf(buff, "FLOAT(%d,%d)", (int) max_length - (item->decimals + 1) + max_notzero_dec_len,
max_notzero_dec_len);
else
- sprintf(buff, "DOUBLE(%d,%d)", (int) max_length - (item->decimals + 1),
+ sprintf(buff, "DOUBLE(%d,%d)", (int) max_length - (item->decimals + 1) + max_notzero_dec_len,
max_notzero_dec_len);
answer->append(buff, (uint) strlen(buff));
}