mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-19468 Hybrid type expressions return wrong format for FLOAT
This commit is contained in:
@ -7884,7 +7884,7 @@ EXPLAIN
|
|||||||
"access_type": "ALL",
|
"access_type": "ALL",
|
||||||
"rows": 3,
|
"rows": 3,
|
||||||
"filtered": 100,
|
"filtered": 100,
|
||||||
"attached_condition": "sq.i = 2.7100000381469727",
|
"attached_condition": "sq.i = 2.71",
|
||||||
"materialized": {
|
"materialized": {
|
||||||
"query_block": {
|
"query_block": {
|
||||||
"select_id": 2,
|
"select_id": 2,
|
||||||
|
@ -2789,26 +2789,26 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||||||
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
||||||
select max(key1) from t1 where key1 <= 0.6158;
|
select max(key1) from t1 where key1 <= 0.6158;
|
||||||
max(key1)
|
max(key1)
|
||||||
0.6158000230789185
|
0.6158
|
||||||
select max(key2) from t2 where key2 <= 1.6158;
|
select max(key2) from t2 where key2 <= 1.6158;
|
||||||
max(key2)
|
max(key2)
|
||||||
1.6158000230789185
|
1.6158
|
||||||
select min(key1) from t1 where key1 >= 0.3762;
|
select min(key1) from t1 where key1 >= 0.3762;
|
||||||
min(key1)
|
min(key1)
|
||||||
0.37619999051094055
|
0.3762
|
||||||
select min(key2) from t2 where key2 >= 1.3762;
|
select min(key2) from t2 where key2 >= 1.3762;
|
||||||
min(key2)
|
min(key2)
|
||||||
1.3761999607086182
|
1.3762
|
||||||
select max(key1), min(key2) from t1, t2
|
select max(key1), min(key2) from t1, t2
|
||||||
where key1 <= 0.6158 and key2 >= 1.3762;
|
where key1 <= 0.6158 and key2 >= 1.3762;
|
||||||
max(key1) min(key2)
|
max(key1) min(key2)
|
||||||
0.6158000230789185 1.3761999607086182
|
0.6158 1.3762
|
||||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||||
max(key1)
|
max(key1)
|
||||||
0.38449999690055847
|
0.3845
|
||||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||||
min(key1)
|
min(key1)
|
||||||
0.38449999690055847
|
0.3845
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
||||||
INSERT INTO t1 VALUES (10);
|
INSERT INTO t1 VALUES (10);
|
||||||
|
@ -2800,26 +2800,26 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||||||
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
||||||
select max(key1) from t1 where key1 <= 0.6158;
|
select max(key1) from t1 where key1 <= 0.6158;
|
||||||
max(key1)
|
max(key1)
|
||||||
0.6158000230789185
|
0.6158
|
||||||
select max(key2) from t2 where key2 <= 1.6158;
|
select max(key2) from t2 where key2 <= 1.6158;
|
||||||
max(key2)
|
max(key2)
|
||||||
1.6158000230789185
|
1.6158
|
||||||
select min(key1) from t1 where key1 >= 0.3762;
|
select min(key1) from t1 where key1 >= 0.3762;
|
||||||
min(key1)
|
min(key1)
|
||||||
0.37619999051094055
|
0.3762
|
||||||
select min(key2) from t2 where key2 >= 1.3762;
|
select min(key2) from t2 where key2 >= 1.3762;
|
||||||
min(key2)
|
min(key2)
|
||||||
1.3761999607086182
|
1.3762
|
||||||
select max(key1), min(key2) from t1, t2
|
select max(key1), min(key2) from t1, t2
|
||||||
where key1 <= 0.6158 and key2 >= 1.3762;
|
where key1 <= 0.6158 and key2 >= 1.3762;
|
||||||
max(key1) min(key2)
|
max(key1) min(key2)
|
||||||
0.6158000230789185 1.3761999607086182
|
0.6158 1.3762
|
||||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||||
max(key1)
|
max(key1)
|
||||||
0.38449999690055847
|
0.3845
|
||||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||||
min(key1)
|
min(key1)
|
||||||
0.38449999690055847
|
0.3845
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
||||||
INSERT INTO t1 VALUES (10);
|
INSERT INTO t1 VALUES (10);
|
||||||
|
@ -2789,26 +2789,26 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||||||
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
||||||
select max(key1) from t1 where key1 <= 0.6158;
|
select max(key1) from t1 where key1 <= 0.6158;
|
||||||
max(key1)
|
max(key1)
|
||||||
0.6158000230789185
|
0.6158
|
||||||
select max(key2) from t2 where key2 <= 1.6158;
|
select max(key2) from t2 where key2 <= 1.6158;
|
||||||
max(key2)
|
max(key2)
|
||||||
1.6158000230789185
|
1.6158
|
||||||
select min(key1) from t1 where key1 >= 0.3762;
|
select min(key1) from t1 where key1 >= 0.3762;
|
||||||
min(key1)
|
min(key1)
|
||||||
0.37619999051094055
|
0.3762
|
||||||
select min(key2) from t2 where key2 >= 1.3762;
|
select min(key2) from t2 where key2 >= 1.3762;
|
||||||
min(key2)
|
min(key2)
|
||||||
1.3761999607086182
|
1.3762
|
||||||
select max(key1), min(key2) from t1, t2
|
select max(key1), min(key2) from t1, t2
|
||||||
where key1 <= 0.6158 and key2 >= 1.3762;
|
where key1 <= 0.6158 and key2 >= 1.3762;
|
||||||
max(key1) min(key2)
|
max(key1) min(key2)
|
||||||
0.6158000230789185 1.3761999607086182
|
0.6158 1.3762
|
||||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||||
max(key1)
|
max(key1)
|
||||||
0.38449999690055847
|
0.3845
|
||||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||||
min(key1)
|
min(key1)
|
||||||
0.38449999690055847
|
0.3845
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
||||||
INSERT INTO t1 VALUES (10);
|
INSERT INTO t1 VALUES (10);
|
||||||
|
@ -840,3 +840,40 @@ DROP TABLE t1;
|
|||||||
#
|
#
|
||||||
# End of 10.2 tests
|
# End of 10.2 tests
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# Start of 10.3 tests
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MDEV-19468 Hybrid type expressions return wrong format for FLOAT
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a FLOAT);
|
||||||
|
INSERT INTO t1 VALUES (0.671437);
|
||||||
|
SELECT a, COALESCE(a), MAX(a), LEAST(a,a), (SELECT a FROM t1) AS c FROM t1;
|
||||||
|
a COALESCE(a) MAX(a) LEAST(a,a) c
|
||||||
|
0.671437 0.671437 0.671437 0.671437 0.671437
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a FLOAT);
|
||||||
|
INSERT INTO t1 VALUES (0.671437);
|
||||||
|
SELECT
|
||||||
|
CONCAT(a),
|
||||||
|
CONCAT(COALESCE(a)),
|
||||||
|
CONCAT(LEAST(a,a)),
|
||||||
|
CONCAT(MAX(a)),
|
||||||
|
CONCAT((SELECT a FROM t1)) AS c
|
||||||
|
FROM t1;
|
||||||
|
CONCAT(a) CONCAT(COALESCE(a)) CONCAT(LEAST(a,a)) CONCAT(MAX(a)) c
|
||||||
|
0.671437 0.671437 0.671437 0.671437 0.671437
|
||||||
|
CREATE TABLE t2 AS SELECT
|
||||||
|
CONCAT(a),
|
||||||
|
CONCAT(COALESCE(a)),
|
||||||
|
CONCAT(LEAST(a,a)),
|
||||||
|
CONCAT(MAX(a)),
|
||||||
|
CONCAT((SELECT a FROM t1)) AS c
|
||||||
|
FROM t1;
|
||||||
|
SELECT * FROM t2;
|
||||||
|
CONCAT(a) CONCAT(COALESCE(a)) CONCAT(LEAST(a,a)) CONCAT(MAX(a)) c
|
||||||
|
0.671437 0.671437 0.671437 0.671437 0.671437
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
#
|
||||||
|
# End of 10.3 tests
|
||||||
|
#
|
||||||
|
@ -581,3 +581,40 @@ DROP TABLE t1;
|
|||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.2 tests
|
--echo # End of 10.2 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Start of 10.3 tests
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-19468 Hybrid type expressions return wrong format for FLOAT
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a FLOAT);
|
||||||
|
INSERT INTO t1 VALUES (0.671437);
|
||||||
|
SELECT a, COALESCE(a), MAX(a), LEAST(a,a), (SELECT a FROM t1) AS c FROM t1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a FLOAT);
|
||||||
|
INSERT INTO t1 VALUES (0.671437);
|
||||||
|
SELECT
|
||||||
|
CONCAT(a),
|
||||||
|
CONCAT(COALESCE(a)),
|
||||||
|
CONCAT(LEAST(a,a)),
|
||||||
|
CONCAT(MAX(a)),
|
||||||
|
CONCAT((SELECT a FROM t1)) AS c
|
||||||
|
FROM t1;
|
||||||
|
CREATE TABLE t2 AS SELECT
|
||||||
|
CONCAT(a),
|
||||||
|
CONCAT(COALESCE(a)),
|
||||||
|
CONCAT(LEAST(a,a)),
|
||||||
|
CONCAT(MAX(a)),
|
||||||
|
CONCAT((SELECT a FROM t1)) AS c
|
||||||
|
FROM t1;
|
||||||
|
SELECT * FROM t2;
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # End of 10.3 tests
|
||||||
|
--echo #
|
||||||
|
21
sql/field.cc
21
sql/field.cc
@ -4556,34 +4556,15 @@ String *Field_float::val_str(String *val_buffer,
|
|||||||
{
|
{
|
||||||
ASSERT_COLUMN_MARKED_FOR_READ;
|
ASSERT_COLUMN_MARKED_FOR_READ;
|
||||||
DBUG_ASSERT(!zerofill || field_length <= MAX_FIELD_CHARLENGTH);
|
DBUG_ASSERT(!zerofill || field_length <= MAX_FIELD_CHARLENGTH);
|
||||||
float nr;
|
|
||||||
float4get(nr,ptr);
|
|
||||||
|
|
||||||
uint to_length= 70;
|
if (Float(ptr).to_string(val_buffer, dec))
|
||||||
if (val_buffer->alloc(to_length))
|
|
||||||
{
|
{
|
||||||
my_error(ER_OUT_OF_RESOURCES, MYF(0));
|
my_error(ER_OUT_OF_RESOURCES, MYF(0));
|
||||||
return val_buffer;
|
return val_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *to=(char*) val_buffer->ptr();
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (dec >= FLOATING_POINT_DECIMALS)
|
|
||||||
len= my_gcvt(nr, MY_GCVT_ARG_FLOAT, to_length - 1, to, NULL);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
We are safe here because the buffer length is 70, and
|
|
||||||
fabs(float) < 10^39, dec < FLOATING_POINT_DECIMALS. So the resulting string
|
|
||||||
will be not longer than 69 chars + terminating '\0'.
|
|
||||||
*/
|
|
||||||
len= my_fcvt(nr, dec, to, NULL);
|
|
||||||
}
|
|
||||||
val_buffer->length((uint) len);
|
|
||||||
if (zerofill)
|
if (zerofill)
|
||||||
prepend_zeros(val_buffer);
|
prepend_zeros(val_buffer);
|
||||||
val_buffer->set_charset(&my_charset_numeric);
|
|
||||||
return val_buffer;
|
return val_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
sql/item.cc
12
sql/item.cc
@ -10153,7 +10153,7 @@ longlong Item_cache_real::val_int()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String* Item_cache_real::val_str(String *str)
|
String* Item_cache_double::val_str(String *str)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(fixed == 1);
|
DBUG_ASSERT(fixed == 1);
|
||||||
if (!has_value())
|
if (!has_value())
|
||||||
@ -10163,6 +10163,16 @@ String* Item_cache_real::val_str(String *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String* Item_cache_float::val_str(String *str)
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(fixed == 1);
|
||||||
|
if (!has_value())
|
||||||
|
return NULL;
|
||||||
|
Float((float) value).to_string(str, decimals);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
my_decimal *Item_cache_real::val_decimal(my_decimal *decimal_val)
|
my_decimal *Item_cache_real::val_decimal(my_decimal *decimal_val)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(fixed == 1);
|
DBUG_ASSERT(fixed == 1);
|
||||||
|
33
sql/item.h
33
sql/item.h
@ -6186,21 +6186,44 @@ public:
|
|||||||
|
|
||||||
class Item_cache_real: public Item_cache
|
class Item_cache_real: public Item_cache
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
double value;
|
double value;
|
||||||
public:
|
public:
|
||||||
Item_cache_real(THD *thd): Item_cache(thd, &type_handler_double),
|
Item_cache_real(THD *thd, const Type_handler *h)
|
||||||
value(0) {}
|
:Item_cache(thd, h),
|
||||||
|
value(0)
|
||||||
|
{}
|
||||||
double val_real();
|
double val_real();
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
String* val_str(String *str);
|
|
||||||
my_decimal *val_decimal(my_decimal *);
|
my_decimal *val_decimal(my_decimal *);
|
||||||
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
|
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
|
||||||
{ return get_date_from_real(ltime, fuzzydate); }
|
{ return get_date_from_real(ltime, fuzzydate); }
|
||||||
bool cache_value();
|
bool cache_value();
|
||||||
Item *convert_to_basic_const_item(THD *thd);
|
Item *convert_to_basic_const_item(THD *thd);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Item_cache_double: public Item_cache_real
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Item_cache_double(THD *thd)
|
||||||
|
:Item_cache_real(thd, &type_handler_double)
|
||||||
|
{ }
|
||||||
|
String* val_str(String *str);
|
||||||
Item *get_copy(THD *thd)
|
Item *get_copy(THD *thd)
|
||||||
{ return get_item_copy<Item_cache_real>(thd, this); }
|
{ return get_item_copy<Item_cache_double>(thd, this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Item_cache_float: public Item_cache_real
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Item_cache_float(THD *thd)
|
||||||
|
:Item_cache_real(thd, &type_handler_float)
|
||||||
|
{ }
|
||||||
|
String* val_str(String *str);
|
||||||
|
Item *get_copy(THD *thd)
|
||||||
|
{ return get_item_copy<Item_cache_float>(thd, this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1209,7 +1209,7 @@ bool Protocol_text::store(float from, uint32 decimals, String *buffer)
|
|||||||
field_types[field_pos] == MYSQL_TYPE_FLOAT);
|
field_types[field_pos] == MYSQL_TYPE_FLOAT);
|
||||||
field_pos++;
|
field_pos++;
|
||||||
#endif
|
#endif
|
||||||
buffer->set_real((double) from, decimals, thd->charset());
|
Float(from).to_string(buffer, decimals);
|
||||||
return net_store_data((uchar*) buffer->ptr(), buffer->length());
|
return net_store_data((uchar*) buffer->ptr(), buffer->length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +125,32 @@ bool Type_handler_data::init()
|
|||||||
Type_handler_data *type_handler_data= NULL;
|
Type_handler_data *type_handler_data= NULL;
|
||||||
|
|
||||||
|
|
||||||
|
bool Float::to_string(String *val_buffer, uint dec) const
|
||||||
|
{
|
||||||
|
uint to_length= 70;
|
||||||
|
if (val_buffer->alloc(to_length))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
char *to=(char*) val_buffer->ptr();
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (dec >= FLOATING_POINT_DECIMALS)
|
||||||
|
len= my_gcvt(m_value, MY_GCVT_ARG_FLOAT, to_length - 1, to, NULL);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
We are safe here because the buffer length is 70, and
|
||||||
|
fabs(float) < 10^39, dec < FLOATING_POINT_DECIMALS. So the resulting string
|
||||||
|
will be not longer than 69 chars + terminating '\0'.
|
||||||
|
*/
|
||||||
|
len= my_fcvt(m_value, (int) dec, to, NULL);
|
||||||
|
}
|
||||||
|
val_buffer->length((uint) len);
|
||||||
|
val_buffer->set_charset(&my_charset_numeric);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Time::make_from_item(Item *item, const Options opt)
|
void Time::make_from_item(Item *item, const Options opt)
|
||||||
{
|
{
|
||||||
if (item->get_date(this, opt.get_date_flags()))
|
if (item->get_date(this, opt.get_date_flags()))
|
||||||
@ -2708,9 +2734,15 @@ Type_handler_year::Item_get_cache(THD *thd, const Item *item) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
Item_cache *
|
Item_cache *
|
||||||
Type_handler_real_result::Item_get_cache(THD *thd, const Item *item) const
|
Type_handler_double::Item_get_cache(THD *thd, const Item *item) const
|
||||||
{
|
{
|
||||||
return new (thd->mem_root) Item_cache_real(thd);
|
return new (thd->mem_root) Item_cache_double(thd);
|
||||||
|
}
|
||||||
|
|
||||||
|
Item_cache *
|
||||||
|
Type_handler_float::Item_get_cache(THD *thd, const Item *item) const
|
||||||
|
{
|
||||||
|
return new (thd->mem_root) Item_cache_float(thd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Item_cache *
|
Item_cache *
|
||||||
@ -3575,7 +3607,7 @@ Type_handler_int_result::Item_func_hybrid_field_type_get_date(
|
|||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
||||||
String *
|
String *
|
||||||
Type_handler_real_result::Item_func_hybrid_field_type_val_str(
|
Type_handler_double::Item_func_hybrid_field_type_val_str(
|
||||||
Item_func_hybrid_field_type *item,
|
Item_func_hybrid_field_type *item,
|
||||||
String *str) const
|
String *str) const
|
||||||
{
|
{
|
||||||
@ -3583,6 +3615,19 @@ Type_handler_real_result::Item_func_hybrid_field_type_val_str(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String *
|
||||||
|
Type_handler_float::Item_func_hybrid_field_type_val_str(
|
||||||
|
Item_func_hybrid_field_type *item,
|
||||||
|
String *str) const
|
||||||
|
{
|
||||||
|
Float nr(item->real_op());
|
||||||
|
if (item->null_value)
|
||||||
|
return 0;
|
||||||
|
nr.to_string(str, item->decimals);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double
|
double
|
||||||
Type_handler_real_result::Item_func_hybrid_field_type_val_real(
|
Type_handler_real_result::Item_func_hybrid_field_type_val_real(
|
||||||
Item_func_hybrid_field_type *item)
|
Item_func_hybrid_field_type *item)
|
||||||
@ -4042,13 +4087,24 @@ String *Type_handler_decimal_result::
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String *Type_handler_real_result::
|
String *Type_handler_double::
|
||||||
Item_func_min_max_val_str(Item_func_min_max *func, String *str) const
|
Item_func_min_max_val_str(Item_func_min_max *func, String *str) const
|
||||||
{
|
{
|
||||||
return func->val_string_from_real(str);
|
return func->val_string_from_real(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String *Type_handler_float::
|
||||||
|
Item_func_min_max_val_str(Item_func_min_max *func, String *str) const
|
||||||
|
{
|
||||||
|
Float nr(func->val_real());
|
||||||
|
if (func->null_value)
|
||||||
|
return 0;
|
||||||
|
nr.to_string(str, func->decimals);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double Type_handler_string_result::
|
double Type_handler_string_result::
|
||||||
Item_func_min_max_val_real(Item_func_min_max *func) const
|
Item_func_min_max_val_real(Item_func_min_max *func) const
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "sql_array.h"
|
#include "sql_array.h"
|
||||||
#include "sql_const.h"
|
#include "sql_const.h"
|
||||||
#include "sql_time.h"
|
#include "sql_time.h"
|
||||||
|
#include "sql_type_real.h"
|
||||||
|
|
||||||
class Field;
|
class Field;
|
||||||
class Column_definition;
|
class Column_definition;
|
||||||
@ -1779,7 +1780,6 @@ public:
|
|||||||
const st_value *value) const;
|
const st_value *value) const;
|
||||||
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
|
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
|
||||||
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
|
Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const;
|
||||||
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
|
|
||||||
bool set_comparator_func(Arg_comparator *cmp) const;
|
bool set_comparator_func(Arg_comparator *cmp) const;
|
||||||
bool Item_hybrid_func_fix_attributes(THD *thd,
|
bool Item_hybrid_func_fix_attributes(THD *thd,
|
||||||
const char *name,
|
const char *name,
|
||||||
@ -1799,8 +1799,6 @@ public:
|
|||||||
longlong Item_val_int_signed_typecast(Item *item) const;
|
longlong Item_val_int_signed_typecast(Item *item) const;
|
||||||
longlong Item_val_int_unsigned_typecast(Item *item) const;
|
longlong Item_val_int_unsigned_typecast(Item *item) const;
|
||||||
String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const;
|
String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const;
|
||||||
String *Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type *,
|
|
||||||
String *) const;
|
|
||||||
double Item_func_hybrid_field_type_val_real(Item_func_hybrid_field_type *)
|
double Item_func_hybrid_field_type_val_real(Item_func_hybrid_field_type *)
|
||||||
const;
|
const;
|
||||||
longlong Item_func_hybrid_field_type_val_int(Item_func_hybrid_field_type *)
|
longlong Item_func_hybrid_field_type_val_int(Item_func_hybrid_field_type *)
|
||||||
@ -1811,7 +1809,6 @@ public:
|
|||||||
bool Item_func_hybrid_field_type_get_date(Item_func_hybrid_field_type *,
|
bool Item_func_hybrid_field_type_get_date(Item_func_hybrid_field_type *,
|
||||||
MYSQL_TIME *,
|
MYSQL_TIME *,
|
||||||
ulonglong fuzzydate) const;
|
ulonglong fuzzydate) const;
|
||||||
String *Item_func_min_max_val_str(Item_func_min_max *, String *) const;
|
|
||||||
longlong Item_func_between_val_int(Item_func_between *func) const;
|
longlong Item_func_between_val_int(Item_func_between *func) const;
|
||||||
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const;
|
cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const;
|
||||||
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const;
|
in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const;
|
||||||
@ -2611,6 +2608,11 @@ public:
|
|||||||
TABLE *table) const;
|
TABLE *table) const;
|
||||||
void Item_param_set_param_func(Item_param *param,
|
void Item_param_set_param_func(Item_param *param,
|
||||||
uchar **pos, ulong len) const;
|
uchar **pos, ulong len) const;
|
||||||
|
|
||||||
|
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
|
||||||
|
String *Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type *,
|
||||||
|
String *) const;
|
||||||
|
String *Item_func_min_max_val_str(Item_func_min_max *, String *) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -2643,6 +2645,11 @@ public:
|
|||||||
TABLE *table) const;
|
TABLE *table) const;
|
||||||
void Item_param_set_param_func(Item_param *param,
|
void Item_param_set_param_func(Item_param *param,
|
||||||
uchar **pos, ulong len) const;
|
uchar **pos, ulong len) const;
|
||||||
|
|
||||||
|
Item_cache *Item_get_cache(THD *thd, const Item *item) const;
|
||||||
|
String *Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type *,
|
||||||
|
String *) const;
|
||||||
|
String *Item_func_min_max_val_str(Item_func_min_max *, String *) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
35
sql/sql_type_real.h
Normal file
35
sql/sql_type_real.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* Copyright (c) 2019 MariaDB
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; version 2 of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||||
|
|
||||||
|
#ifndef SQL_TYPE_REAL_INCLUDED
|
||||||
|
#define SQL_TYPE_REAL_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
class Float
|
||||||
|
{
|
||||||
|
float m_value;
|
||||||
|
public:
|
||||||
|
Float(float nr)
|
||||||
|
:m_value(nr)
|
||||||
|
{ }
|
||||||
|
Float(const uchar *ptr)
|
||||||
|
{
|
||||||
|
float4get(m_value, ptr);
|
||||||
|
}
|
||||||
|
bool to_string(String *to, uint dec) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SQL_TYPE_REAL_INCLUDED
|
@ -1654,15 +1654,15 @@ CONCAT('', MAX(d1_0)),
|
|||||||
CONCAT('', MAX(d10_10)),
|
CONCAT('', MAX(d10_10)),
|
||||||
CONCAT('', MAX(d53)),
|
CONCAT('', MAX(d53)),
|
||||||
CONCAT('', MAX(d53_10)) FROM t1;
|
CONCAT('', MAX(d53_10)) FROM t1;
|
||||||
CONCAT('', MAX(f)) 9.999999680285692e37
|
CONCAT('', MAX(f)) 1e38
|
||||||
CONCAT('', MAX(d)) 1e81
|
CONCAT('', MAX(d)) 1e81
|
||||||
CONCAT('', MAX(d10_10)) 0.9999999999
|
CONCAT('', MAX(d10_10)) 0.9999999999
|
||||||
CONCAT('', MAX(d1_0)) 9
|
CONCAT('', MAX(d1_0)) 9
|
||||||
CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
|
CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
|
||||||
CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
|
CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
|
||||||
CONCAT('', MAX(f0)) 9.999999680285692e37
|
CONCAT('', MAX(f0)) 1e38
|
||||||
CONCAT('', MAX(f20_3)) 99999998430674940.000
|
CONCAT('', MAX(f20_3)) 99999998430674940.000
|
||||||
CONCAT('', MAX(f23_0)) 9.999999680285692e37
|
CONCAT('', MAX(f23_0)) 1e38
|
||||||
CONCAT('', MAX(r1_1)) 0.9
|
CONCAT('', MAX(r1_1)) 0.9
|
||||||
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
|
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
|
||||||
9999999999999999999999999999999999999999999999999999999999999.9999,
|
9999999999999999999999999999999999999999999999999999999999999.9999,
|
||||||
|
@ -1441,15 +1441,15 @@ CONCAT('', MAX(d1_0)),
|
|||||||
CONCAT('', MAX(d10_10)),
|
CONCAT('', MAX(d10_10)),
|
||||||
CONCAT('', MAX(d53)),
|
CONCAT('', MAX(d53)),
|
||||||
CONCAT('', MAX(d53_10)) FROM t1;
|
CONCAT('', MAX(d53_10)) FROM t1;
|
||||||
CONCAT('', MAX(f)) 9.999999680285692e37
|
CONCAT('', MAX(f)) 1e38
|
||||||
CONCAT('', MAX(d)) 1e81
|
CONCAT('', MAX(d)) 1e81
|
||||||
CONCAT('', MAX(d10_10)) 0.9999999999
|
CONCAT('', MAX(d10_10)) 0.9999999999
|
||||||
CONCAT('', MAX(d1_0)) 9
|
CONCAT('', MAX(d1_0)) 9
|
||||||
CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
|
CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
|
||||||
CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
|
CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
|
||||||
CONCAT('', MAX(f0)) 9.999999680285692e37
|
CONCAT('', MAX(f0)) 1e38
|
||||||
CONCAT('', MAX(f20_3)) 99999998430674940.000
|
CONCAT('', MAX(f20_3)) 99999998430674940.000
|
||||||
CONCAT('', MAX(f23_0)) 9.999999680285692e37
|
CONCAT('', MAX(f23_0)) 1e38
|
||||||
CONCAT('', MAX(r1_1)) 0.9
|
CONCAT('', MAX(r1_1)) 0.9
|
||||||
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
|
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
|
||||||
9999999999999999999999999999999999999999999999999999999999999.9999,
|
9999999999999999999999999999999999999999999999999999999999999.9999,
|
||||||
|
@ -328,15 +328,15 @@ CONCAT('', MAX(d1_0)),
|
|||||||
CONCAT('', MAX(d10_10)),
|
CONCAT('', MAX(d10_10)),
|
||||||
CONCAT('', MAX(d53)),
|
CONCAT('', MAX(d53)),
|
||||||
CONCAT('', MAX(d53_10)) FROM t1;
|
CONCAT('', MAX(d53_10)) FROM t1;
|
||||||
CONCAT('', MAX(f)) 9.999999680285692e37
|
CONCAT('', MAX(f)) 1e38
|
||||||
CONCAT('', MAX(d)) 1e81
|
CONCAT('', MAX(d)) 1e81
|
||||||
CONCAT('', MAX(d10_10)) 0.9999999999
|
CONCAT('', MAX(d10_10)) 0.9999999999
|
||||||
CONCAT('', MAX(d1_0)) 9
|
CONCAT('', MAX(d1_0)) 9
|
||||||
CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
|
CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
|
||||||
CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
|
CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
|
||||||
CONCAT('', MAX(f0)) 9.999999680285692e37
|
CONCAT('', MAX(f0)) 1e38
|
||||||
CONCAT('', MAX(f20_3)) 99999998430674940.000
|
CONCAT('', MAX(f20_3)) 99999998430674940.000
|
||||||
CONCAT('', MAX(f23_0)) 9.999999680285692e37
|
CONCAT('', MAX(f23_0)) 1e38
|
||||||
CONCAT('', MAX(r1_1)) 0.9
|
CONCAT('', MAX(r1_1)) 0.9
|
||||||
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
|
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
|
||||||
9999999999999999999999999999999999999999999999999999999999999.9999,
|
9999999999999999999999999999999999999999999999999999999999999.9999,
|
||||||
|
@ -138,15 +138,15 @@ CONCAT('', MAX(d1_0)),
|
|||||||
CONCAT('', MAX(d10_10)),
|
CONCAT('', MAX(d10_10)),
|
||||||
CONCAT('', MAX(d53)),
|
CONCAT('', MAX(d53)),
|
||||||
CONCAT('', MAX(d53_10)) FROM t1;
|
CONCAT('', MAX(d53_10)) FROM t1;
|
||||||
CONCAT('', MAX(f)) 9.999999680285692e37
|
CONCAT('', MAX(f)) 1e38
|
||||||
CONCAT('', MAX(d)) 1e81
|
CONCAT('', MAX(d)) 1e81
|
||||||
CONCAT('', MAX(d10_10)) 0.9999999999
|
CONCAT('', MAX(d10_10)) 0.9999999999
|
||||||
CONCAT('', MAX(d1_0)) 9
|
CONCAT('', MAX(d1_0)) 9
|
||||||
CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
|
CONCAT('', MAX(d53)) 100000000000000000000000000000000000000000000000000000
|
||||||
CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
|
CONCAT('', MAX(d53_10)) 10000000000000000000000000000000000000000000.0000000000
|
||||||
CONCAT('', MAX(f0)) 9.999999680285692e37
|
CONCAT('', MAX(f0)) 1e38
|
||||||
CONCAT('', MAX(f20_3)) 99999998430674940.000
|
CONCAT('', MAX(f20_3)) 99999998430674940.000
|
||||||
CONCAT('', MAX(f23_0)) 9.999999680285692e37
|
CONCAT('', MAX(f23_0)) 1e38
|
||||||
CONCAT('', MAX(r1_1)) 0.9
|
CONCAT('', MAX(r1_1)) 0.9
|
||||||
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
|
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
|
||||||
9999999999999999999999999999999999999999999999999999999999999.9999,
|
9999999999999999999999999999999999999999999999999999999999999.9999,
|
||||||
|
Reference in New Issue
Block a user