Bug #37045 Delete multiple slected columns deletes wrong columns
Submitted: 28 May 2008 18:31 Modified: 10 Jul 2008 8:32
Reporter: Radboud Platvoet Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S2 (Serious)
Version:5.0.21 OSS OS:Windows (XP SP2)
Assigned to: Mike Lischke CPU Architecture:Any
Tags: columns, delete, multiselect, workbench

[28 May 2008 18:31] Radboud Platvoet
Description:
When you editing a table and on the columns tab if you want to delete multiple selected tables at once, the WorkBench removes the wrong columns.

How to repeat:
-Create a table.
-Create 5 columns: c1, c2, c3, c4
-Select columns c4 then add column c2 to the selection. (The order of selection is important!!)
-Alternative mouse button click the selected columns.
-Click "Delete selected columns" on the popup menu.

Column c2 and c5 are deleted.

This bug probably is also valid for any other listviews or listboxes where multiple selected items may be deleted at once. For example: Foreign Keys tab for Table edit.

Suggested fix:
It seems that an array of the selected items in the listview is created and that these are delete one by one. Item c2 has index 1 (0 based?) and item c4 has index 3. First index 1 is deleted, then index 3. However, after the deletion of item c2 with index 1 the items left over get re-indexed and now item c5 has index 3 which is thus deleted.

If the items were selected in the different order first c2 than c4, then the array of indexes seems to be filled with first 3, then 1. Deleting in this order is correct because when the item with index 3 is deleted the index for the item with index 1 does not change.

Fix option 1: Reorder indexes from high to low before deleting.
Fix option 2: while (first selected item index != -1)
{
get first selected item index
delete first selected item index
}
[29 May 2008 12:33] MySQL Verification Team
Thank you for the bug report.
[5 Jun 2008 13:08] Mike Lischke
Fixed in 5.0 (rev 3124)
[6 Jun 2008 10:46] Johannes Taxacher
fixed. will be incorporated in 5.0.23
[10 Jul 2008 8:32] Tony Bedford
An entry has been added to the 5.0.23 changelog:

Incorrect behaviour when editing a table. When the columns tab is selected, if you want to delete multiple selected tables at once, Workbench removes the wrong columns.