Bug #12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
Submitted: 11 Aug 2005 11:12 Modified: 17 Aug 2005 19:15
Reporter: Hakan Küçükyılmaz Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.12 OS:Linux (Linux)
Assigned to: Antony Curtis CPU Architecture:Any

[11 Aug 2005 11:12] Hakan Küçükyılmaz
Description:
According to ISO/IEC 9075-11:2003 Part 11 Chapter 6.20 case 7) the COLUMN_DEFAULT has to set to NULL if no default value is given. However if the field is set to NOT NULL an empty string is returned.

How to repeat:
USE test;
DROP TABLE IF EXISTS t1;

CREATE TABLE t1 (
 a int NOT NULL,
 b int);

SELECT COLUMN_NAME, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS
  WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 't1';

[13:03] root@test>' SELECT COLUMN_NAME, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS
    -> A  WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 't1';
+-------------+----------------+
| COLUMN_NAME | COLUMN_DEFAULT |
+-------------+----------------+
| a           |                |
| b           | NULL           |
+-------------+----------------+
2 rows in set (0.19 sec)

Suggested fix:
The column a should have NULL as COLUMN_DEFAULT
[12 Aug 2005 8:05] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/28210
[15 Aug 2005 16:15] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/28285
[15 Aug 2005 16:49] Antony Curtis
Made alterations as per review.
[15 Aug 2005 16:50] Antony Curtis
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
[15 Aug 2005 16:52] Antony Curtis
Output from "SHOW COLUMNS" hasn't changed.
INFORMATION_SCHEMA.COLUMNS follows SQL standards.
[17 Aug 2005 17:20] Paul DuBois
We need the three-part version number for the
version to which the patch was applied, in order to
write a changelog entry.  Reverting to Patch Pending
status.  Please supply the version number and set
to Documenting status again. Thanks.
[17 Aug 2005 18:58] Antony Curtis
Version 5.0.12
[17 Aug 2005 19:15] Paul DuBois
Noted in 5.0.12 changelog.