diff --git a/mysql-test/suite/innodb/r/innodb_bug57252.result b/mysql-test/suite/innodb/r/innodb_bug57252.result index 2e371cb74ee..66183c2c42d 100644 --- a/mysql-test/suite/innodb/r/innodb_bug57252.result +++ b/mysql-test/suite/innodb/r/innodb_bug57252.result @@ -1,5 +1,5 @@ cardinality -10 +2 Table Op Msg_type Msg_text test.bug57252 analyze status Engine-independent statistics collected test.bug57252 analyze status OK diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 718ed4218f1..60d3578e680 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2530,7 +2530,7 @@ static void store_key_options(THD *thd, String *packet, TABLE *table, packet->append(STRING_WITH_LEN(" USING BTREE")); if (key_info->algorithm == HA_KEY_ALG_HASH || - key_info->algorithm == HA_KEY_ALG_LONG_HASH) + key_info->algorithm == HA_KEY_ALG_LONG_HASH) packet->append(STRING_WITH_LEN(" USING HASH")); /* send USING only in non-default case: non-spatial rtree */ @@ -6636,6 +6636,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, { show_table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | + HA_STATUS_CONST | HA_STATUS_TIME); set_statistics_for_table(thd, show_table); } @@ -6670,18 +6671,23 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, "D" : "A"), 1, cs); table->field[8]->set_notnull(); } - KEY *key=show_table->key_info+i; - if (key->rec_per_key[j] && key->algorithm != HA_KEY_ALG_LONG_HASH) - { - ha_rows records= (ha_rows) ((double) show_table->stat_records() / - key->actual_rec_per_key(j)); - table->field[9]->store((longlong) records, TRUE); - table->field[9]->set_notnull(); - } - if (key->algorithm == HA_KEY_ALG_LONG_HASH) + if (key_info->algorithm == HA_KEY_ALG_LONG_HASH) table->field[13]->store(STRING_WITH_LEN("HASH"), cs); else { + /* + We have to use table key information to get the key statistics + from table as key_info points to TABLE_SHARE which has no + statistics. + */ + KEY *key_info= show_table->key_info + i; + if (key_info->rec_per_key[j]) + { + ha_rows records= (ha_rows) ((double) show_table->stat_records() / + key_info->actual_rec_per_key(j)); + table->field[9]->store((longlong) records, TRUE); + table->field[9]->set_notnull(); + } const char *tmp= show_table->file->index_type(i); table->field[13]->store(tmp, strlen(tmp), cs); } diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1_pick.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1_pick.result index 33c60935952..f92bc361547 100644 --- a/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1_pick.result +++ b/storage/tokudb/mysql-test/tokudb_bugs/r/db756_card_part_hash_1_pick.result @@ -20,6 +20,6 @@ test.t analyze status OK show indexes from t; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment t 0 PRIMARY 1 id A 7 NULL NULL BTREE -t 1 x 1 x A 7 NULL NULL YES BTREE +t 1 x 1 x A 3 NULL NULL YES BTREE set @@use_stat_tables = @save_use_stat_tables; drop table t;