46
45
SchemaIdentifier schema_identifier(string(session->lex->name.str, session->lex->name.length));
47
if (not check(schema_identifier))
46
if (not check_db_name(session, schema_identifier))
48
my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
50
drizzled::message::init(schema_message, session->lex->name.str);
52
schema_message.set_name(session->lex->name.str);
53
schema_message.mutable_engine()->set_name(std::string("filesystem")); // For the moment we have only one.
54
if (not schema_message.has_collation())
56
schema_message.set_collation(default_charset_info->name);
54
schema_identifier.getSQLPath(path);
56
if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, path)))
60
if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, schema_identifier.getSQLPath())))
58
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
62
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), schema_identifier.getSQLPath().c_str());
62
66
res= mysql_create_db(session, schema_message, is_if_not_exists);
63
if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, path, res)))
67
if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, schema_identifier.getSQLPath(), res)))
65
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
69
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
78
// We don't actually test anything at this point, we assume it is all bad.
99
79
bool statement::CreateSchema::validateSchemaOptions()