diff options
author | Igor Babaev <igor@askmonty.org> | 2012-05-22 20:55:07 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2012-05-22 20:55:07 -0700 |
commit | 055477ae522b805d3b2e890af9fe520cc1e3290d (patch) | |
tree | 6f45830161e7fa5f2a690046fc6f118f9331b3b2 /sql/sql_admin.cc | |
parent | 2a1afc29f252fb189f6e93a2e0d3a1939f8220d5 (diff) | |
download | mariadb-git-055477ae522b805d3b2e890af9fe520cc1e3290d.tar.gz |
Support of the extended syntax for ANALYZE.
Diffstat (limited to 'sql/sql_admin.cc')
-rw-r--r-- | sql/sql_admin.cc | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index c2d06a149e8..4e2581b885c 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -27,6 +27,7 @@ #include "sql_acl.h" // *_ACL #include "sp.h" // Sroutine_hash_entry #include "sql_parse.h" // check_table_access +#include "strfunc.h" #include "sql_admin.h" /* Prepare, run and cleanup for mysql_recreate_table() */ @@ -628,16 +629,75 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, } } - result_code= compl_result_code= 0; - if (operator_func != &handler::ha_analyze || - thd->variables.optimizer_use_stat_tables < 3) + result_code= compl_result_code= HA_ADMIN_OK; + + if (operator_func == &handler::ha_analyze) + { + TABLE *tab= table->table; + Field **field_ptr= tab->field; + + if (!lex->column_list) + { + uint fields= 0; + for ( ; *field_ptr; field_ptr++, fields++) ; + bitmap_set_prefix(tab->read_set, fields); + } + else + { + int pos; + LEX_STRING *column_name; + List_iterator_fast<LEX_STRING> it(*lex->column_list); + + bitmap_clear_all(tab->read_set); + while ((column_name= it++)) + { + if (tab->s->fieldnames.type_names == 0 || + (pos= find_type(&tab->s->fieldnames, column_name->str, + column_name->length, 1)) <= 0) + { + compl_result_code= result_code= HA_ADMIN_INVALID; + break; + } + bitmap_set_bit(tab->read_set, --pos); + } + } + + if (!lex->index_list) + { + tab->keys_in_use_for_query.init(tab->s->keys); + } + else + { + int pos; + LEX_STRING *index_name; + List_iterator_fast<LEX_STRING> it(*lex->index_list); + + tab->keys_in_use_for_query.clear_all(); + while ((index_name= it++)) + { + if (tab->s->keynames.type_names == 0 || + (pos= find_type(&tab->s->keynames, index_name->str, + index_name->length, 1)) <= 0) + { + compl_result_code= result_code= HA_ADMIN_INVALID; + break; + } + tab->keys_in_use_for_query.set_bit(--pos); + } + } + } + + if (result_code == HA_ADMIN_OK && + (operator_func != &handler::ha_analyze || + thd->variables.optimizer_use_stat_tables < 3)) { DBUG_PRINT("admin", ("calling operator_func '%s'", operator_name)); result_code = (table->table->file->*operator_func)(thd, check_opt); DBUG_PRINT("admin", ("operator_func returned: %d", result_code)); } - if (operator_func == &handler::ha_analyze && opt_with_stat_tables && + if (compl_result_code == HA_ADMIN_OK && + operator_func == &handler::ha_analyze && opt_with_stat_tables && thd->variables.optimizer_use_stat_tables > 0) { if (!(compl_result_code= |