mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
cleanup: get_float convenience helper
more helpers like that can be added as needed
This commit is contained in:
parent
115d3e050c
commit
949fed514a
7 changed files with 16 additions and 21 deletions
|
@ -16,6 +16,7 @@
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Macro for reading 32-bit integer from network byte order (big-endian)
|
Macro for reading 32-bit integer from network byte order (big-endian)
|
||||||
|
@ -51,4 +52,12 @@
|
||||||
#include "little_endian.h"
|
#include "little_endian.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* convenienve helpers */
|
||||||
|
static inline float get_float(const void *from)
|
||||||
|
{
|
||||||
|
float to;
|
||||||
|
float4get(to, ((const uchar*)from));
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* MY_BYTEORDER_INCLUDED */
|
#endif /* MY_BYTEORDER_INCLUDED */
|
||||||
|
|
|
@ -3658,9 +3658,7 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
|
||||||
}
|
}
|
||||||
case MYSQL_TYPE_FLOAT:
|
case MYSQL_TYPE_FLOAT:
|
||||||
{
|
{
|
||||||
float value;
|
fetch_float_with_conversion(param, field, get_float(*row), MY_GCVT_ARG_FLOAT);
|
||||||
float4get(value,*row);
|
|
||||||
fetch_float_with_conversion(param, field, value, MY_GCVT_ARG_FLOAT);
|
|
||||||
*row+= 4;
|
*row+= 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4862,16 +4862,12 @@ int Field_float::store(longlong nr, bool unsigned_val)
|
||||||
double Field_float::val_real(void)
|
double Field_float::val_real(void)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(marked_for_read());
|
DBUG_ASSERT(marked_for_read());
|
||||||
float j;
|
return ((double) get_float(ptr));
|
||||||
float4get(j,ptr);
|
|
||||||
return ((double) j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
longlong Field_float::val_int(void)
|
longlong Field_float::val_int(void)
|
||||||
{
|
{
|
||||||
float j;
|
return Converter_double_to_longlong(get_float(ptr), false).result();
|
||||||
float4get(j,ptr);
|
|
||||||
return Converter_double_to_longlong(j, false).result();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -632,10 +632,8 @@ log_event_print_value(IO_CACHE *file, PRINT_EVENT_INFO *print_event_info,
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
goto return_null;
|
goto return_null;
|
||||||
|
|
||||||
float fl;
|
|
||||||
float4get(fl, ptr);
|
|
||||||
char tmp[320];
|
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 */
|
my_b_printf(file, "%s", tmp); /* my_snprintf doesn't support %-20g */
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -635,9 +635,7 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
|
||||||
|
|
||||||
if (seg->type == HA_KEYTYPE_FLOAT)
|
if (seg->type == HA_KEYTYPE_FLOAT)
|
||||||
{
|
{
|
||||||
float nr;
|
if (isnan(get_float(pos)))
|
||||||
float4get(nr, pos);
|
|
||||||
if (isnan(nr))
|
|
||||||
{
|
{
|
||||||
/* Replace NAN with zero */
|
/* Replace NAN with zero */
|
||||||
bzero(key, length);
|
bzero(key, length);
|
||||||
|
|
|
@ -284,9 +284,7 @@ MARIA_KEY *_ma_make_key(MARIA_HA *info, MARIA_KEY *int_key, uint keynr,
|
||||||
{ /* Numerical column */
|
{ /* Numerical column */
|
||||||
if (type == HA_KEYTYPE_FLOAT)
|
if (type == HA_KEYTYPE_FLOAT)
|
||||||
{
|
{
|
||||||
float nr;
|
if (isnan(get_float(pos)))
|
||||||
float4get(nr,pos);
|
|
||||||
if (isnan(nr))
|
|
||||||
{
|
{
|
||||||
/* Replace NAN with zero */
|
/* Replace NAN with zero */
|
||||||
bzero(key,length);
|
bzero(key,length);
|
||||||
|
|
|
@ -158,9 +158,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
|
||||||
{ /* Numerical column */
|
{ /* Numerical column */
|
||||||
if (type == HA_KEYTYPE_FLOAT)
|
if (type == HA_KEYTYPE_FLOAT)
|
||||||
{
|
{
|
||||||
float nr;
|
if (isnan(get_float(pos)))
|
||||||
float4get(nr,pos);
|
|
||||||
if (isnan(nr))
|
|
||||||
{
|
{
|
||||||
/* Replace NAN with zero */
|
/* Replace NAN with zero */
|
||||||
bzero(key,length);
|
bzero(key,length);
|
||||||
|
|
Loading…
Reference in a new issue