summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2018-05-19 00:26:35 +0300
committerSergei Petrunia <psergey@askmonty.org>2018-05-19 00:26:35 +0300
commitdd51082eca82fe7b61ee2e62f75b84c39f180450 (patch)
tree98c4856b91c3948f249b47bb9357b0620523915c /sql
parent06aaaef51a90cf21f9361ca6901cfc1ab854e5b9 (diff)
downloadmariadb-git-dd51082eca82fe7b61ee2e62f75b84c39f180450.tar.gz
MDEV-12465: Server crashes in my_scan_weight_utf8_bin upon collecting stats for RocksDB table
Apply patch by Oleksandr Byelkin: Do not use "only index read" in analyzing indices if there is a field which present in the index only partially.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_statistics.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 01947462cce..903ebb91d01 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -1801,6 +1801,7 @@ private:
public:
bool is_single_comp_pk;
+ bool is_partial_fields_present;
Index_prefix_calc(THD *thd, TABLE *table, KEY *key_info)
: index_table(table), index_info(key_info)
@@ -1812,7 +1813,7 @@ public:
prefixes= 0;
LINT_INIT_STRUCT(calc_state);
- is_single_comp_pk= FALSE;
+ is_partial_fields_present= is_single_comp_pk= FALSE;
uint pk= table->s->primary_key;
if ((uint) (table->key_info - key_info) == pk &&
table->key_info[pk].user_defined_key_parts == 1)
@@ -1834,7 +1835,10 @@ public:
calculating the values of 'avg_frequency' for prefixes.
*/
if (!key_info->key_part[i].field->part_of_key.is_set(keyno))
+ {
+ is_partial_fields_present= TRUE;
break;
+ }
if (!(state->last_prefix=
new (thd->mem_root) Cached_item_field(thd,
@@ -2633,7 +2637,13 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)
DBUG_RETURN(rc);
}
- table->file->ha_start_keyread(index);
+ /*
+ Request "only index read" in case of absence of fields which are
+ partially in the index to avoid problems with partitioning (for example)
+ which want to get whole field value.
+ */
+ if (!index_prefix_calc.is_partial_fields_present)
+ table->file->ha_start_keyread(index);
table->file->ha_index_init(index, TRUE);
rc= table->file->ha_index_first(table->record[0]);
while (rc != HA_ERR_END_OF_FILE)