~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_schema.cc

  • Committer: Stewart Smith
  • Author(s): Vasil Dimov, Stewart Smith
  • Date: 2010-12-20 02:24:00 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2022.
  • Revision ID: stewart@flamingspork.com-20101220022400-0p9lvvppwgaowdju
Merge Revision revid:vasil.dimov@oracle.com-20101102165720-164z3666y3tut4c2 from MySQL InnoDB

Original revid:vasil.dimov@oracle.com-20101102165720-164z3666y3tut4c2

Original Authors: Vasil Dimov <vasil.dimov@oracle.com>
Original commit message:
Fix Bug#53046 dict_update_statistics_low can still be run concurrently on same table

Replace the array of mutexes that used to protect
dict_index_t::stat_n_diff_key_vals[] with an array of rw locks that protects
all the stats related members in dict_table_t and all of its indexes.

Approved by:    Jimmy (rb://503)

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, Inc.
 
4
 *  Copyright (C) 2009 Sun Microsystems
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
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
28
 
29
29
#include <string>
35
35
 
36
36
bool statement::AlterSchema::execute()
37
37
{
38
 
  LEX_STRING *db= &getSession()->getLex()->name;
 
38
  LEX_STRING *db= &session->lex->name;
39
39
  message::schema::shared_ptr old_definition;
40
40
 
41
41
  if (not validateSchemaOptions())
42
42
    return true;
43
43
 
44
 
  identifier::Schema schema_identifier(string(db->str, db->length));
 
44
  SchemaIdentifier schema_identifier(string(db->str, db->length));
45
45
 
46
 
  if (not schema::check(*getSession(), schema_identifier))
 
46
  if (not check_db_name(session, schema_identifier))
47
47
  {
48
 
    my_error(ER_WRONG_DB_NAME, schema_identifier);
 
48
    std::string path;
 
49
    schema_identifier.getSQLPath(path);
 
50
    my_error(ER_WRONG_DB_NAME, MYF(0), path.c_str());
49
51
 
50
52
    return false;
51
53
  }
52
54
 
53
 
  identifier::Schema identifier(db->str);
54
 
  if (not (old_definition= plugin::StorageEngine::getSchemaDefinition(identifier)))
 
55
  SchemaIdentifier identifier(db->str);
 
56
  if (not plugin::StorageEngine::getSchemaDefinition(identifier, old_definition))
55
57
  {
56
 
    my_error(ER_SCHEMA_DOES_NOT_EXIST, identifier); 
 
58
    my_error(ER_SCHEMA_DOES_NOT_EXIST, MYF(0), db->str);
57
59
    return true;
58
60
  }
59
61
 
60
 
  if (getSession()->inTransaction())
 
62
  if (session->inTransaction())
61
63
  {
62
 
    my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
 
64
    my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, 
 
65
               ER(ER_LOCK_OR_ACTIVE_TRANSACTION), 
 
66
               MYF(0));
63
67
    return true;
64
68
  }
65
69
  /*
66
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.
67
71
  */
68
72
 
69
 
  // First initialize the schema message
70
 
  drizzled::message::schema::init(schema_message, old_definition->name());
71
 
 
72
73
  // We set the name from the old version to keep case preference
 
74
  schema_message.set_name(old_definition->name());
73
75
  schema_message.set_version(old_definition->version());
74
76
  schema_message.set_uuid(old_definition->uuid());
75
77
  schema_message.mutable_engine()->set_name(old_definition->engine().name());
83
85
  
84
86
  drizzled::message::update(schema_message);
85
87
 
86
 
  bool res= schema::alter(*getSession(), schema_message, *old_definition);
 
88
  bool res= mysql_alter_db(session, schema_message);
87
89
 
88
90
  return not res;
89
91
}