Commit faad6382 authored by unknown's avatar unknown

dict0dict.h, dict0dict.c, ha_innodb.cc:

  In ORDER BY MySQL seems to set the key read flag also in the case where the primary key contains only a prefix of a column - not the whole column; to prevent potential bugs retrieve the whole column if the index contains a prefix of it


sql/ha_innodb.cc:
  In ORDER BY MySQL seems to set the key read flag also in the case where the primary key contains only a prefix of a column - not the whole column; to prevent potential bugs retrieve the whole column if the index contains a prefix of it
innobase/dict/dict0dict.c:
  In ORDER BY MySQL seems to set the key read flag also in the case where the primary key contains only a prefix of a column - not the whole column; to prevent potential bugs retrieve the whole column if the index contains a prefix of it
innobase/include/dict0dict.h:
  In ORDER BY MySQL seems to set the key read flag also in the case where the primary key contains only a prefix of a column - not the whole column; to prevent potential bugs retrieve the whole column if the index contains a prefix of it
parent 2de08709
Branches unavailable
Tags unavailable
No related merge requests found
...@@ -494,6 +494,46 @@ dict_index_get_nth_col_pos( ...@@ -494,6 +494,46 @@ dict_index_get_nth_col_pos(
return(ULINT_UNDEFINED); return(ULINT_UNDEFINED);
} }
/************************************************************************
Returns TRUE if the index contains a column or a prefix of that column. */
ibool
dict_index_contains_col_or_prefix(
/*==============================*/
/* out: TRUE if contains the column or its
prefix */
dict_index_t* index, /* in: index */
ulint n) /* in: column number */
{
dict_field_t* field;
dict_col_t* col;
ulint pos;
ulint n_fields;
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
if (index->type & DICT_CLUSTERED) {
return(TRUE);
}
col = dict_table_get_nth_col(index->table, n);
n_fields = dict_index_get_n_fields(index);
for (pos = 0; pos < n_fields; pos++) {
field = dict_index_get_nth_field(index, pos);
if (col == field->col) {
return(TRUE);
}
}
return(FALSE);
}
/************************************************************************ /************************************************************************
Looks for a matching field in an index. The column and the prefix len have Looks for a matching field in an index. The column and the prefix len have
to be the same. */ to be the same. */
......
...@@ -569,6 +569,16 @@ dict_index_get_nth_col_pos( ...@@ -569,6 +569,16 @@ dict_index_get_nth_col_pos(
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
ulint n); /* in: column number */ ulint n); /* in: column number */
/************************************************************************ /************************************************************************
Returns TRUE if the index contains a column or a prefix of that column. */
ibool
dict_index_contains_col_or_prefix(
/*==============================*/
/* out: TRUE if contains the column or its
prefix */
dict_index_t* index, /* in: index */
ulint n); /* in: column number */
/************************************************************************
Looks for a matching field in an index. The column and the prefix len has Looks for a matching field in an index. The column and the prefix len has
to be the same. */ to be the same. */
......
...@@ -1863,7 +1863,11 @@ build_template( ...@@ -1863,7 +1863,11 @@ build_template(
if (prebuilt->read_just_key) { if (prebuilt->read_just_key) {
/* MySQL has instructed us that it is enough to /* MySQL has instructed us that it is enough to
fetch the columns in the key */ fetch the columns in the key; looks like MySQL
can set this flag also when there is only a
prefix of the column in the key: in that case we
retrieve the whole column from the clustered
index */
fetch_all_in_key = TRUE; fetch_all_in_key = TRUE;
} else { } else {
...@@ -1924,9 +1928,8 @@ build_template( ...@@ -1924,9 +1928,8 @@ build_template(
field = table->field[i]; field = table->field[i];
if (templ_type == ROW_MYSQL_REC_FIELDS if (templ_type == ROW_MYSQL_REC_FIELDS
&& !(fetch_all_in_key && && !(fetch_all_in_key
ULINT_UNDEFINED != dict_index_get_nth_col_pos( && dict_index_contains_col_or_prefix(index, i))
index, i))
&& thd->query_id != field->query_id && thd->query_id != field->query_id
&& thd->query_id != (field->query_id ^ MAX_ULONG_BIT) && thd->query_id != (field->query_id ^ MAX_ULONG_BIT)
&& thd->query_id != && thd->query_id !=
......
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