~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_schema.cc

  • Committer: Brian Aker
  • Date: 2010-03-31 19:14:14 UTC
  • Revision ID: brian@gaz-20100331191414-9yv44mmpvf0tb7l1
Updated to use show schemas specific table.

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;
40
 
 
41
 
  if (not validateSchemaOptions())
42
 
    return true;
 
38
  message::Schema old_definition;
43
39
 
44
40
  SchemaIdentifier schema_identifier(string(db->str, db->length));
45
41
 
46
 
  if (not check_db_name(session, schema_identifier))
 
42
  if (not check_db_name(schema_identifier))
47
43
  {
48
 
    std::string path;
49
 
    schema_identifier.getSQLPath(path);
50
 
    my_error(ER_WRONG_DB_NAME, MYF(0), path.c_str());
51
 
 
 
44
    my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
52
45
    return false;
53
46
  }
54
47
 
55
 
  SchemaIdentifier identifier(db->str);
 
48
  schema_message.set_name(db->str);
 
49
  SchemaIdentifier identifier(schema_message.name());
 
50
 
56
51
  if (not plugin::StorageEngine::getSchemaDefinition(identifier, old_definition))
57
52
  {
58
53
    my_error(ER_SCHEMA_DOES_NOT_EXIST, MYF(0), db->str);
66
61
               MYF(0));
67
62
    return true;
68
63
  }
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.
 
64
 
81
65
  if (not schema_message.has_collation())
82
66
  {
83
 
    schema_message.set_collation(old_definition->collation());
 
67
    schema_message.set_collation(schema_message.collation());
84
68
  }
85
 
  
86
 
  drizzled::message::update(schema_message);
87
69
 
88
70
  bool res= mysql_alter_db(session, schema_message);
89
71