From 1d0acc7754a44613d2ad56dc2231f20a1bedf718 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Tue, 25 May 2010 18:43:45 +0400 Subject: Bug #53830: !table || (!table->read_set || bitmap_is_set(table->read_set, field_index)) UPDATE on an InnoDB table modifying the same index that is used to satisfy the WHERE condition could trigger a debug assertion under some circumstances. Since for engines with the HA_PRIMARY_KEY_IN_READ_INDEX flag set results of an index scan on a secondary index are appended by the primary key value, if a query involves only columns from the primary key and a secondary index, the latter is considered to be covering. That tricks mysql_update() to mark for reading only columns from the secondary index when it does an index scan to retrieve rows to update in case a part of that key is also being updated. However, there may be other columns in WHERE that are part of the primary key, but not the secondary one. What we actually want to do in this case is to add index columns to the existing WHERE columns bitmap rather than replace it. mysql-test/r/innodb_mysql.result: Test case for bug #53830. mysql-test/t/innodb_mysql.test: Test case for bug #53830. sql/sql_update.cc: Add index columns to the read_set bitmap, don't replace it. sql/table.cc: Added a new add_read_columns_used_by_index() function to st_table. sql/table.h: Added a new add_read_columns_used_by_index() function to st_table. --- sql/table.h | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/table.h') diff --git a/sql/table.h b/sql/table.h index bddb0731625..4125c252427 100644 --- a/sql/table.h +++ b/sql/table.h @@ -865,6 +865,7 @@ struct st_table { void prepare_for_position(void); void mark_columns_used_by_index_no_reset(uint index, MY_BITMAP *map); void mark_columns_used_by_index(uint index); + void add_read_columns_used_by_index(uint index); void restore_column_maps_after_mark_index(); void mark_auto_increment_column(void); void mark_columns_needed_for_update(void); -- cgit v1.2.1