mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
fixed printing of real constants (BUG#5160)
mysql-test/r/view.result: VIEW with floating point (long bumber) as column mysql-test/t/view.test: VIEW with floating point (long bumber) as column sql/item.cc: fixed printing of real constants sql/item.h: fixed printing of real constants
This commit is contained in:
parent
c33897765f
commit
321918b300
4 changed files with 32 additions and 3 deletions
|
@ -1217,3 +1217,8 @@ t1 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL
|
|||
v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1;
|
||||
show create view v1;
|
||||
Table Create Table
|
||||
v1 CREATE VIEW `test`.`v1` AS select 99999999999999999999999999999999999999999999999999999 AS `col1`
|
||||
drop view v1;
|
||||
|
|
|
@ -1161,3 +1161,10 @@ show table status;
|
|||
show table status;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# VIEW with floating point (long bumber) as column
|
||||
#
|
||||
create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1;
|
||||
show create view v1;
|
||||
drop view v1;
|
||||
|
|
15
sql/item.cc
15
sql/item.cc
|
@ -1756,6 +1756,21 @@ int Item_real::save_in_field(Field *field, bool no_conversions)
|
|||
return field->store(nr);
|
||||
}
|
||||
|
||||
|
||||
void Item_real::print(String *str)
|
||||
{
|
||||
if (presentation)
|
||||
{
|
||||
str->append(presentation);
|
||||
return;
|
||||
}
|
||||
char buffer[20];
|
||||
String num(buffer, sizeof(buffer), &my_charset_bin);
|
||||
num.set(value, decimals, &my_charset_bin);
|
||||
str->append(num);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
** varbinary item
|
||||
** In string context this is a binary string
|
||||
|
|
|
@ -698,12 +698,13 @@ public:
|
|||
|
||||
class Item_real :public Item_num
|
||||
{
|
||||
char *presentation;
|
||||
public:
|
||||
double value;
|
||||
// Item_real() :value(0) {}
|
||||
Item_real(const char *str_arg, uint length) :value(my_atof(str_arg))
|
||||
{
|
||||
name=(char*) str_arg;
|
||||
presentation= name=(char*) str_arg;
|
||||
decimals=(uint8) nr_of_decimals(str_arg);
|
||||
max_length=length;
|
||||
fixed= 1;
|
||||
|
@ -711,12 +712,12 @@ public:
|
|||
Item_real(const char *str,double val_arg,uint decimal_par,uint length)
|
||||
:value(val_arg)
|
||||
{
|
||||
name=(char*) str;
|
||||
presentation= name=(char*) str;
|
||||
decimals=(uint8) decimal_par;
|
||||
max_length=length;
|
||||
fixed= 1;
|
||||
}
|
||||
Item_real(double value_par) :value(value_par) { fixed= 1; }
|
||||
Item_real(double value_par) :presentation(0), value(value_par) { fixed= 1; }
|
||||
int save_in_field(Field *field, bool no_conversions);
|
||||
enum Type type() const { return REAL_ITEM; }
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
|
||||
|
@ -732,6 +733,7 @@ public:
|
|||
void cleanup() {}
|
||||
Item *new_item() { return new Item_real(name,value,decimals,max_length); }
|
||||
Item_num *neg() { value= -value; return this; }
|
||||
void print(String *str);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue