summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <tnurnberg@mysql.com/white.intern.koehntopp.de>2007-11-17 19:05:31 +0100
committerunknown <tnurnberg@mysql.com/white.intern.koehntopp.de>2007-11-17 19:05:31 +0100
commit748446b99c435b9c268f8931878a2474ba6e753f (patch)
tree8cb67d260aa02a391094fbe25bd72edc65a76182 /mysql-test
parent7b98539199e9335068b4e3a5e91b8d0fa5092c43 (diff)
downloadmariadb-git-748446b99c435b9c268f8931878a2474ba6e753f.tar.gz
Bug#24907: unpredictable (display) precission, if input precission increases
Server failed in assert() when we tried to create a DECIMAL() temp field with a scale of more than the allowed 30. Now we limit the scale to the allowed maximum. A truncation warning is thrown as necessary. mysql-test/r/type_newdecimal.result: Show that out of range DECIMAL temp fields will no longer stop the server with an assert. mysql-test/t/type_newdecimal.test: Show that out of range DECIMAL temp fields will no longer stop the server with an assert. sql/sql_select.cc: When creating DECIMAL() temp field, ascertain we stay within allowed limits. If not, truncate and warn.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/type_newdecimal.result20
-rw-r--r--mysql-test/t/type_newdecimal.test21
2 files changed, 40 insertions, 1 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 75d9582a23c..b53b49bd0dd 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -1499,4 +1499,24 @@ SELECT 1 FROM t1 GROUP BY @b := @a, @b;
1
1
DROP TABLE t1;
+CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1;
+Warnings:
+Note 1265 Data truncated for column 'f1' at row 1
+DESC t1;
+Field Type Null Key Default Extra
+f1 decimal(31,30) NO 0.000000000000000000000000000000
+SELECT f1 FROM t1;
+f1
+0.123456789012345678901234567890
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1;
+Warnings:
+Warning 1264 Out of range value adjusted for column 'f1' at row 1
+DESC t1;
+Field Type Null Key Default Extra
+f1 decimal(59,30) NO 0.000000000000000000000000000000
+SELECT f1 FROM t1;
+f1
+99999999999999999999999999999.999999999999999999999999999999
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 5a631b6163e..cb7e0c4163a 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1195,6 +1195,25 @@ SELECT 1 FROM t1 GROUP BY @b := @a, @b;
DROP TABLE t1;
---echo End of 5.0 tests
+#
+# Bug #24907: unpredictable (display) precission, if input precission
+# increases
+#
+# As per 10.1.1. Overview of Numeric Types, type (new) DECIMAL has a
+# maxmimum precision of 30 places after the decimal point. Show that
+# temp field creation beyond that works and throws a truncation warning.
+# DECIMAL(37,36) should be adjusted to DECIMAL(31,30).
+CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1;
+DESC t1;
+SELECT f1 FROM t1;
+DROP TABLE t1;
+# too many decimal places, AND too many digits altogether (90 = 45+45).
+# should preserve integers (65 = 45+20)
+CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1;
+DESC t1;
+SELECT f1 FROM t1;
+DROP TABLE t1;
+
+--echo End of 5.0 tests