Commit f9272676 authored by unknown's avatar unknown

ha_innodb.cc:

  Fix bug: MySQL could erroneously return Empty set if InnoDB estimated index range size to 0 records though the range was not empty; MySQL also failed to do the next-key locking in the case of an empty index range


sql/ha_innodb.cc:
  Fix bug: MySQL could erroneously return Empty set if InnoDB estimated index range size to 0 records though the range was not empty; MySQL also failed to do the next-key locking in the case of an empty index range
parent 5a667a50
...@@ -3486,6 +3486,16 @@ ha_innobase::records_in_range( ...@@ -3486,6 +3486,16 @@ ha_innobase::records_in_range(
prebuilt->trx->op_info = (char*)""; prebuilt->trx->op_info = (char*)"";
/* The MySQL optimizer seems to believe an estimate of 0 rows is
always accurate and may return the result 'Empty set' based on that.
The accuracy is not guaranteed, and even if it were, for a locking
read we should anyway perform the search to set the next-key lock.
Add 1 to the value to make sure MySQL does not make the assumption! */
if (n_rows == 0) {
n_rows = 1;
}
DBUG_RETURN((ha_rows) n_rows); DBUG_RETURN((ha_rows) n_rows);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment