| Bug #43345 | Column creation allows a column name with trailing spaces | ||
|---|---|---|---|
| Submitted: | 3 Mar 2009 22:55 | Modified: | 6 Aug 2009 16:13 |
| Reporter: | Bruce Hard | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Workbench | Severity: | S3 (Non-critical) |
| Version: | 5.0.30 | OS: | Windows (XP) |
| Assigned to: | Sergei Tkachenko | CPU Architecture: | Any |
| Tags: | CHECKED, ERROR 1166 (42000): Incorrect column name | ||
[4 Mar 2009 0:58]
MySQL Verification Team
Thank you for the bug report.
[4 Aug 2009 8:55]
Sergei Tkachenko
Fixed in 5.1
[6 Aug 2009 15:41]
Johannes Taxacher
fix confirmed. will be included in 5.1.17
[6 Aug 2009 16:13]
Tony Bedford
An entry was added to the 5.1.17 changelog: In the Columns tab of the Table Editor, a column name could be entered with leading or trailing spaces. This led to the following error when exporting the schema: ERROR 1166 (42000): Incorrect column name 'name '

Description: The Workbench GUI does not remove trailing spaces from a column name resulting in an error when creating the table. ERROR 1166 (42000): Incorrect column name 'name ' How to repeat: Test Case: Using Workbench GUI Click on Add Table Type in tbl_name Click on Columns tab at the column name prompt type in id at the datatype prompt select INT -- Now create a column name with 3 trailing blank spaces at the column name prompt type in name //followed by three blank spaces at the datatype prompt select VARCHAR(45) Click on SAVE Then Click on File, Export Forward Engineer Export Script Save to a file name bug_test Click Next Click Finish Then open the generated file and look at the table creation script and see that there are trailing space in the column_name for name CREATE TABLE IF NOT EXISTS `MY_TESTING_DB`.`tbl_name` ( `id` INT NOT NULL AUTO_INCREMENT , `name ` VARCHAR(45) NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB; Run this create table statement in MySQL and see the resulting error mysql> CREATE TABLE IF NOT EXISTS `MY_TESTING_DB`.`tbl_name` ( -> `id` INT NOT NULL AUTO_INCREMENT , -> `name ` VARCHAR(45) NULL , -> PRIMARY KEY (`id`) ) -> ENGINE = InnoDB; ERROR 1166 (42000): Incorrect column name 'name ' Suggested fix: Change the workbench code to strip trailing or leading spaces from a column name.