00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <drizzled/show.h>
00024 #include <drizzled/session.h>
00025 #include <drizzled/statement/drop_index.h>
00026 #include <drizzled/statement/alter_table.h>
00027 #include <drizzled/plugin/storage_engine.h>
00028 #include <drizzled/open_tables_state.h>
00029
00030 namespace drizzled {
00031
00032 bool statement::DropIndex::execute()
00033 {
00034 TableList *first_table= (TableList *) lex().select_lex.table_list.first;
00035 TableList *all_tables= lex().query_tables;
00036
00037
00038 message::table::shared_ptr original_table_message;
00039 {
00040 identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
00041 if (not (original_table_message= plugin::StorageEngine::getTableMessage(session(), identifier)))
00042 {
00043 my_error(ER_BAD_TABLE_ERROR, identifier);
00044 return true;
00045 }
00046 }
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 HA_CREATE_INFO create_info;
00058
00059 assert(first_table == all_tables && first_table != 0);
00060 if (session().inTransaction())
00061 {
00062 my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
00063 return true;
00064 }
00065
00066 create_info.db_type= 0;
00067
00068 bool res;
00069 if (original_table_message->type() == message::Table::STANDARD )
00070 {
00071 identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
00072
00073 create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
00074
00075 res= alter_table(&session(),
00076 identifier,
00077 identifier,
00078 &create_info,
00079 *original_table_message,
00080 create_table_proto,
00081 first_table,
00082 &alter_info,
00083 0, (Order*) 0, 0);
00084 }
00085 else
00086 {
00087 identifier::Table catch22(first_table->getSchemaName(), first_table->getTableName());
00088 Table *table= session().open_tables.find_temporary_table(catch22);
00089 assert(table);
00090 {
00091 identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName(), table->getShare()->getPath());
00092 create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
00093
00094 res= alter_table(&session(),
00095 identifier,
00096 identifier,
00097 &create_info,
00098 *original_table_message,
00099 create_table_proto,
00100 first_table,
00101 &alter_info,
00102 0, (Order*) 0, 0);
00103 }
00104 }
00105 return res;
00106 }
00107
00108 }