1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems, Inc.
4
* Copyright (C) 2009 Sun Microsystems
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
23
22
#include <drizzled/show.h>
24
23
#include <drizzled/session.h>
25
24
#include <drizzled/statement/drop_schema.h>
26
#include <drizzled/plugin/event_observer.h>
27
#include <drizzled/sql_lex.h>
28
#include <drizzled/schema.h>
25
#include <drizzled/db.h>
37
34
bool statement::DropSchema::execute()
39
if (session().inTransaction())
36
if (! session->endActiveTransaction())
41
my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
45
identifier::Schema schema_identifier(std::string(lex().name.str, lex().name.length));
47
if (not schema::check(session(), schema_identifier))
40
if (check_db_name(&session->lex->name))
49
my_error(ER_WRONG_DB_NAME, schema_identifier);
42
my_error(ER_WRONG_DB_NAME, MYF(0), session->lex->name.str);
54
if (session().inTransaction())
45
if (session->inTransaction())
56
47
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
57
48
ER(ER_LOCK_OR_ACTIVE_TRANSACTION),
63
std::string path = schema_identifier.getSQLPath();
64
if (unlikely(plugin::EventObserver::beforeDropDatabase(session(), path)))
66
my_error(ER_EVENT_OBSERVER_PLUGIN, schema_identifier);
70
res= schema::drop(session(), schema_identifier, drop_if_exists);
71
if (unlikely(plugin::EventObserver::afterDropDatabase(session(), path, res)))
73
my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
52
bool res= mysql_rm_db(session, session->lex->name.str, drop_if_exists);