~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_schema.cc

  • Committer: Brian Aker
  • Date: 2010-08-12 17:19:46 UTC
  • mfrom: (1701.1.1 turn-off-csv)
  • Revision ID: brian@tangent.org-20100812171946-n44naaqhg27gehlh
MErge Monty, remove CSV from auto-build

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>
22
 
 
 
21
#include "config.h"
23
22
#include <drizzled/show.h>
24
23
#include <drizzled/session.h>
25
24
#include <drizzled/statement/drop_schema.h>
 
25
#include <drizzled/db.h>
26
26
#include <drizzled/plugin/event_observer.h>
27
27
 
28
 
#include <drizzled/schema.h>
29
 
 
30
28
#include <string>
31
29
 
32
30
using namespace std;
36
34
 
37
35
bool statement::DropSchema::execute()
38
36
{
39
 
  if (getSession()->inTransaction())
 
37
  if (! session->endActiveTransaction())
40
38
  {
41
 
    my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
42
39
    return true;
43
40
  }
44
 
 
45
 
  identifier::Schema schema_identifier(std::string(getSession()->getLex()->name.str, getSession()->getLex()->name.length));
46
 
 
47
 
  if (not schema::check(*getSession(), schema_identifier))
 
41
  SchemaIdentifier schema_identifier(string(session->lex->name.str, session->lex->name.length));
 
42
  if (not check_db_name(session, schema_identifier))
48
43
  {
49
 
    my_error(ER_WRONG_DB_NAME, schema_identifier);
50
 
 
 
44
    my_error(ER_WRONG_DB_NAME, MYF(0), schema_identifier.getSQLPath().c_str());
51
45
    return false;
52
46
  }
53
 
 
54
 
  if (getSession()->inTransaction())
 
47
  if (session->inTransaction())
55
48
  {
56
49
    my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, 
57
50
        ER(ER_LOCK_OR_ACTIVE_TRANSACTION), 
60
53
  }
61
54
  
62
55
  bool res = true;
63
 
  std::string path;
64
 
  schema_identifier.getSQLPath(path);
65
 
  if (unlikely(plugin::EventObserver::beforeDropDatabase(*getSession(), path))) 
 
56
  if (unlikely(plugin::EventObserver::beforeDropDatabase(*session, schema_identifier.getSQLPath()))) 
66
57
  {
67
 
    my_error(ER_EVENT_OBSERVER_PLUGIN, schema_identifier);
 
58
    my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), schema_identifier.getSQLPath().c_str());
68
59
  }
69
60
  else
70
61
  {
71
 
    res= schema::drop(*getSession(), schema_identifier, drop_if_exists);
72
 
    if (unlikely(plugin::EventObserver::afterDropDatabase(*getSession(), path, res)))
 
62
    res= mysql_rm_db(session, schema_identifier, drop_if_exists);
 
63
    if (unlikely(plugin::EventObserver::afterDropDatabase(*session, schema_identifier.getSQLPath(), res)))
73
64
    {
74
 
      my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
 
65
      my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), schema_identifier.getSQLPath().c_str());
75
66
      res = false;
76
67
    }
77
68