~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_schema.cc

  • Committer: Brian Aker
  • Date: 2011-02-05 10:53:26 UTC
  • mto: (2147.3.1 alter-table)
  • mto: This revision was merged to the branch mainline in revision 2148.
  • Revision ID: brian@tangent.org-20110205105326-hjmn5xehw5rs46tp
Fix bad error in warnings/errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
 
4
 *  Copyright (C) 2009 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
35
35
 
36
36
bool statement::AlterSchema::execute()
37
37
{
38
 
  LEX_STRING *db= &session->lex->name;
39
 
  message::SchemaPtr old_definition;
 
38
  LEX_STRING *db= &getSession()->lex->name;
 
39
  message::schema::shared_ptr old_definition;
40
40
 
41
41
  if (not validateSchemaOptions())
42
42
    return true;
43
43
 
44
 
  SchemaIdentifier schema_identifier(string(db->str, db->length));
 
44
  identifier::Schema schema_identifier(string(db->str, db->length));
45
45
 
46
 
  if (not check_db_name(session, schema_identifier))
 
46
  if (not check_db_name(getSession(), schema_identifier))
47
47
  {
48
 
    my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
 
48
    my_error(ER_WRONG_DB_NAME, schema_identifier);
 
49
 
49
50
    return false;
50
51
  }
51
52
 
52
 
  SchemaIdentifier identifier(db->str);
 
53
  identifier::Schema identifier(db->str);
53
54
  if (not plugin::StorageEngine::getSchemaDefinition(identifier, old_definition))
54
55
  {
55
 
    my_error(ER_SCHEMA_DOES_NOT_EXIST, MYF(0), db->str);
 
56
    my_error(ER_SCHEMA_DOES_NOT_EXIST, identifier); 
56
57
    return true;
57
58
  }
58
59
 
59
 
  if (session->inTransaction())
 
60
  if (getSession()->inTransaction())
60
61
  {
61
 
    my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, 
62
 
               ER(ER_LOCK_OR_ACTIVE_TRANSACTION), 
63
 
               MYF(0));
 
62
    my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
64
63
    return true;
65
64
  }
66
65
  /*
67
66
    @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
67
  */
69
68
 
 
69
  // First initialize the schema message
 
70
  drizzled::message::schema::init(schema_message, old_definition->name());
 
71
 
70
72
  // We set the name from the old version to keep case preference
71
 
  schema_message.set_name(old_definition->name());
72
73
  schema_message.set_version(old_definition->version());
73
74
  schema_message.set_uuid(old_definition->uuid());
74
75
  schema_message.mutable_engine()->set_name(old_definition->engine().name());
82
83
  
83
84
  drizzled::message::update(schema_message);
84
85
 
85
 
  bool res= mysql_alter_db(session, schema_message);
 
86
  bool res= alter_db(getSession(), schema_message, old_definition);
86
87
 
87
88
  return not res;
88
89
}