36
34
bool statement::CreateSchema::execute()
38
if (not validateSchemaOptions())
41
36
if (not session->endActiveTransaction())
46
SchemaIdentifier schema_identifier(string(session->lex->name.str, session->lex->name.length));
47
if (not check(schema_identifier))
41
if (check_db_name(&session->lex->name))
43
my_error(ER_WRONG_DB_NAME, MYF(0), session->lex->name.str);
50
drizzled::message::init(schema_message, session->lex->name.str);
54
schema_identifier.getSQLPath(path);
56
if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, path)))
58
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
62
res= mysql_create_db(session, schema_message, is_if_not_exists);
63
if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, path, res)))
65
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
47
schema_message.set_name(session->lex->name.str);
48
if (not schema_message.has_collation())
50
schema_message.set_collation(default_charset_info->name);
53
bool res= mysql_create_db(session, schema_message, is_if_not_exists);
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
// We don't actually test anything at this point, we assume it is all bad.
99
bool statement::CreateSchema::validateSchemaOptions()
101
size_t num_engine_options= schema_message.engine().options_size();
102
bool rc= num_engine_options ? false : true;
104
for (size_t y= 0; y < num_engine_options; ++y)
106
my_error(ER_UNKNOWN_SCHEMA_OPTION, MYF(0),
107
schema_message.engine().options(y).name().c_str(),
108
schema_message.engine().options(y).state().c_str());
116
57
} /* namespace drizzled */