~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_list.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
 
/* Copyright (C) 2009 Sun Microsystems, Inc.
 
1
/* Copyright (C) 2009 Sun Microsystems
2
2
 
3
3
  This program is free software; you can redistribute it and/or modify
4
4
  it under the terms of the GNU General Public License as published by
11
11
 
12
12
  You should have received a copy of the GNU General Public License
13
13
  along with this program; if not, write to the Free Software
14
 
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include <config.h>
 
16
#include "config.h"
17
17
 
18
18
#include <string>
19
19
 
20
 
#include <drizzled/error.h>
21
 
#include <drizzled/table_list.h>
22
 
#include <drizzled/item.h>
23
 
#include <drizzled/item/field.h>
24
 
#include <drizzled/nested_join.h>
25
 
#include <drizzled/sql_lex.h>
26
 
#include <drizzled/sql_select.h>
27
 
#include <drizzled/strfunc.h>
 
20
#include "drizzled/error.h"
 
21
#include "drizzled/table_list.h"
 
22
#include "drizzled/item.h"
 
23
#include "drizzled/item/field.h"
 
24
#include "drizzled/nested_join.h"
 
25
#include "drizzled/sql_lex.h"
 
26
#include "drizzled/sql_select.h"
 
27
#include "drizzled/strfunc.h"
28
28
 
29
29
using namespace std;
30
30
 
34
34
class Item;
35
35
class Item_field;
36
36
 
37
 
bool TableList::set_insert_values(memory::Root *)
 
37
uint32_t TableList::create_table_def_key(char *key)
 
38
{
 
39
  return TableIdentifier::createKey(key, db, table_name);
 
40
}
 
41
 
 
42
bool TableList::set_insert_values(memory::Root *mem_root)
38
43
{
39
44
  if (table)
40
45
  {
41
 
    table->insert_values.resize(table->getShare()->rec_buff_length);
 
46
    if (!table->insert_values &&
 
47
        !(table->insert_values= (unsigned char *)mem_root->alloc_root(table->getShare()->rec_buff_length)))
 
48
      return true;
42
49
  }
43
50
 
44
51
  return false;
76
83
TableList *TableList::last_leaf_for_name_resolution()
77
84
{
78
85
  TableList *cur_table_ref= this;
79
 
  NestedJoin *cur_nested_join;
 
86
  nested_join_st *cur_nested_join;
80
87
 
81
88
  if (is_leaf_for_name_resolution())
82
89
    return this;
94
101
    */
95
102
    if ((cur_table_ref->outer_join & JOIN_TYPE_RIGHT))
96
103
    {
97
 
      List<TableList>::iterator it(cur_nested_join->join_list.begin());
 
104
      List_iterator_fast<TableList> it(cur_nested_join->join_list);
98
105
      TableList *next;
99
106
      cur_table_ref= it++;
100
107
      while ((next= it++))
114
121
TableList *TableList::first_leaf_for_name_resolution()
115
122
{
116
123
  TableList *cur_table_ref= NULL;
117
 
  NestedJoin *cur_nested_join;
 
124
  nested_join_st *cur_nested_join;
118
125
 
119
126
  if (is_leaf_for_name_resolution())
120
127
    return this;
124
131
       cur_nested_join;
125
132
       cur_nested_join= cur_table_ref->nested_join)
126
133
  {
127
 
    List<TableList>::iterator it(cur_nested_join->join_list.begin());
 
134
    List_iterator_fast<TableList> it(cur_nested_join->join_list);
128
135
    cur_table_ref= it++;
129
136
    /*
130
137
      If the current nested join is a RIGHT JOIN, the operands in
165
172
    int type;
166
173
    bool have_empty_use_join= false, have_empty_use_order= false,
167
174
         have_empty_use_group= false;
168
 
    List_iterator <Index_hint> iter(index_hints->begin());
 
175
    List_iterator <Index_hint> iter(*index_hints);
169
176
 
170
177
    /* initialize temporary variables used to collect hints of each kind */
171
178
    for (type= INDEX_HINT_IGNORE; type <= INDEX_HINT_FORCE; type++)
309
316
 
310
317
    if (index_hints)
311
318
    {
312
 
      List<Index_hint>::iterator it(index_hints->begin());
 
319
      List_iterator<Index_hint> it(*index_hints);
313
320
      Index_hint *hint;
314
321
 
315
322
      while ((hint= it++))