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
56
static bool rm_table(Session *session, TableList *tables, bool if_exists, bool drop_temporary)
56
static bool mysql_rm_table(Session *session, TableList *tables, bool if_exists, bool drop_temporary)
58
58
bool error, need_start_waiting= false;
60
60
/* mark for close and remove all cached entries */
62
if (not drop_temporary)
64
if (not (need_start_waiting= not session->wait_if_global_read_lock(false, true)))
64
if (!(need_start_waiting= !wait_if_global_read_lock(session, false, true)))
69
Acquire table::Cache::singleton().mutex() after wait_if_global_read_lock(). If we would hold
70
table::Cache::singleton().mutex() during wait_if_global_read_lock(), other threads could not
69
Acquire LOCK_open after wait_if_global_read_lock(). If we would hold
70
LOCK_open during wait_if_global_read_lock(), other threads could not
71
71
close their tables. This would make a pretty deadlock.
73
error= rm_table_part2(session, tables, if_exists, drop_temporary);
73
error= mysql_rm_table_part2(session, tables, if_exists, drop_temporary);
75
75
if (need_start_waiting)
77
session->startWaitingGlobalReadLock();
76
start_waiting_global_read_lock(session);
88
86
bool statement::DropTable::execute()
90
TableList *first_table= (TableList *) getSession()->lex->select_lex.table_list.first;
91
TableList *all_tables= getSession()->lex->query_tables;
88
TableList *first_table= (TableList *) session->lex->select_lex.table_list.first;
89
TableList *all_tables= session->lex->query_tables;
92
90
assert(first_table == all_tables && first_table != 0);
94
if (not drop_temporary)
96
if (getSession()->inTransaction())
93
if (! session->endActiveTransaction())
98
my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
103
/* DDL and binlog write order protected by table::Cache::singleton().mutex() */
105
return rm_table(getSession(), first_table, drop_if_exists, drop_temporary);
98
/* DDL and binlog write order protected by LOCK_open */
99
bool res= mysql_rm_table(session,
108
106
} /* namespace drizzled */