From fd7059d20859863a146cd306b88ac6e9817622fd Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 18 Aug 2012 22:18:46 -0700 Subject: [PATCH] Fixed the following problem: the syntax of the ANALYZE command did not returned an error if the list of the specified index names contained the name 'primary'. --- mysql-test/r/statistics.result | 19 +++++++++++++++++++ mysql-test/t/statistics.test | 5 +++++ sql/sql_yacc.yy | 29 ++++++++++++++++++----------- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/statistics.result b/mysql-test/r/statistics.result index 680712e5f4a..5a163ca3f84 100644 --- a/mysql-test/r/statistics.result +++ b/mysql-test/r/statistics.result @@ -893,6 +893,25 @@ test t1 idx2 2 2.3846 test t1 idx4 1 6.2000 test t1 idx4 2 1.6875 test t1 idx4 3 1.1304 +DELETE FROM mysql.index_stat WHERE table_name='t1' AND index_name='primary'; +SELECT * FROM mysql.index_stat; +db_name table_name index_name prefix_arity avg_frequency +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES(primary); +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +SELECT * FROM mysql.index_stat; +db_name table_name index_name prefix_arity avg_frequency +test t1 idx2 1 7.0000 +test t1 idx2 2 2.3846 +test t1 idx4 1 6.2000 +test t1 idx4 2 1.6875 +test t1 idx4 3 1.1304 +test t1 PRIMARY 1 1.0000 DELETE FROM mysql.table_stat; DELETE FROM mysql.column_stat; DELETE FROM mysql.index_stat; diff --git a/mysql-test/t/statistics.test b/mysql-test/t/statistics.test index 903cf27648c..30aa335e42d 100644 --- a/mysql-test/t/statistics.test +++ b/mysql-test/t/statistics.test @@ -353,6 +353,11 @@ SELECT * FROM mysql.table_stat; SELECT * FROM mysql.column_stat; SELECT * FROM mysql.index_stat; +DELETE FROM mysql.index_stat WHERE table_name='t1' AND index_name='primary'; +SELECT * FROM mysql.index_stat; +ANALYZE TABLE t1 PERSISTENT FOR COLUMNS() INDEXES(primary); +SELECT * FROM mysql.index_stat; + DELETE FROM mysql.table_stat; DELETE FROM mysql.column_stat; DELETE FROM mysql.index_stat; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e2d2b1cac84..13c6cd3aded 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1597,7 +1597,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); analyze_table_list analyze_table_elem_spec opt_persistent_stat_clause persistent_stat_spec persistent_column_stat_spec persistent_index_stat_spec - table_column_list table_index_list + table_column_list table_index_list table_index_name check start checksum field_list field_list_item field_spec kill column_def key_def keycache_list keycache_list_or_parts assign_to_keycache @@ -7312,18 +7312,25 @@ table_column_list: table_index_list: /* empty */ {} - | ident - { - Lex->index_list->push_back((LEX_STRING*) - sql_memdup(&$1, sizeof(LEX_STRING))); - } - | table_index_list ',' ident - { - Lex->index_list->push_back((LEX_STRING*) - sql_memdup(&$3, sizeof(LEX_STRING))); - } + | table_index_name + | table_index_list ',' table_index_name ; +table_index_name: + ident + { + Lex->index_list->push_back( + (LEX_STRING*) sql_memdup(&$1, sizeof(LEX_STRING))); + } + | + PRIMARY_SYM + { + LEX_STRING str= {(char*) "PRIMARY", 7}; + Lex->index_list->push_back( + (LEX_STRING*) sql_memdup(&str, sizeof(LEX_STRING))); + } + ; + binlog_base64_event: BINLOG_SYM TEXT_STRING_sys {