diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-02-02 16:58:15 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-02-02 16:58:15 +0300 |
commit | c2fe19883e624ddd0e37768f860fa0853848adb3 (patch) | |
tree | 0aec0b83266060d9cc4c9c65ee047b5fd7a83d96 /client | |
parent | 3147bdd0ac34a5c62158b8c28da6ca77e0901f08 (diff) | |
parent | ece5ad57e9b2505732be4b043440d9e5a5dc3b9a (diff) | |
download | mariadb-git-c2fe19883e624ddd0e37768f860fa0853848adb3.tar.gz |
Merge next-mr -> next-4284.
Fix Bug#50555 "handler commands crash server in my_hash_first()"
as a post-merge fix (the new handler tests are not passing
otherwise).
- in hash.c, don't call calc_hash if ! my_hash_inited().
- add tests and results for the test case for Bug#50555
Diffstat (limited to 'client')
-rw-r--r-- | client/Makefile.am | 2 | ||||
-rw-r--r-- | client/sql_string.cc | 80 |
2 files changed, 8 insertions, 74 deletions
diff --git a/client/Makefile.am b/client/Makefile.am index cfc322c2531..feb71a491e4 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -109,7 +109,7 @@ sql_src=log_event.h mysql_priv.h rpl_constants.h \ log_event_old.h log_event_old.cc \ rpl_record_old.h rpl_record_old.cc \ transaction.h -strings_src=decimal.c +strings_src=decimal.c dtoa.c link_sources: for f in $(sql_src) ; do \ diff --git a/client/sql_string.cc b/client/sql_string.cc index 3292bc7e6f2..ccbc8977e7f 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -24,10 +24,6 @@ #include <m_string.h> #include <m_ctype.h> #include <mysql_com.h> -#ifdef HAVE_FCONVERT -#include <floatingpoint.h> -#endif - /* The following extern declarations are ok as these are interface functions required by the string function @@ -117,82 +113,19 @@ bool String::set(ulonglong num, CHARSET_INFO *cs) bool String::set(double num,uint decimals, CHARSET_INFO *cs) { - char buff[331]; + char buff[FLOATING_POINT_BUFFER]; uint dummy_errors; + size_t len; str_charset=cs; if (decimals >= NOT_FIXED_DEC) { - uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME + len= my_gcvt(num, MY_GCVT_ARG_DOUBLE, sizeof(buff) - 1, buff, NULL); return copy(buff, len, &my_charset_latin1, cs, &dummy_errors); } -#ifdef HAVE_FCONVERT - int decpt,sign; - char *pos,*to; - - (void) fconvert(num,(int) decimals,&decpt,&sign,buff+1); - if (!my_isdigit(&my_charset_latin1, buff[1])) - { // Nan or Inf - pos=buff+1; - if (sign) - { - buff[0]='-'; - pos=buff; - } - uint dummy_errors; - return copy(pos,(uint32) strlen(pos), &my_charset_latin1, cs, &dummy_errors); - } - if (alloc((uint32) ((uint32) decpt+3+decimals))) - return TRUE; - to=Ptr; - if (sign) - *to++='-'; - - pos=buff+1; - if (decpt < 0) - { /* value is < 0 */ - *to++='0'; - if (!decimals) - goto end; - *to++='.'; - if ((uint32) -decpt > decimals) - decpt= - (int) decimals; - decimals=(uint32) ((int) decimals+decpt); - while (decpt++ < 0) - *to++='0'; - } - else if (decpt == 0) - { - *to++= '0'; - if (!decimals) - goto end; - *to++='.'; - } - else - { - while (decpt-- > 0) - *to++= *pos++; - if (!decimals) - goto end; - *to++='.'; - } - while (decimals--) - *to++= *pos++; - -end: - *to=0; - str_length=(uint32) (to-Ptr); - return FALSE; -#else -#ifdef HAVE_SNPRINTF - buff[sizeof(buff)-1]=0; // Safety - snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num); -#else - sprintf(buff,"%.*f",(int) decimals,num); -#endif - return copy(buff,(uint32) strlen(buff), &my_charset_latin1, cs, + len= my_fcvt(num, decimals, buff, NULL); + return copy(buff, (uint32) len, &my_charset_latin1, cs, &dummy_errors); -#endif } @@ -675,7 +608,8 @@ void String::qs_append(const char *str, uint32 len) void String::qs_append(double d) { char *buff = Ptr + str_length; - str_length+= my_sprintf(buff, (buff, "%.15g", d)); + str_length+= my_gcvt(d, MY_GCVT_ARG_DOUBLE, FLOATING_POINT_BUFFER - 1, buff, + NULL); } void String::qs_append(double *d) |