summaryrefslogtreecommitdiff
path: root/sql/sql_statistics.cc
diff options
context:
space:
mode:
authorGalina Shalygina <galina.shalygina@mariadb.com>2018-06-01 21:57:10 +0200
committerGalina Shalygina <galina.shalygina@mariadb.com>2018-06-01 21:57:10 +0200
commit6db465d7ce455cf75ec224108cbe61ca8be63d3d (patch)
tree9648ff1fc677eebb60b278c2e2c13131934ed2a0 /sql/sql_statistics.cc
parentffe83e8e7bef32eb2a80aad2d382f0b023dd3a44 (diff)
parent4a49f7f88cfa82ae6eb8e7b5a528e91416b33b52 (diff)
downloadmariadb-git-shagalla-10.4.tar.gz
Merge 10.3.7 into 10.4shagalla-10.4
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r--sql/sql_statistics.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index e62a49f71ea..92c019d3f1b 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -1799,6 +1799,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)
@@ -1810,7 +1811,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)
@@ -1832,7 +1833,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,
@@ -2617,7 +2621,7 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index)
DBUG_ENTER("collect_statistics_for_index");
/* No statistics for FULLTEXT indexes. */
- if (key_info->flags & HA_FULLTEXT)
+ if (key_info->flags & (HA_FULLTEXT|HA_SPATIAL))
DBUG_RETURN(rc);
Index_prefix_calc index_prefix_calc(thd, table, key_info);
@@ -2631,7 +2635,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)
@@ -2743,11 +2753,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
break;
if (rc)
- {
- if (rc == HA_ERR_RECORD_DELETED)
- continue;
break;
- }
for (field_ptr= table->field; *field_ptr; field_ptr++)
{
@@ -3990,11 +3996,11 @@ bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table)
{
DBUG_ASSERT(db->str && table->str);
- if (!cmp(db, &MYSQL_SCHEMA_NAME))
+ if (!my_strcasecmp(table_alias_charset, db->str, MYSQL_SCHEMA_NAME.str))
{
for (uint i= 0; i < STATISTICS_TABLES; i ++)
{
- if (cmp(table, &stat_table_name[i]) == 0)
+ if (!my_strcasecmp(table_alias_charset, table->str, stat_table_name[i].str))
return true;
}
}