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>
36 bool statement::DropSchema::execute()
38 if (session().inTransaction())
40 my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
46 if (not schema::check(session(), schema_identifier))
48 my_error(ER_WRONG_DB_NAME, schema_identifier);
52 if (session().inTransaction())
54 my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
59 std::string path = schema_identifier.getSQLPath();
60 if (unlikely(plugin::EventObserver::beforeDropDatabase(session(), path)))
62 my_error(ER_EVENT_OBSERVER_PLUGIN, schema_identifier);
66 res= schema::drop(session(), schema_identifier, drop_if_exists);
67 if (unlikely(plugin::EventObserver::afterDropDatabase(session(), path, res)))
69 my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());