~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_schema.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 00:53:34 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913005334-6wio2sbjugskfbm3
Added calls to the connection start/end dtrace probes.

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 <drizzled/server_includes.h>
22
22
#include <drizzled/show.h>
23
23
#include <drizzled/session.h>
24
24
#include <drizzled/statement/alter_schema.h>
25
 
#include <drizzled/plugin/storage_engine.h>
26
 
#include <drizzled/db.h>
27
 
 
28
 
#include <string>
29
 
 
30
 
using namespace std;
31
 
 
32
 
namespace drizzled
33
 
{
 
25
 
 
26
using namespace drizzled;
34
27
 
35
28
bool statement::AlterSchema::execute()
36
29
{
37
30
  LEX_STRING *db= &session->lex->name;
38
 
  message::Schema old_definition;
39
 
 
40
 
  SchemaIdentifier schema_identifier(string(db->str, db->length));
41
 
 
42
 
  if (not check_db_name(schema_identifier))
 
31
  HA_CREATE_INFO create_info(session->lex->create_info);
 
32
  if (check_db_name(db))
43
33
  {
44
 
    my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
 
34
    my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
45
35
    return false;
46
36
  }
47
 
 
48
 
  schema_message.set_name(db->str);
49
 
  SchemaIdentifier identifier(schema_message.name());
50
 
 
51
 
  if (not plugin::StorageEngine::getSchemaDefinition(identifier, old_definition))
52
 
  {
53
 
    my_error(ER_SCHEMA_DOES_NOT_EXIST, MYF(0), db->str);
54
 
    return true;
55
 
  }
56
 
 
57
37
  if (session->inTransaction())
58
38
  {
59
39
    my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, 
61
41
               MYF(0));
62
42
    return true;
63
43
  }
64
 
 
65
 
  if (not schema_message.has_collation())
66
 
  {
67
 
    schema_message.set_collation(schema_message.collation());
68
 
  }
69
 
 
70
 
  bool res= mysql_alter_db(session, schema_message);
71
 
 
72
 
  return not res;
 
44
  bool res= mysql_alter_db(session, db->str, &create_info);
 
45
  return res;
73
46
}
74
 
 
75
 
} /* namespace drizzled */
76