diff --git a/include/my_byteorder.h b/include/my_byteorder.h index a70330ca47c..acd3f490136 100644 --- a/include/my_byteorder.h +++ b/include/my_byteorder.h @@ -16,6 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ +#include /* Macro for reading 32-bit integer from network byte order (big-endian) @@ -51,4 +52,12 @@ #include "little_endian.h" #endif +/* convenienve helpers */ +static inline float get_float(const void *from) +{ + float to; + float4get(to, ((const uchar*)from)); + return to; +} + #endif /* MY_BYTEORDER_INCLUDED */ diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c index 84b45e14435..01fda8ea8d0 100644 --- a/libmysqld/libmysql.c +++ b/libmysqld/libmysql.c @@ -3658,9 +3658,7 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, } case MYSQL_TYPE_FLOAT: { - float value; - float4get(value,*row); - fetch_float_with_conversion(param, field, value, MY_GCVT_ARG_FLOAT); + fetch_float_with_conversion(param, field, get_float(*row), MY_GCVT_ARG_FLOAT); *row+= 4; break; } diff --git a/sql/field.cc b/sql/field.cc index 2c66e34cf8e..5fcd5eb57a4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4862,16 +4862,12 @@ int Field_float::store(longlong nr, bool unsigned_val) double Field_float::val_real(void) { DBUG_ASSERT(marked_for_read()); - float j; - float4get(j,ptr); - return ((double) j); + return ((double) get_float(ptr)); } longlong Field_float::val_int(void) { - float j; - float4get(j,ptr); - return Converter_double_to_longlong(j, false).result(); + return Converter_double_to_longlong(get_float(ptr), false).result(); } diff --git a/sql/log_event_client.cc b/sql/log_event_client.cc index da788db6b06..31e2722b627 100644 --- a/sql/log_event_client.cc +++ b/sql/log_event_client.cc @@ -632,10 +632,8 @@ log_event_print_value(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info, if (!ptr) goto return_null; - float fl; - float4get(fl, ptr); char tmp[320]; - sprintf(tmp, "%-20g", (double) fl); + sprintf(tmp, "%-20g", (double) get_float(ptr)); my_b_printf(file, "%s", tmp); /* my_snprintf doesn't support %-20g */ return 4; } diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index a0139151730..e00de4c835a 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -635,9 +635,7 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key, if (seg->type == HA_KEYTYPE_FLOAT) { - float nr; - float4get(nr, pos); - if (isnan(nr)) + if (isnan(get_float(pos))) { /* Replace NAN with zero */ bzero(key, length); diff --git a/storage/maria/ma_key.c b/storage/maria/ma_key.c index 1b58c1c12c8..58c05547484 100644 --- a/storage/maria/ma_key.c +++ b/storage/maria/ma_key.c @@ -284,9 +284,7 @@ MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr, { /* Numerical column */ if (type == HA_KEYTYPE_FLOAT) { - float nr; - float4get(nr,pos); - if (isnan(nr)) + if (isnan(get_float(pos))) { /* Replace NAN with zero */ bzero(key,length); diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index bde3ee19e2c..707de1d45d9 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -158,9 +158,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, { /* Numerical column */ if (type == HA_KEYTYPE_FLOAT) { - float nr; - float4get(nr,pos); - if (isnan(nr)) + if (isnan(get_float(pos))) { /* Replace NAN with zero */ bzero(key,length);