opt_range.cc:

  Fix the crash in InnoDB when WHERE primarykey < x ORDER BY primarykey is used
parent 5fcc80ff
...@@ -2623,13 +2623,19 @@ int QUICK_SELECT_DESC::get_next() ...@@ -2623,13 +2623,19 @@ int QUICK_SELECT_DESC::get_next()
} }
else else
{ {
/* Heikki changed Sept 11, 2002: since InnoDB does not store the cursor
position if READ_KEY_EXACT is used to a primary key with all
key columns specified, we must use below HA_READ_KEY_OR_NEXT,
so that InnoDB stores the cursor position and is able to move
the cursor one step backward after the search. */
DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range)); DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range));
/* Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will /* Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will
* do the right thing - go past all keys which match the prefix */ * do the right thing - go past all keys which match the prefix */
result=file->index_read(record, (byte*) range->max_key, result=file->index_read(record, (byte*) range->max_key,
range->max_length, range->max_length,
((range->flag & NEAR_MAX) ? ((range->flag & NEAR_MAX) ?
HA_READ_KEY_EXACT : HA_READ_AFTER_KEY)); HA_READ_KEY_OR_NEXT : HA_READ_AFTER_KEY));
result = file->index_prev(record); result = file->index_prev(record);
} }
if (result) if (result)
......
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