~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_schema.cc

  • Committer: Stewart Smith
  • Date: 2010-11-03 03:27:09 UTC
  • mto: (1902.1.1 build) (1910.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1903.
  • Revision ID: stewart@flamingspork.com-20101103032709-oyvfrc6eb8fzj0mr
fix docs warning: docs/unlock.rst:2: (WARNING/2) Title underline too short.

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