27
27
#include <drizzled/plugin/event_observer.h>
28
28
#include <drizzled/message.h>
29
29
#include <drizzled/plugin/storage_engine.h>
30
#include <drizzled/sql_lex.h>
31
#include <drizzled/plugin/authorization.h>
40
42
if (not validateSchemaOptions())
43
if (getSession()->inTransaction())
45
if (session().inTransaction())
45
47
my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
49
identifier::Schema schema_identifier(string(getSession()->getLex()->name.str, getSession()->getLex()->name.length));
51
identifier::Schema schema_identifier(string(lex().name.str, lex().name.length));
50
52
if (not check(schema_identifier))
53
drizzled::message::schema::init(schema_message, getSession()->getLex()->name.str);
55
drizzled::message::schema::init(schema_message, lex().name.str);
57
59
schema_identifier.getSQLPath(path);
59
if (unlikely(plugin::EventObserver::beforeCreateDatabase(*getSession(), path)))
61
if (unlikely(plugin::EventObserver::beforeCreateDatabase(session(), path)))
61
63
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
65
res= schema::create(*getSession(), schema_message, getSession()->getLex()->exists());
66
if (unlikely(plugin::EventObserver::afterCreateDatabase(*getSession(), path, res)))
67
res= schema::create(session(), schema_message, lex().exists());
68
if (unlikely(plugin::EventObserver::afterCreateDatabase(session(), path, res)))
68
70
my_error(ER_EVENT_OBSERVER_PLUGIN, schema_identifier);
79
81
if (not identifier.isValid())
82
if (not plugin::Authorization::isAuthorized(*getSession()->user(), identifier))
84
if (not plugin::Authorization::isAuthorized(*session().user(), identifier))
85
if (not getSession()->getLex()->exists())
87
if (not lex().exists())
87
89
if (plugin::StorageEngine::doesSchemaExist(identifier))