46
46
SchemaIdentifier schema_identifier(string(session->lex->name.str, session->lex->name.length));
47
if (not check(schema_identifier))
47
if (not check_db_name(session, schema_identifier))
49
my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
50
53
drizzled::message::init(schema_message, session->lex->name.str);
54
schema_identifier.getSQLPath(path);
56
if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, path)))
56
if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, schema_identifier.getSQLPath())))
58
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
58
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), schema_identifier.getSQLPath().c_str());
62
62
res= mysql_create_db(session, schema_message, is_if_not_exists);
63
if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, path, res)))
63
if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, schema_identifier.getSQLPath(), res)))
65
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
65
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), schema_identifier.getSQLPath().c_str());
74
bool statement::CreateSchema::check(const SchemaIdentifier &identifier)
76
if (not identifier.isValid())
79
if (not plugin::Authorization::isAuthorized(getSession()->getSecurityContext(), identifier))
82
if (not is_if_not_exists)
84
if (plugin::StorageEngine::doesSchemaExist(identifier))
88
identifier.getSQLPath(name);
89
my_error(ER_DB_CREATE_EXISTS, MYF(0), name.c_str());
98
74
// We don't actually test anything at this point, we assume it is all bad.
99
75
bool statement::CreateSchema::validateSchemaOptions()