From 54ea60189d1fa37c77388ba34db0927d8e05e046 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Jun 2005 12:25:57 +0500 Subject: 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' --- mysql-test/r/type_decimal.result | 12 ++++++------ mysql-test/r/type_newdecimal.result | 7 ++++++- mysql-test/t/type_newdecimal.test | 9 +++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index ab57caacc0f..93467d1d7da 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -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 diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index f03f2f5a862..26ea9c2e5d2 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -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; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 0f7d20ed977..de5fb09186b 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -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; -- cgit v1.2.1 From 3eb21ef361283d52a5bce7c90ce1e62791d48647 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Jun 2005 13:11:04 +0500 Subject: Fix for bug #8425 (Insufficient precision in the '/' operation) As the bug was already fixed, just testcase added here mysql-test/r/type_newdecimal.result: test result fixed mysql-test/t/type_newdecimal.test: test case added --- mysql-test/r/type_newdecimal.result | 13 +++++++++++++ mysql-test/t/type_newdecimal.test | 12 ++++++++++++ 2 files changed, 25 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index 26ea9c2e5d2..09fbc6b8143 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -896,3 +896,16 @@ create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (2 insert into t1 values(1,-1,-1); ERROR 22003: Out of range value adjusted for column 'd2' at row 1 drop table t1; +set @@div_precision_increment=15; +create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); +insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); +select col2/9999999999 from t1 where col1=1; +col2/9999999999 +0.000000000001234567890246913578 +select 9999999999/col2 from t1 where col1=1; +9999999999/col2 +810000007209.000065537105051 +select 77777777/7777777; +77777777/7777777 +10.000000900000090 +drop table t1; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index de5fb09186b..6bff6c22abc 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -934,3 +934,15 @@ create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (2 --error 1264 insert into t1 values(1,-1,-1); drop table t1; + +# +# Bug #8425 (insufficient precision of the division) +# +set @@div_precision_increment=15; +create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); +insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); +select col2/9999999999 from t1 where col1=1; +select 9999999999/col2 from t1 where col1=1; +select 77777777/7777777; +drop table t1; + -- cgit v1.2.1