Commit 54ea6018 authored by unknown's avatar unknown

Fix for bug #9894 (Negative numbers are allowed to 'unsigned' column)


mysql-test/r/type_decimal.result:
  test result fixed
mysql-test/r/type_newdecimal.result:
  test result fixed
mysql-test/t/type_newdecimal.test:
  test case added
sql/field.cc:
  We need to refuse negative integers when 'unsigned'
parent 936688fe
......@@ -414,8 +414,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1;
a
9999999999
9999999999
0
0
1
1
1
......@@ -430,8 +430,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1;
a
9999999999
9999999999
0000000000
0000000000
0000000001
0000000001
0000000001
......@@ -446,8 +446,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 7
select * from t1;
a
9999999999
9999999999
0000000000
0000000000
0000000001
0000000001
0000000001
......
......@@ -119,7 +119,7 @@ a
99.99
99.99
99.99
99.99
0.00
0.00
0.00
0.00
......@@ -891,3 +891,8 @@ NULL
select abs(NULL);
abs(NULL)
NULL
set @@sql_mode='traditional';
create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned);
insert into t1 values(1,-1,-1);
ERROR 22003: Out of range value adjusted for column 'd2' at row 1
drop table t1;
......@@ -925,3 +925,12 @@ DROP TABLE t1;
select abs(10/0);
select abs(NULL);
#
# Bug #9894 (negative to unsigned column)
#
set @@sql_mode='traditional';
create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned);
--error 1264
insert into t1 values(1,-1,-1);
drop table t1;
......@@ -2446,7 +2446,7 @@ int Field_new_decimal::store(longlong nr)
int err;
if ((err= int2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
nr, unsigned_flag, &decimal_value)))
nr, false, &decimal_value)))
{
if (check_overflow(err))
set_value_on_overflow(&decimal_value, decimal_value.sign());
......
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