Commit 6f3d6a54 authored by unknown's avatar unknown

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
parent acdae5b1
......@@ -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;
......@@ -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 @@ class Item_uint :public Item_int
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 @@ class Item_real :public Item_num
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 @@ class Item_real :public Item_num
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);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment