~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/quick_range_select.h

  • Committer: Prafulla Tekawade
  • Date: 2010-07-18 03:36:32 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-20100718033632-p7q6qtgliqbhe38p
Fix for Bug 592444

There were two problems:
o. In greedy_search optimizer method, best_extension_by_limited search
   maintains join embedding(nestedness) of tables added so far, so that 
   correct(valid)  join order is selected
   These are requirements from nested outer join executioner.
   The problem was, embedding_map was not correctly updated when a table 
   is added to optimal plan outside best_extension_by_limited search, 
   by greedy_search method. We need to update join->cur_embedding_map
   correctly here so that execution plan for other tables get
   generated.
   Invoked checked_interleaving_with_nj from greedy_search on the
   best_table selected. Fixed its prototype to take only one JoinTab
   This is same as mysql 5.1 source tree.
o. The other problem was, join->cur_embedding_map was not restored correctly
   when a table is added to the optimal plan to reflect the current embedding 
   map. 
   Taken good documented method restore_prev_nj_state which restores 
   cur_embedding_map from mysql 5.1 source tree and modified it for drizzled 
   code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "drizzled/optimizer/range.h"
24
24
 
25
 
#include <boost/dynamic_bitset.hpp>
26
25
#include <vector>
27
26
 
28
27
namespace drizzled
47
46
 
48
47
  /** Members to deal with case when this quick select is a ROR-merged scan */
49
48
  bool in_ror_merged_scan;
50
 
  boost::dynamic_bitset<> *column_bitmap;
51
 
  boost::dynamic_bitset<> *save_read_set;
52
 
  boost::dynamic_bitset<> *save_write_set;
 
49
  MyBitmap column_bitmap;
 
50
  MyBitmap *save_read_set;
 
51
  MyBitmap *save_write_set;
53
52
  bool free_file; /**< True when this->file is "owned" by this quick select */
54
53
 
55
54
  /* Range pointers to be used when not using MRR interface */
59
58
  /** Members needed to use the MRR interface */
60
59
  QuickRangeSequenceContext qr_traversal_ctx;
61
60
  uint32_t mrr_buf_size; /**< copy from session->variables.read_rnd_buff_size */
 
61
  HANDLER_BUFFER *mrr_buf_desc; /**< the Cursor buffer */
62
62
 
63
63
  /** Info about index we're scanning */
64
64
  KEY_PART *key_parts;
107
107
                     Table *table,
108
108
                     uint32_t index_arg,
109
109
                     bool no_alloc,
110
 
                     memory::Root *parent_alloc);
 
110
                     memory::Root *parent_alloc,
 
111
                     bool *create_err);
111
112
 
112
113
  ~QuickRangeSelect();
113
114
 
122
123
   * QuickRangeSelect::get_next()
123
124
   *
124
125
   * NOTES
125
 
   * Record is read into table->getInsertRecord()
 
126
   * Record is read into table->record[0]
126
127
   *
127
128
   * RETURN
128
129
   * @retval 0                  Found row
222
223
      Use default MRR implementation for reverse scans. No table engine
223
224
      currently can do an MRR scan with output in reverse index order.
224
225
    */
 
226
    mrr_buf_desc= NULL;
225
227
    mrr_flags|= HA_MRR_USE_DEFAULT_IMPL;
226
228
    mrr_buf_size= 0;
227
229
  }