~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/create_schema.cc

  • Committer: Brian Aker
  • Date: 2010-10-20 20:25:52 UTC
  • mto: (1864.2.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1865.
  • Revision ID: brian@tangent.org-20101020202552-51y5sz5ledoxbp7t
Add support for --with-valgrind

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <drizzled/session.h>
24
24
#include <drizzled/statement/create_schema.h>
25
25
#include <drizzled/db.h>
 
26
#include <drizzled/plugin/event_observer.h>
 
27
#include <drizzled/message.h>
26
28
 
27
29
#include <string>
28
30
 
33
35
 
34
36
bool statement::CreateSchema::execute()
35
37
{
 
38
  if (not validateSchemaOptions())
 
39
    return true;
 
40
 
36
41
  if (not session->endActiveTransaction())
37
42
  {
38
43
    return true;
39
44
  }
40
45
 
41
46
  SchemaIdentifier schema_identifier(string(session->lex->name.str, session->lex->name.length));
42
 
  if (not check_db_name(schema_identifier))
 
47
  if (not check_db_name(session, schema_identifier))
43
48
  {
44
49
    my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
45
50
    return false;
46
51
  }
47
52
 
48
 
  schema_message.set_name(session->lex->name.str);
49
 
  if (not schema_message.has_collation())
50
 
  {
51
 
    schema_message.set_collation(default_charset_info->name);
52
 
  }
53
 
 
54
 
  bool res= mysql_create_db(session, schema_message, is_if_not_exists);
 
53
  drizzled::message::init(schema_message, session->lex->name.str);
 
54
 
 
55
  bool res = false;
 
56
  if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, schema_identifier.getSQLPath())))
 
57
  {
 
58
    my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), schema_identifier.getSQLPath().c_str());
 
59
  }
 
60
  else
 
61
  {
 
62
    res= mysql_create_db(session, schema_message, is_if_not_exists);
 
63
    if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, schema_identifier.getSQLPath(), res)))
 
64
    {
 
65
      my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), schema_identifier.getSQLPath().c_str());
 
66
      res = false;
 
67
    }
 
68
 
 
69
  }
 
70
 
55
71
  return not res;
56
72
}
57
73
 
 
74
// We don't actually test anything at this point, we assume it is all bad.
 
75
bool statement::CreateSchema::validateSchemaOptions()
 
76
{
 
77
  size_t num_engine_options= schema_message.engine().options_size();
 
78
  bool rc= num_engine_options ? false : true;
 
79
 
 
80
  for (size_t y= 0; y < num_engine_options; ++y)
 
81
  {
 
82
    my_error(ER_UNKNOWN_SCHEMA_OPTION, MYF(0),
 
83
             schema_message.engine().options(y).name().c_str(),
 
84
             schema_message.engine().options(y).state().c_str());
 
85
 
 
86
    rc= false;
 
87
  }
 
88
 
 
89
  return rc;
 
90
}
 
91
 
58
92
} /* namespace drizzled */
59
93