~drizzle-developers/drizzle/elliott-release

« back to all changes in this revision

Viewing changes to drizzled/statement/create_schema.cc

  • Committer: Patrick Crews
  • Date: 2011-02-01 20:33:06 UTC
  • mfrom: (1845.2.288 drizzle)
  • Revision ID: gleebix@gmail.com-20110201203306-mwq2rk0it81tlwxh
Merged Trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
  if (not validateSchemaOptions())
39
39
    return true;
40
40
 
41
 
  if (not session->endActiveTransaction())
 
41
  if (getSession()->inTransaction())
42
42
  {
 
43
    my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
43
44
    return true;
44
45
  }
45
46
 
46
 
  identifier::Schema schema_identifier(string(session->lex->name.str, session->lex->name.length));
 
47
  identifier::Schema schema_identifier(string(getSession()->lex->name.str, getSession()->lex->name.length));
47
48
  if (not check(schema_identifier))
48
49
    return false;
49
50
 
50
 
  drizzled::message::schema::init(schema_message, session->lex->name.str);
 
51
  drizzled::message::schema::init(schema_message, getSession()->lex->name.str);
51
52
 
52
53
  bool res = false;
53
54
  std::string path;
54
55
  schema_identifier.getSQLPath(path);
55
56
 
56
 
  if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, path)))
 
57
  if (unlikely(plugin::EventObserver::beforeCreateDatabase(*getSession(), path)))
57
58
  {
58
59
    my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
59
60
  }
60
61
  else
61
62
  {
62
 
    res= create_db(session, schema_message, session->getLex()->exists());
63
 
    if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, path, res)))
 
63
    res= create_db(getSession(), schema_message, getSession()->getLex()->exists());
 
64
    if (unlikely(plugin::EventObserver::afterCreateDatabase(*getSession(), path, res)))
64
65
    {
65
 
      my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
 
66
      my_error(ER_EVENT_OBSERVER_PLUGIN, schema_identifier);
66
67
      res = false;
67
68
    }
68
69
 
79
80
  if (not plugin::Authorization::isAuthorized(getSession()->user(), identifier))
80
81
    return false;
81
82
 
82
 
  if (not session->getLex()->exists())
 
83
  if (not getSession()->getLex()->exists())
83
84
  {
84
85
    if (plugin::StorageEngine::doesSchemaExist(identifier))
85
86
    {
86
 
      std::string name;
87
 
 
88
 
      identifier.getSQLPath(name);
89
 
      my_error(ER_DB_CREATE_EXISTS, MYF(0), name.c_str());
 
87
      my_error(ER_DB_CREATE_EXISTS, identifier);
90
88
 
91
89
      return false;
92
90
    }