fixed signed numeric literal parsing
sql/item.h: added negation methods for numeric Items sql/sql_yacc.yy: fixed numeric literal
This commit is contained in:
parent
85dddd908a
commit
647498e965
26
sql/item.h
26
sql/item.h
@ -242,6 +242,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Item_num: public Item
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void neg()= 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class st_select_lex;
|
class st_select_lex;
|
||||||
class Item_ident :public Item
|
class Item_ident :public Item
|
||||||
{
|
{
|
||||||
@ -398,10 +405,10 @@ public:
|
|||||||
void print(String *str) { str->append('?'); }
|
void print(String *str) { str->append('?'); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_int :public Item
|
class Item_int :public Item_num
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const longlong value;
|
longlong value;
|
||||||
Item_int(int32 i,uint length=11) :value((longlong) i)
|
Item_int(int32 i,uint length=11) :value((longlong) i)
|
||||||
{ max_length=length; fixed= 1; }
|
{ max_length=length; fixed= 1; }
|
||||||
#ifdef HAVE_LONG_LONG
|
#ifdef HAVE_LONG_LONG
|
||||||
@ -425,12 +432,16 @@ public:
|
|||||||
Item *new_item() { return new Item_int(name,value,max_length); }
|
Item *new_item() { return new Item_int(name,value,max_length); }
|
||||||
// to prevent drop fixed flag (no need parent cleanup call)
|
// to prevent drop fixed flag (no need parent cleanup call)
|
||||||
void cleanup() { fixed= 1; }
|
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:
|
public:
|
||||||
Item_uint(const char *str_arg, uint length) :
|
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; }
|
{ unsigned_flag= 1; }
|
||||||
Item_uint(uint32 i) :Item_int((longlong) i, 10)
|
Item_uint(uint32 i) :Item_int((longlong) i, 10)
|
||||||
{ unsigned_flag= 1; }
|
{ unsigned_flag= 1; }
|
||||||
@ -443,10 +454,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Item_real :public Item
|
class Item_real :public Item_num
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const 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))
|
||||||
{
|
{
|
||||||
@ -474,6 +485,7 @@ public:
|
|||||||
String *val_str(String*);
|
String *val_str(String*);
|
||||||
bool basic_const_item() const { return 1; }
|
bool basic_const_item() const { return 1; }
|
||||||
Item *new_item() { return new Item_real(name,value,decimals,max_length); }
|
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;
|
Table_ident *table;
|
||||||
char *simple_string;
|
char *simple_string;
|
||||||
Item *item;
|
Item *item;
|
||||||
|
Item_num *item_num;
|
||||||
List<Item> *item_list;
|
List<Item> *item_list;
|
||||||
List<String> *string_list;
|
List<String> *string_list;
|
||||||
String *string;
|
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
|
using_list expr_or_default set_expr_or_default interval_expr
|
||||||
param_marker singlerow_subselect singlerow_subselect_init
|
param_marker singlerow_subselect singlerow_subselect_init
|
||||||
exists_subselect exists_subselect_init geometry_function
|
exists_subselect exists_subselect_init geometry_function
|
||||||
signed_literal NUM_literal
|
signed_literal
|
||||||
|
|
||||||
|
%type <item_num>
|
||||||
|
NUM_literal
|
||||||
|
|
||||||
%type <item_list>
|
%type <item_list>
|
||||||
expr_list udf_expr_list when_list ident_list ident_list_arg
|
expr_list udf_expr_list when_list ident_list ident_list_arg
|
||||||
@ -4525,8 +4529,9 @@ signed_literal:
|
|||||||
| '+' NUM_literal { $$ = $2; }
|
| '+' NUM_literal { $$ = $2; }
|
||||||
| '-' NUM_literal
|
| '-' NUM_literal
|
||||||
{
|
{
|
||||||
/* $2 it's Item_int -> we can get value without fix_fields call */
|
$2->neg();
|
||||||
$$= new Item_int(-$2->val_int(), $2->max_length+1);
|
$2->max_length++;
|
||||||
|
$$= $2;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user