Bug #80378 deleting in a table with just an index deletes multiple rows (and hangs)
Submitted: 15 Feb 2016 17:10 Modified: 24 Apr 2018 18:50
Reporter: Fabio Napodano Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S2 (Serious)
Version:6.3.6 OS:Windows (only triaged on Windows 10)
Assigned to: CPU Architecture:Any
Tags: delete, INDEX

[15 Feb 2016 17:10] Fabio Napodano
Description:
When you are using the SQL editor on a table which has no primary jey but has an index on a field, the table should be in readonly mode, but it isn't.

if you then select a row for deletion and click Apply (which should not be possible), then the SQL which will be executed is something like

delete from table_name where index_field = 'value of the field for the row to delete'

which can potentially result into multiple rows being deleted.

however, when I tried to apply this erroenous delete action, Workbench hung and nothing happened, until I terminated the execution

How to repeat:
CREATE TABLE `tmp_giacenza_hw` (
  `COD_RIV` varchar(45) NOT NULL,
  `COD_HW` char(4) NOT NULL,
  `QUANTITA` int(11) NOT NULL DEFAULT '0',
  `ID_TASK` varchar(255) NOT NULL,
  KEY `IDX_TASK` (`ID_TASK`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

select * from tmp_giacenza_hw

mark one row for deletion

apply the changes

Suggested fix:
put this table in read only mode
[15 Feb 2016 21:35] MySQL Verification Team
Thank you for the bug report. Verified as described.
[24 Apr 2018 18:50] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Workbench 8.0.12 release, and here's the changelog entry:

Read-only tables, such as those with an index but no primary key, could be
selected for update. However, the invalid update operation caused MySQL
Workbench to become unresponsive before the operation finished.

Thank you for the bug report.