Bug #432 MySQL allows precision of -1 if scale is > 0
Submitted: 14 May 2003 10:28 Modified: 14 May 2003 15:21
Reporter: Matt Solnit Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.12 OS:Microsoft Windows (Windows XP Professional SP1)
Assigned to: Michael Widenius CPU Architecture:Any

[14 May 2003 10:28] Matt Solnit
Description:
MySQL will allow me to create a DECIMAL column with a precision of -1 if the scale is greater than zero.  When I try to insert a row into this table, mysqld-nt.exe crashes.

How to repeat:
USE test;

mysql> CREATE TABLE notvalid_decimal (a_dec DECIMAL(-1,0));
ERROR 1074: Too big column length for column 'a_dec' (max = 255). Use BLOB instead /* good */

mysql> CREATE TABLE notvalid_decimal (a_dec DECIMAL(-2,1));
ERROR 1074: Too big column length for column 'a_dec' (max = 255). Use BLOB instead /* good */

mysql> CREATE TABLE notvalid_decimal (a_dec DECIMAL(-1,1));
Query OK, 0 rows affected (0.03 sec) /* bad??? */

mysql> INSERT INTO notvalid_decimal VALUES (NULL);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO notvalid_decimal VALUES (1);
MySQL Server crashes!

Suggested fix:
Do not allow table to be created or only allow null values.
[14 May 2003 15:21] Michael Widenius
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html

Will be fixed in 4.0.13 and 4.1.1