Bug #8122 incorrect handling of SET, ENUM columns
Submitted: 25 Jan 2005 4:20 Modified: 3 May 2005 10:54
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Administrator Severity:S2 (Serious)
Version:1.0.19 OS:Linux (Linux)
Assigned to: Vladimir Kolesnikov CPU Architecture:Any

[25 Jan 2005 4:20] [ name withheld ]
Description:
This is the bug reported to Debian (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=291755)
--------------------

The mysql-admin "Table Editor" incorrectly parses columns with a SET or
ENUM type. The bug appears the same way with SET and ENUM, so I'll just
describe the ENUM case below.

In the mysql-admin "Table Editor", create a table with an ENUM column.
This results in this SQL statement:

CREATE TABLE `test`.`testtbl` (
  `col` ENUM('foo','bar')  NOT NULL DEFAULT 'bar'
)
TYPE = MYISAM;

Now quit the table editor, and click on "Refresh" in the main window
so that the newly created table becomes visible.

Now edit the testtbl table in the "Table Editor". The default value will
now be "bar" _without_ quotes, both in the column list and in the "Column
Details" at the bottom of the "Table Editor".

Now press "Apply Changes" and this SQL statement is generated (line feed
added by me):

ALTER TABLE `test`.`testtbl`
MODIFY COLUMN `col` ENUM('foo','bar') NOT NULL DEFAULT bar AUTO_INCREMENT;

Note the "DEFAULT bar", where "bar" is unquoted, just it is shown in
the "Table Editor". This is clearly incorrect SQL, as it should be
"DEFAULT 'bar'".

If I fix the unquoted "bar" in the "Table Editor" dialog to "'bar'"
(with quotes), then the quoted version is inserted into the SQL
statement, and the resulting SQL statement works:

ALTER TABLE `test`.`testtbl`
MODIFY COLUMN `col` ENUM('foo','bar') NOT NULL DEFAULT 'bar' AUTO_INCREMENT;

The place to fix this is probably somewhere in the parsing of the column
types and the corresponding generation of column data for the GUI.

How to repeat:
see description.
[25 Jan 2005 6:09] Aleksey Kishkin
tested on slackware 10, mysql 4.1.9-standard, mysql-administrator 1.0.19
[3 May 2005 10:54] Vladimir Kolesnikov
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