~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_table.cc

  • Committer: Lee Bieber
  • Date: 2011-03-29 22:31:41 UTC
  • mfrom: (2257.1.3 build)
  • Revision ID: kalebral@gmail.com-20110329223141-yxc22h3l2he58sk0
Merge Andrew - 743842: Build failure using GCC 4.6
Merge Stewart - 738022: CachedDirectory silently fails to add entries if stat() fails
Merge Olaf - Common fwd: add copyright, add more declaration

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 <config.h>
22
22
#include <drizzled/show.h>
23
23
#include <drizzled/session.h>
24
24
#include <drizzled/lock.h>
25
25
#include <drizzled/statement/drop_table.h>
26
 
#include "drizzled/sql_table.h"
 
26
#include <drizzled/sql_table.h>
 
27
#include <drizzled/sql_lex.h>
27
28
 
28
29
namespace drizzled
29
30
{
33
34
 delete (drop) tables.
34
35
 
35
36
  SYNOPSIS
36
 
   mysql_rm_table()
 
37
   rm_table()
37
38
   session                      Thread handle
38
39
   tables               List of tables to delete
39
40
   if_exists            If 1, don't give error if one table doesn't exists
53
54
 
54
55
*/
55
56
 
56
 
static bool mysql_rm_table(Session *session, TableList *tables, bool if_exists, bool drop_temporary)
 
57
static bool rm_table(Session *session, TableList *tables, bool if_exists, bool drop_temporary)
57
58
{
58
59
  bool error, need_start_waiting= false;
59
60
 
70
71
    table::Cache::singleton().mutex() during wait_if_global_read_lock(), other threads could not
71
72
    close their tables. This would make a pretty deadlock.
72
73
  */
73
 
  error= mysql_rm_table_part2(session, tables, if_exists, drop_temporary);
 
74
  error= rm_table_part2(session, tables, if_exists, drop_temporary);
74
75
 
75
76
  if (need_start_waiting)
76
77
  {
87
88
 
88
89
bool statement::DropTable::execute()
89
90
{
90
 
  TableList *first_table= (TableList *) session->lex->select_lex.table_list.first;
91
 
  TableList *all_tables= session->lex->query_tables;
 
91
  TableList *first_table= (TableList *) lex().select_lex.table_list.first;
 
92
  TableList *all_tables= lex().query_tables;
92
93
  assert(first_table == all_tables && first_table != 0);
93
94
 
94
95
  if (not drop_temporary)
95
96
  {
96
 
    if (not session->endActiveTransaction())
 
97
    if (session().inTransaction())
97
98
    {
 
99
      my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
98
100
      return true;
99
101
    }
100
102
  }
101
103
 
102
104
  /* DDL and binlog write order protected by table::Cache::singleton().mutex() */
103
 
  bool res= mysql_rm_table(session,
104
 
                           first_table,
105
 
                           drop_if_exists,
106
 
                           drop_temporary);
107
 
  return res;
 
105
 
 
106
  return rm_table(&session(), first_table, drop_if_exists, drop_temporary);
108
107
}
109
108
 
110
109
} /* namespace drizzled */