Bug #2075 | negative default values not accepted for integer columns | ||
---|---|---|---|
Submitted: | 10 Dec 2003 5:51 | Modified: | 10 Dec 2003 16:31 |
Reporter: | SINISA MILIVOJEVIC | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 4.1.1 | OS: | Any (any) |
Assigned to: | Antony Curtis | CPU Architecture: | Any |
[10 Dec 2003 5:51]
SINISA MILIVOJEVIC
[10 Dec 2003 16:03]
Antony Curtis
The following patch fixes it - it allows numeric literals to have a sign prepended. ===== sql/sql_yacc.yy 1.282 vs edited ===== --- 1.282/sql/sql_yacc.yy Wed Dec 10 03:36:38 2003 +++ edited/sql/sql_yacc.yy Wed Dec 10 23:38:59 2003 @@ -627,6 +627,7 @@ using_list expr_or_default set_expr_or_default interval_expr param_marker singlerow_subselect singlerow_subselect_init exists_subselect exists_subselect_init + NUM_literal %type <item_list> expr_list udf_expr_list when_list ident_list ident_list_arg @@ -4409,11 +4410,8 @@ literal: text_literal { $$ = $1; } - | NUM { $$ = new Item_int($1.str, (longlong) strtol($1.str, N ULL, 10),$1.length); } - | LONG_NUM { $$ = new Item_int($1.str, (longlong) strtoll($1.str,N ULL,10), $1.length); } - | ULONGLONG_NUM { $$ = new Item_uint($1.str, $1.length); } - | REAL_NUM { $$ = new Item_real($1.str, $1.length); } - | FLOAT_NUM { $$ = new Item_float($1.str, $1.length); } + | opt_plus NUM_literal { $$ = $2; } + | '-' NUM_literal { $$ = new Item_func_neg($2); } | NULL_SYM { $$ = new Item_null(); Lex->next_state=MY_LEX_OPERATOR_OR_IDENT;} | HEX_NUM { $$ = new Item_varbinary($1.str,$1.length);} @@ -4429,6 +4427,17 @@ | TIME_SYM text_literal { $$ = $2; } | TIMESTAMP text_literal { $$ = $2; }; +opt_plus: + | '+' ; + +NUM_literal: + NUM { $$ = new Item_int($1.str, (longlong) strtol($1.str, N ULL, 10),$1.length); } + | LONG_NUM { $$ = new Item_int($1.str, (longlong) strtoll($1.str,N ULL,10), $1.length); } + | ULONGLONG_NUM { $$ = new Item_uint($1.str, $1.length); } + | REAL_NUM { $$ = new Item_real($1.str, $1.length); } + | FLOAT_NUM { $$ = new Item_float($1.str, $1.length); } + ; + /********************************************************************** ** Createing different items. **********************************************************************/
[10 Dec 2003 16:31]
Antony Curtis
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bugfix, yourself. More information about accessing the source trees is available at http://www.mysql.com/doc/en/Installing_source_tree.html