From 11881c42890a8c22ba9cb5ee68d4240abad5c4e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Mar 2003 23:10:50 +0200 Subject: ha_innobase.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_innobase.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_innobase.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 5b2af70f34e..c0aea197b1f 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -3098,6 +3098,16 @@ ha_innobase::records_in_range( my_free((char*) key_val_buff2, MYF(0)); + /* 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); } -- cgit v1.2.1