Bug #36335 Incorrect syntax description for DECIMAL/NUMERIC column definitions
Submitted: 25 Apr 2008 8:49 Modified: 25 Apr 2008 13:59
Reporter: Kay Roepke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:4.1+ OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[25 Apr 2008 8:49] Kay Roepke
Description:
In http://dev.mysql.com/doc/refman/4.1/en/create-table.html the syntax description for both the DECIMAL and NUMERIC types is incorrect:

It suggests that the "length,decimals" portion is required, but in fact it is optional:
  | DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
  | NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]

How to repeat:
According to the docs the statement:
create table test.foo (a DECIMAL, b NUMERIC);

should lead to a syntax error.

Suggested fix:
Change the respective descriptions to:

  | DECIMAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
  | NUMERIC[(length,decimals)] [UNSIGNED] [ZEROFILL]

and document the default values for length and decimals.
[25 Apr 2008 8:49] Kay Roepke
I forgot to mention that this problem is present in all versions of the docs.
[25 Apr 2008 9:41] Valeriy Kravchuk
Thank you for a problem report.
[25 Apr 2008 12:46] Kay Roepke
Please note that this problem also extends to the two following types:
CHAR, BINARY

VARCHAR and VARBINARY are not affected.

mysql> create table test.char(a char);
mysql> show create table test.char\G
*************************** 1. row ***************************
       Table: char
Create Table: CREATE TABLE `char` (
  `a` char(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> create table test.binary(a binary);
mysql> show create table test.binary\G
*************************** 1. row ***************************
       Table: binary
Create Table: CREATE TABLE `binary` (
  `a` binary(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
[25 Apr 2008 13:42] Paul DuBois
This page doesn't exactly track the exact syntax as specified in the data types chapter. As the page says:

"
data_type represents the data type in a column definition. spatial_type represents a spatial data type. The data type syntax shown is representative only. For a full description of the syntax available for specifying column data types, as well as information about the properties of each type, see Chapter 10, Data Types, and Chapter 16, Spatial Extensions.
"

However, it does appear that the DECIMAL/NUMERIC syntax is incorrect *everywhere* -- even if M is specified, D is optional. That needs to be fixed.
[25 Apr 2008 13:56] Paul DuBois
Sorry, the DECIMAL/NUMERIC syntax is correct in the data types chapter.
[25 Apr 2008 13:59] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.