~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_schema.cc

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

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
 
 
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 (getSession()->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(getSession()->getLex()->name.str, getSession()->getLex()->name.length));
46
 
 
47
 
  if (not schema::check(*getSession(), 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 (getSession()->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;
64
 
  schema_identifier.getSQLPath(path);
65
 
  if (unlikely(plugin::EventObserver::beforeDropDatabase(*getSession(), path))) 
66
 
  {
67
 
    my_error(ER_EVENT_OBSERVER_PLUGIN, schema_identifier);
68
 
  }
69
 
  else
70
 
  {
71
 
    res= schema::drop(*getSession(), schema_identifier, drop_if_exists);
72
 
    if (unlikely(plugin::EventObserver::afterDropDatabase(*getSession(), path, res)))
73
 
    {
74
 
      my_error(ER_EVENT_OBSERVER_PLUGIN, MYF(0), path.c_str());
75
 
      res = false;
76
 
    }
77
 
 
78
 
  }
79
 
 
 
52
  bool res= mysql_rm_db(session, session->lex->name.str, drop_if_exists);
80
53
  return res;
81
54
}
82
55