summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-01-07 17:44:18 +0100
committerunknown <jimw@mysql.com>2005-01-07 17:44:18 +0100
commit0c57a67ce0434fa78e2b64f569a271d166371a32 (patch)
tree9a7f02c79ea56ff312e753cadcecc4efe3a60f3a /mysql-test
parent9ad1b390fcf12ec7aa7b9fad157d6e0a61045b40 (diff)
downloadmariadb-git-0c57a67ce0434fa78e2b64f569a271d166371a32.tar.gz
Correctly truncate integers inserted into field and double columns
with a number of decimals specified. (Bug #7361) mysql-test/t/type_float.test: Add test for maximum values of float and double columns with number of decimals mysql-test/r/type_float.result: Add results for new test mysql-test/r/type_float.result.es: Add results for new test sql/field.cc: Use ::store(double nr) from ::store(longlong nr) so we get the same range checking
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/type_float.result36
-rw-r--r--mysql-test/r/type_float.result.es36
-rw-r--r--mysql-test/t/type_float.test10
3 files changed, 82 insertions, 0 deletions
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index 2f996382586..9dd92c13c98 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -143,3 +143,39 @@ drop table t1;
create table t1 (f float(54));
ERROR 42000: Incorrect column specifier for column 'f'
drop table if exists t1;
+create table t1 (f float(4,3));
+insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
+Warnings:
+Warning 1264 Data truncated; out of range for column 'f' at row 1
+Warning 1264 Data truncated; out of range for column 'f' at row 2
+Warning 1264 Data truncated; out of range for column 'f' at row 3
+Warning 1264 Data truncated; out of range for column 'f' at row 4
+Warning 1264 Data truncated; out of range for column 'f' at row 5
+Warning 1264 Data truncated; out of range for column 'f' at row 6
+select * from t1;
+f
+-9.999
+-9.999
+-9.999
+9.999
+9.999
+9.999
+drop table if exists t1;
+create table t1 (f double(4,3));
+insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
+Warnings:
+Warning 1264 Data truncated; out of range for column 'f' at row 1
+Warning 1264 Data truncated; out of range for column 'f' at row 2
+Warning 1264 Data truncated; out of range for column 'f' at row 3
+Warning 1264 Data truncated; out of range for column 'f' at row 4
+Warning 1264 Data truncated; out of range for column 'f' at row 5
+Warning 1264 Data truncated; out of range for column 'f' at row 6
+select * from t1;
+f
+-9.999
+-9.999
+-9.999
+9.999
+9.999
+9.999
+drop table if exists t1;
diff --git a/mysql-test/r/type_float.result.es b/mysql-test/r/type_float.result.es
index 4bfe644d7fb..64d9be7e30f 100644
--- a/mysql-test/r/type_float.result.es
+++ b/mysql-test/r/type_float.result.es
@@ -143,3 +143,39 @@ drop table t1;
create table t1 (f float(54));
ERROR 42000: Incorrect column specifier for column 'f'
drop table if exists t1;
+create table t1 (f float(4,3));
+insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
+Warnings:
+Warning 1264 Data truncated; out of range for column 'f' at row 1
+Warning 1264 Data truncated; out of range for column 'f' at row 2
+Warning 1264 Data truncated; out of range for column 'f' at row 3
+Warning 1264 Data truncated; out of range for column 'f' at row 4
+Warning 1264 Data truncated; out of range for column 'f' at row 5
+Warning 1264 Data truncated; out of range for column 'f' at row 6
+select * from t1;
+f
+-9.999
+-9.999
+-9.999
+9.999
+9.999
+9.999
+drop table if exists t1;
+create table t1 (f double(4,3));
+insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
+Warnings:
+Warning 1264 Data truncated; out of range for column 'f' at row 1
+Warning 1264 Data truncated; out of range for column 'f' at row 2
+Warning 1264 Data truncated; out of range for column 'f' at row 3
+Warning 1264 Data truncated; out of range for column 'f' at row 4
+Warning 1264 Data truncated; out of range for column 'f' at row 5
+Warning 1264 Data truncated; out of range for column 'f' at row 6
+select * from t1;
+f
+-9.999
+-9.999
+-9.999
+9.999
+9.999
+9.999
+drop table if exists t1;
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index 26ac272c6d4..3fe3afa3fac 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -93,3 +93,13 @@ create table t1 (f float(54)); # Should give an error
drop table if exists t1;
--enable_warnings
+# Ensure that maximum values as the result of number of decimals
+# being specified in table schema are enforced (Bug #7361)
+create table t1 (f float(4,3));
+insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
+select * from t1;
+drop table if exists t1;
+create table t1 (f double(4,3));
+insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
+select * from t1;
+drop table if exists t1;