~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_schema.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-01 10:23:22 UTC
  • mto: (2136.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2137.
  • Revision ID: andrew@linuxjedi.co.uk-20110201102322-oxztcyrjzg3c7yta
Fix counters cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
 
21
#include "config.h"
22
22
#include <drizzled/show.h>
23
23
#include <drizzled/session.h>
24
24
#include <drizzled/statement/alter_schema.h>
25
25
#include <drizzled/plugin/storage_engine.h>
26
 
#include <drizzled/schema.h>
 
26
#include <drizzled/db.h>
27
27
#include <drizzled/message.h>
28
 
#include <drizzled/sql_lex.h>
29
28
 
30
29
#include <string>
31
30
 
36
35
 
37
36
bool statement::AlterSchema::execute()
38
37
{
39
 
  LEX_STRING *db= &lex().name;
 
38
  LEX_STRING *db= &getSession()->lex->name;
40
39
  message::schema::shared_ptr old_definition;
41
40
 
42
41
  if (not validateSchemaOptions())
44
43
 
45
44
  identifier::Schema schema_identifier(string(db->str, db->length));
46
45
 
47
 
  if (not schema::check(session(), schema_identifier))
 
46
  if (not check_db_name(getSession(), schema_identifier))
48
47
  {
49
48
    my_error(ER_WRONG_DB_NAME, schema_identifier);
50
49
 
52
51
  }
53
52
 
54
53
  identifier::Schema identifier(db->str);
55
 
  if (not (old_definition= plugin::StorageEngine::getSchemaDefinition(identifier)))
 
54
  if (not plugin::StorageEngine::getSchemaDefinition(identifier, old_definition))
56
55
  {
57
56
    my_error(ER_SCHEMA_DOES_NOT_EXIST, identifier); 
58
57
    return true;
59
58
  }
60
59
 
61
 
  if (session().inTransaction())
 
60
  if (getSession()->inTransaction())
62
61
  {
63
62
    my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
64
63
    return true;
84
83
  
85
84
  drizzled::message::update(schema_message);
86
85
 
87
 
  bool res= schema::alter(session(), schema_message, *old_definition);
 
86
  bool res= alter_db(getSession(), schema_message, old_definition);
88
87
 
89
88
  return not res;
90
89
}