Commit 8086aa35 authored by unknown's avatar unknown

Fix for Bug #2075 - negative default values not accepted for integer columns

  Allow numeric literals have a sign


sql/sql_yacc.yy:
  Bug#2075 - Numeric literals need to handle sign.
mysql-test/r/create.result:
  New test for Bug #2075
mysql-test/t/create.test:
  New test for Bug #2075
parent 4de97333
......@@ -423,6 +423,17 @@ strnull varchar(10) YES NULL
intg int(11) YES NULL
rel double YES NULL
drop table t1, t2;
create table t1(name varchar(10), age smallint default -1);
describe t1;
Field Type Null Key Default Extra
name varchar(10) YES NULL
age smallint(6) YES -1
create table t2(name varchar(10), age smallint default - 1);
describe t2;
Field Type Null Key Default Extra
name varchar(10) YES NULL
age smallint(6) YES -1
drop table t1, t2;
create database test_$1;
use test_$1;
select database();
......
......@@ -330,6 +330,16 @@ create table t2 select default(str) as str, default(strnull) as strnull, default
describe t2;
drop table t1, t2;
#
# Bug #2075
#
create table t1(name varchar(10), age smallint default -1);
describe t1;
create table t2(name varchar(10), age smallint default - 1);
describe t2;
drop table t1, t2;
#
# Bug #1209
#
......
......@@ -627,6 +627,7 @@ 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
NUM_literal
%type <item_list>
expr_list udf_expr_list when_list ident_list ident_list_arg
......@@ -4409,11 +4410,8 @@ param_marker:
literal:
text_literal { $$ = $1; }
| NUM { $$ = new Item_int($1.str, (longlong) strtol($1.str, NULL, 10),$1.length); }
| LONG_NUM { $$ = new Item_int($1.str, (longlong) strtoll($1.str,NULL,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 @@ literal:
| TIME_SYM text_literal { $$ = $2; }
| TIMESTAMP text_literal { $$ = $2; };
opt_plus:
| '+' ;
NUM_literal:
NUM { $$ = new Item_int($1.str, (longlong) strtol($1.str, NULL, 10),$1.length); }
| LONG_NUM { $$ = new Item_int($1.str, (longlong) strtoll($1.str,NULL,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.
**********************************************************************/
......
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