~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_schema.cc

Does not work (compile issue in plugin).

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