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
00029 namespace drizzled {
00030
00031 bool statement::DropIndex::execute()
00032 {
00033 TableList *first_table= (TableList *) lex().select_lex.table_list.first;
00034 TableList *all_tables= lex().query_tables;
00035
00036
00037 message::table::shared_ptr original_table_message;
00038 {
00039 identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
00040 if (not (original_table_message= plugin::StorageEngine::getTableMessage(session(), identifier)))
00041 {
00042 my_error(ER_BAD_TABLE_ERROR, identifier);
00043 return true;
00044 }
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 HA_CREATE_INFO create_info;
00057
00058 assert(first_table == all_tables && first_table != 0);
00059 if (session().inTransaction())
00060 {
00061 my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
00062 return true;
00063 }
00064
00065 create_info.db_type= 0;
00066
00067 bool res;
00068 if (original_table_message->type() == message::Table::STANDARD )
00069 {
00070 identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
00071
00072 create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
00073
00074 res= alter_table(&session(),
00075 identifier,
00076 identifier,
00077 &create_info,
00078 *original_table_message,
00079 create_table_proto,
00080 first_table,
00081 &alter_info,
00082 0, (Order*) 0, 0);
00083 }
00084 else
00085 {
00086 identifier::Table catch22(first_table->getSchemaName(), first_table->getTableName());
00087 Table *table= session().find_temporary_table(catch22);
00088 assert(table);
00089 {
00090 identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName(), table->getShare()->getPath());
00091 create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
00092
00093 res= alter_table(&session(),
00094 identifier,
00095 identifier,
00096 &create_info,
00097 *original_table_message,
00098 create_table_proto,
00099 first_table,
00100 &alter_info,
00101 0, (Order*) 0, 0);
00102 }
00103 }
00104 return res;
00105 }
00106
00107 }