Commit e7c592d
committed
BUG#31360522 : >=5.6.36 SOME RANGE QUERIES STILL CRASH...
DESCRIPTION:
============
Certain range queries on a table with index prefixed
BLOB/TEXT columns could lead to a server exit.
ANALYSIS:
=========
While opening the table based on its table share, in
open_table_from_share(), we create a copy of the key_info
from TABLE_SHARE object to TABLE object. If the key is
prefixed, we allocate a new Field object, having its
field_length set to the prefix key length, and point the
table's matching key_part->field to this new Field object.
We skip creating the new Field object for prefixed BLOB
columns.
A secondary key is extended by adding primary key parts to
it if the primary key part does not exist in the secondary
key or the key part in the secondary key is a prefix of the
key field (add_pk_parts_to_sk()). The consequence of
skipping the creation of new Field object for prefixed BLOB
columns is that the key parts from the secondary key and
primary key will be pointing to the same Field object.
Later, while performing end-range scan, we check if the key
is within range (compare_key_in_buffer()). We change the
offsets of all the fields in the key range to make the
fields point to the record buffer
(move_key_field_offsets()). In case of BLOBs, we end up
moving the same field twice in move_key_field_offsets().
This leads to accessing out of bound memory while performing
key comparison.
FIX:
====
We allow creating new Field object even for BLOB columns in
open_table_from_share().
Note:
=====
This issue is not a regression but rather was exposed in
5.6.36 by the patch for Bug#23481444: OPTIMISER CALL
ROW_SEARCH_MVCC() AND READ THE INDEX APPLIED BY UNCOMMITTED
ROWS.
Change-Id: I407dec8a997de2c51ebf62351351288beb7dde5e1 parent 4c5e1f1 commit e7c592d
2 files changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
834 | 834 | | |
835 | 835 | | |
836 | 836 | | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
837 | 843 | | |
838 | 844 | | |
839 | 845 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3241 | 3241 | | |
3242 | 3242 | | |
3243 | 3243 | | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
3244 | 3251 | | |
3245 | | - | |
| 3252 | + | |
3246 | 3253 | | |
3247 | 3254 | | |
3248 | 3255 | | |
| |||
0 commit comments