From 511a166d559c37ca7a1f03234db2cbf11bf04a10 Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Sat, 5 Feb 2005 06:23:23 +0300 Subject: [PATCH] Fix for BUG#7519: Index statistics is not displayed after ANALYZE for temporary tables: Call file->extra() with HA_STATUS_CONST in mysqld_show_keys. The fix will not be merged into 4.1/5.0 because they don't have this problem already. --- mysql-test/r/show_check.result | 22 ++++++++++++++++++++++ mysql-test/t/show_check.test | 16 ++++++++++++++++ sql/sql_show.cc | 3 ++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index f40b0693585..6d23dde1f1b 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -233,3 +233,25 @@ c decimal(4,3) YES NULL d double(4,3) YES NULL f float(4,3) YES NULL drop table t1; +CREATE TABLE t1 ( a VARCHAR(20) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +CREATE TEMPORARY TABLE t2 ( index (a(20)) ) SELECT a FROM t1 GROUP BY a; +SHOW INDEX FROM t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 X a X X X NULL X X X BTREE +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SHOW INDEX FROM t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 X a X X X 5 X X X BTREE +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `a` varchar(20) default NULL, + KEY `a` (`a`) +) TYPE=MyISAM +SHOW INDEX FROM t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 X a X X X 5 X X X BTREE +DROP TEMPORARY TABLE t2; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 2cd2012d109..e712ed77f04 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -131,3 +131,19 @@ drop table t1; create table t1 (c decimal(3,3), d double(3,3), f float(3,3)); show columns from t1; drop table t1; + +# Fix for BUG#7519: For temporary tables, SHOW INDEX doesn't display index +# cardinality after ANALYZE. +CREATE TABLE t1 ( a VARCHAR(20) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +CREATE TEMPORARY TABLE t2 ( index (a(20)) ) SELECT a FROM t1 GROUP BY a; +--replace_column 2 X 4 X 5 X 6 X 8 X 9 X 10 X +SHOW INDEX FROM t2; +ANALYZE TABLE t2; +--replace_column 2 X 4 X 5 X 6 X 8 X 9 X 10 X +SHOW INDEX FROM t2; +SHOW CREATE TABLE t2; +--replace_column 2 X 4 X 5 X 6 X 8 X 9 X 10 X +SHOW INDEX FROM t2; +DROP TEMPORARY TABLE t2; + diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2506033cda5..27246729162 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -686,7 +686,8 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) String *packet= &thd->packet; KEY *key_info=table->key_info; - table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); + table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME | + HA_STATUS_CONST); for (uint i=0 ; i < table->keys ; i++,key_info++) { KEY_PART_INFO *key_part= key_info->key_part;