summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2003-03-13 23:10:50 +0200
committerunknown <heikki@hundin.mysql.fi>2003-03-13 23:10:50 +0200
commit11881c42890a8c22ba9cb5ee68d4240abad5c4e9 (patch)
treef38b9fa57d216e70508926e7b83947161c02f074
parentae01a3533b67811b335ce0dc877db3ea4568dd26 (diff)
downloadmariadb-git-11881c42890a8c22ba9cb5ee68d4240abad5c4e9.tar.gz
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
-rw-r--r--sql/ha_innobase.cc10
1 files changed, 10 insertions, 0 deletions
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);
}