~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_table.cc

  • Committer: Prafulla Tekawade
  • Date: 2010-07-13 16:07:35 UTC
  • mto: (1662.1.4 rollup)
  • mto: This revision was merged to the branch mainline in revision 1664.
  • Revision ID: prafulla_t@users.sourceforge.net-20100713160735-2fsdtrm3azayuyu1
This bug is simillar to mysql bug 36133
http://bugs.mysql.com/bug.php?id=36133

Taking changes from that fix.

  - The problem was that the range optimizer evaluated constant expressions, 
    and among them it would try to evaluate IN-subquery predicates slated for
    handling with materialization strategy. However, these predicates require
    that parent_join->setup_subquery_materialization() is invoked before one
    attempts to evaluate them.
  
  - Fixed by making the range optimizer not to evaluate expressions that have
    item->is_expensive() == TRUE (these are materialization subqueries and 
    stored function calls). This should also resolve the problem that EXPLAIN 
    may be too long. 
    This change cuts off some opportunities for range optimizer, but this is 
    the price we're willing to pay for separation of query optimization and
    execution. 

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>
 
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
27
 
28
28
namespace drizzled
29
29
{
33
33
 delete (drop) tables.
34
34
 
35
35
  SYNOPSIS
36
 
   rm_table()
 
36
   mysql_rm_table()
37
37
   session                      Thread handle
38
38
   tables               List of tables to delete
39
39
   if_exists            If 1, don't give error if one table doesn't exists
53
53
 
54
54
*/
55
55
 
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)
57
57
{
58
58
  bool error, need_start_waiting= false;
59
59
 
61
61
 
62
62
  if (not drop_temporary)
63
63
  {
64
 
    if (not (need_start_waiting= not session->wait_if_global_read_lock(false, true)))
 
64
    if (not (need_start_waiting= !wait_if_global_read_lock(session, false, true)))
65
65
      return true;
66
66
  }
67
67
 
68
68
  /*
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.
72
72
  */
73
 
  error= rm_table_part2(session, tables, if_exists, drop_temporary);
 
73
  error= mysql_rm_table_part2(session, tables, if_exists, drop_temporary);
74
74
 
75
75
  if (need_start_waiting)
76
 
  {
77
 
    session->startWaitingGlobalReadLock();
78
 
  }
 
76
    start_waiting_global_read_lock(session);
79
77
 
80
78
  if (error)
81
79
    return true;
87
85
 
88
86
bool statement::DropTable::execute()
89
87
{
90
 
  TableList *first_table= (TableList *) getSession()->getLex()->select_lex.table_list.first;
91
 
  TableList *all_tables= getSession()->getLex()->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);
93
91
 
94
92
  if (not drop_temporary)
95
93
  {
96
 
    if (getSession()->inTransaction())
 
94
    if (not session->endActiveTransaction())
97
95
    {
98
 
      my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
99
96
      return true;
100
97
    }
101
98
  }
102
99
 
103
 
  /* DDL and binlog write order protected by table::Cache::singleton().mutex() */
104
 
 
105
 
  return rm_table(getSession(), first_table, drop_if_exists, drop_temporary);
 
100
  /* DDL and binlog write order protected by LOCK_open */
 
101
  bool res= mysql_rm_table(session,
 
102
                           first_table,
 
103
                           drop_if_exists,
 
104
                           drop_temporary);
 
105
  return res;
106
106
}
107
107
 
108
108
} /* namespace drizzled */