Commit 80a28d45 authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

fixed printing of real constants (BUG#5160)

parent 56d8567a
...@@ -1217,3 +1217,8 @@ t1 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL ...@@ -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 v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view
drop view v1; drop view v1;
drop table t1; 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; ...@@ -1161,3 +1161,10 @@ show table status;
show table status; show table status;
drop view v1; drop view v1;
drop table t1; 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) ...@@ -1756,6 +1756,21 @@ int Item_real::save_in_field(Field *field, bool no_conversions)
return field->store(nr); 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 ** varbinary item
** In string context this is a binary string ** In string context this is a binary string
......
...@@ -698,12 +698,13 @@ public: ...@@ -698,12 +698,13 @@ public:
class Item_real :public Item_num class Item_real :public Item_num
{ {
char *presentation;
public: public:
double value; double value;
// Item_real() :value(0) {} // Item_real() :value(0) {}
Item_real(const char *str_arg, uint length) :value(my_atof(str_arg)) 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); decimals=(uint8) nr_of_decimals(str_arg);
max_length=length; max_length=length;
fixed= 1; fixed= 1;
...@@ -711,12 +712,12 @@ public: ...@@ -711,12 +712,12 @@ public:
Item_real(const char *str,double val_arg,uint decimal_par,uint length) Item_real(const char *str,double val_arg,uint decimal_par,uint length)
:value(val_arg) :value(val_arg)
{ {
name=(char*) str; presentation= name=(char*) str;
decimals=(uint8) decimal_par; decimals=(uint8) decimal_par;
max_length=length; max_length=length;
fixed= 1; 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); int save_in_field(Field *field, bool no_conversions);
enum Type type() const { return REAL_ITEM; } enum Type type() const { return REAL_ITEM; }
enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
...@@ -732,6 +733,7 @@ public: ...@@ -732,6 +733,7 @@ public:
void cleanup() {} void cleanup() {}
Item *new_item() { return new Item_real(name,value,decimals,max_length); } Item *new_item() { return new Item_real(name,value,decimals,max_length); }
Item_num *neg() { value= -value; return this; } 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