24 #include <drizzled/session.h>
25 #include <drizzled/statement/drop_schema.h>
26 #include <drizzled/plugin/event_observer.h>
27 #include <drizzled/sql_lex.h>
28 #include <drizzled/schema.h>
29 #include <drizzled/catalog/instance.h>
37 bool statement::DropSchema::execute()
39 if (session().inTransaction())
41 my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
46 to_string(lex().name));
48 if (not schema::check(session(), schema_identifier))
50 my_error(ER_WRONG_DB_NAME, schema_identifier);
54 if (session().inTransaction())
56 my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
61 std::string path = schema_identifier.getSQLPath();
62 if (unlikely(plugin::EventObserver::beforeDropDatabase(session(), path)))
64 my_error(ER_EVENT_OBSERVER_PLUGIN, schema_identifier);
68 res= schema::drop(session(), schema_identifier, drop_if_exists);
69 if (unlikely(plugin::EventObserver::afterDropDatabase(session(), path, res)))
71 my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
TODO: Rename this file - func.h is stupid.