From f127e2120c08f88550041d5a0d0f9c47f391f16c Mon Sep 17 00:00:00 2001 From: Rich Prohaska Date: Sat, 8 Nov 2014 10:36:33 -0500 Subject: [PATCH] DB-757 compute cardinality when alter table analyze partition is run --- .../r/db757_part_alter_analyze.result | 50 +++++++++++++++++++ .../t/db757_part_alter_analyze.test | 26 ++++++++++ storage/tokudb/ha_tokudb_admin.cc | 2 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/tokudb.bugs/r/db757_part_alter_analyze.result create mode 100644 mysql-test/suite/tokudb.bugs/t/db757_part_alter_analyze.test diff --git a/mysql-test/suite/tokudb.bugs/r/db757_part_alter_analyze.result b/mysql-test/suite/tokudb.bugs/r/db757_part_alter_analyze.result new file mode 100644 index 00000000000..d80e3e4eac8 --- /dev/null +++ b/mysql-test/suite/tokudb.bugs/r/db757_part_alter_analyze.result @@ -0,0 +1,50 @@ +set default_storage_engine='tokudb'; +drop table if exists t; +create table t (id int, x int, y int, primary key (id), key (x), key (y)) +partition by range(id) +( partition p0 values less than (10), partition p1 values less than maxvalue); +insert into t values (1,1,1),(2,1,2),(3,1,3),(4,1,4); +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 5 NULL NULL BTREE +t 1 x 1 x A NULL NULL NULL YES BTREE +t 1 y 1 y A NULL NULL NULL YES BTREE +alter table t analyze partition p0; +Table Op Msg_type Msg_text +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 5 NULL NULL BTREE +t 1 x 1 x A 1 NULL NULL YES BTREE +t 1 y 1 y A 5 NULL NULL YES BTREE +alter table t analyze partition p1; +Table Op Msg_type Msg_text +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 5 NULL NULL BTREE +t 1 x 1 x A 1 NULL NULL YES BTREE +t 1 y 1 y A 5 NULL NULL YES BTREE +insert into t values (100,1,1),(200,2,1),(300,3,1),(400,4,1),(500,5,1); +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 9 NULL NULL BTREE +t 1 x 1 x A 2 NULL NULL YES BTREE +t 1 y 1 y A 9 NULL NULL YES BTREE +alter table t analyze partition p0; +Table Op Msg_type Msg_text +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 9 NULL NULL BTREE +t 1 x 1 x A NULL NULL NULL YES BTREE +t 1 y 1 y A NULL NULL NULL YES BTREE +alter table t analyze partition p1; +Table Op Msg_type Msg_text +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 9 NULL NULL BTREE +t 1 x 1 x A 9 NULL NULL YES BTREE +t 1 y 1 y A 1 NULL NULL YES BTREE +drop table t; diff --git a/mysql-test/suite/tokudb.bugs/t/db757_part_alter_analyze.test b/mysql-test/suite/tokudb.bugs/t/db757_part_alter_analyze.test new file mode 100644 index 00000000000..fc1599591be --- /dev/null +++ b/mysql-test/suite/tokudb.bugs/t/db757_part_alter_analyze.test @@ -0,0 +1,26 @@ +source include/have_tokudb.inc; +source include/have_partition.inc; +set default_storage_engine='tokudb'; +disable_warnings; +drop table if exists t; +enable_warnings; + +create table t (id int, x int, y int, primary key (id), key (x), key (y)) +partition by range(id) +( partition p0 values less than (10), partition p1 values less than maxvalue); + +insert into t values (1,1,1),(2,1,2),(3,1,3),(4,1,4); +show indexes from t; +alter table t analyze partition p0; +show indexes from t; +alter table t analyze partition p1; +show indexes from t; + +insert into t values (100,1,1),(200,2,1),(300,3,1),(400,4,1),(500,5,1); +show indexes from t; +alter table t analyze partition p0; +show indexes from t; +alter table t analyze partition p1; +show indexes from t; + +drop table t; diff --git a/storage/tokudb/ha_tokudb_admin.cc b/storage/tokudb/ha_tokudb_admin.cc index 8fe17e1dfca..c3b895bf4f4 100644 --- a/storage/tokudb/ha_tokudb_admin.cc +++ b/storage/tokudb/ha_tokudb_admin.cc @@ -133,7 +133,7 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) { int result = HA_ADMIN_OK; // stub out analyze if optimize is remapped to alter recreate + analyze - if (thd_sql_command(thd) != SQLCOM_ANALYZE) { + if (thd_sql_command(thd) != SQLCOM_ANALYZE && thd_sql_command(thd) != SQLCOM_ALTER_TABLE) { TOKUDB_HANDLER_DBUG_RETURN(result); }