~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/create_schema.cc

  • Committer: Stewart Smith
  • Date: 2010-07-27 00:49:32 UTC
  • mto: (1720.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 1721.
  • Revision ID: stewart@flamingspork.com-20100727004932-basq3vx9szmmbswm
fix storing and manipulating foreign keys in the proto around ALTER TABLE, CREATE TABLE and ALTER TABLE ADD/DROP FOREIGN KEY. We also (mostly) emulate the naming of innodb foreign keys in the upper layer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <drizzled/statement/create_schema.h>
25
25
#include <drizzled/db.h>
26
26
#include <drizzled/plugin/event_observer.h>
27
 
#include <drizzled/message.h>
28
27
 
29
28
#include <string>
30
29
 
46
45
  SchemaIdentifier schema_identifier(string(session->lex->name.str, session->lex->name.length));
47
46
  if (not check_db_name(session, schema_identifier))
48
47
  {
49
 
    std::string path;
50
 
    schema_identifier.getSQLPath(path);
51
 
    my_error(ER_WRONG_DB_NAME, MYF(0), path.c_str());
 
48
    my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
52
49
    return false;
53
50
  }
54
51
 
55
 
  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())
 
55
  {
 
56
    schema_message.set_collation(default_charset_info->name);
 
57
  }
56
58
 
57
59
  bool res = false;
58
 
  std::string path;
59
 
  schema_identifier.getSQLPath(path);
60
 
 
61
 
  if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, path)))
 
60
  if (unlikely(plugin::EventObserver::beforeCreateDatabase(*session, schema_identifier.getSQLPath())))
62
61
  {
63
 
    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());
64
63
  }
65
64
  else
66
65
  {
67
66
    res= mysql_create_db(session, schema_message, is_if_not_exists);
68
 
    if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, path, res)))
 
67
    if (unlikely(plugin::EventObserver::afterCreateDatabase(*session, schema_identifier.getSQLPath(), res)))
69
68
    {
70
 
      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());
71
70
      res = false;
72
71
    }
73
72