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

fixed signed numeric literal parsing

parent 613104ad
......@@ -242,6 +242,13 @@ class Item {
};
class Item_num: public Item
{
public:
virtual void neg()= 0;
};
class st_select_lex;
class Item_ident :public Item
{
......@@ -398,10 +405,10 @@ class Item_param :public Item
void print(String *str) { str->append('?'); }
};
class Item_int :public Item
class Item_int :public Item_num
{
public:
const longlong value;
longlong value;
Item_int(int32 i,uint length=11) :value((longlong) i)
{ max_length=length; fixed= 1; }
#ifdef HAVE_LONG_LONG
......@@ -425,12 +432,16 @@ class Item_int :public Item
Item *new_item() { return new Item_int(name,value,max_length); }
// to prevent drop fixed flag (no need parent cleanup call)
void cleanup() { fixed= 1; }
void print(String *strclass Item_uint :public Item_int
void print(String *str);
void neg() { value= -value; }
};
class Item_uint :public Item_int
{
public:
Item_uint(const char *str_arg, uint length) :
Item_int(str_arg, (longlong) strtoull(str_arg,(char**) 0,10), length)
Item_int(str_arg, (longlong) strtoull(str_arg,(char**) 0,10), length)
Item_int(str_arg, (longlong) strtoull(str_arg, (char**) 0,10), length)
{ unsigned_flag= 1; }
Item_uint(uint32 i) :Item_int((longlong) i, 10)
{ unsigned_flag= 1; }
......@@ -443,10 +454,10 @@ class Item_int :public Item
};
class Item_real :public Item
class Item_real :public Item_num
{
public:
const double value;
double value;
// Item_real() :value(0) {}
Item_real(const char *str_arg,uint length) :value(my_atof(str_arg))
{
......@@ -474,6 +485,7 @@ class Item_real :public Item
String *val_str(String*);
bool basic_const_item() const { return 1; }
Item *new_item() { return new Item_real(name,value,decimals,max_length); }
void neg() { value= -value; }
};
......
......@@ -64,6 +64,7 @@ inline Item *or_or_concat(THD *thd, Item* A, Item* B)
Table_ident *table;
char *simple_string;
Item *item;
Item_num *item_num;
List<Item> *item_list;
List<String> *string_list;
String *string;
......@@ -628,7 +629,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
using_list expr_or_default set_expr_or_default interval_expr
param_marker singlerow_subselect singlerow_subselect_init
exists_subselect exists_subselect_init geometry_function
signed_literal NUM_literal
signed_literal
%type <item_num>
NUM_literal
%type <item_list>
expr_list udf_expr_list when_list ident_list ident_list_arg
......@@ -4525,8 +4529,9 @@ signed_literal:
| '+' NUM_literal { $$ = $2; }
| '-' NUM_literal
{
/* $2 it's Item_int -> we can get value without fix_fields call */
$$= new Item_int(-$2->val_int(), $2->max_length+1);
$2->neg();
$2->max_length++;
$$= $2;
}
;
......
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