~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_schema.cc

  • Committer: Brian Aker
  • Date: 2010-08-03 20:57:39 UTC
  • mfrom: (1680.6.4 rollup)
  • Revision ID: brian@gaz-20100803205739-7betgobkod41363k
Removes LOCK_system_variables_hash, one goto, drops internall new for std
new (so possible performance regression), fixes bug where Session was not
unlocked correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <drizzled/statement/alter_schema.h>
25
25
#include <drizzled/plugin/storage_engine.h>
26
26
#include <drizzled/db.h>
27
 
#include <drizzled/message.h>
28
27
 
29
28
#include <string>
30
29
 
36
35
bool statement::AlterSchema::execute()
37
36
{
38
37
  LEX_STRING *db= &session->lex->name;
39
 
  message::schema::shared_ptr old_definition;
 
38
  message::Schema old_definition;
40
39
 
41
40
  if (not validateSchemaOptions())
42
41
    return true;
45
44
 
46
45
  if (not check_db_name(session, schema_identifier))
47
46
  {
48
 
    std::string path;
49
 
    schema_identifier.getSQLPath(path);
50
 
    my_error(ER_WRONG_DB_NAME, MYF(0), path.c_str());
51
 
 
 
47
    my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
52
48
    return false;
53
49
  }
54
50
 
55
 
  SchemaIdentifier identifier(db->str);
 
51
  schema_message.set_name(db->str);
 
52
  schema_message.mutable_engine()->set_name("filesystem"); // For the moment we have only one.
 
53
  SchemaIdentifier identifier(schema_message.name());
 
54
 
56
55
  if (not plugin::StorageEngine::getSchemaDefinition(identifier, old_definition))
57
56
  {
58
57
    my_error(ER_SCHEMA_DOES_NOT_EXIST, MYF(0), db->str);
66
65
               MYF(0));
67
66
    return true;
68
67
  }
69
 
  /*
70
 
    @todo right now the logic for alter schema is just sitting here, at some point this should be packaged up in a class/etc.
71
 
  */
72
 
 
73
 
  // We set the name from the old version to keep case preference
74
 
  schema_message.set_name(old_definition->name());
75
 
  schema_message.set_version(old_definition->version());
76
 
  schema_message.set_uuid(old_definition->uuid());
77
 
  schema_message.mutable_engine()->set_name(old_definition->engine().name());
78
 
 
79
 
  // We need to make sure we don't destroy any collation that might have
80
 
  // been changed.
 
68
 
81
69
  if (not schema_message.has_collation())
82
70
  {
83
 
    schema_message.set_collation(old_definition->collation());
 
71
    schema_message.set_collation(schema_message.collation());
84
72
  }
85
 
  
86
 
  drizzled::message::update(schema_message);
87
73
 
88
74
  bool res= mysql_alter_db(session, schema_message);
89
75