~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/quick_range_select.cc

  • Committer: Brian Aker
  • Date: 2010-10-08 20:13:50 UTC
  • mfrom: (1823.1.3 trunk-drizzle)
  • Revision ID: brian@tangent.org-20101008201350-bmjpgakk12zmyw10
Overall merge of Padraig

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "drizzled/session.h"
22
22
#include "drizzled/optimizer/quick_range.h"
23
23
#include "drizzled/optimizer/quick_range_select.h"
24
 
#include "drizzled/sql_bitmap.h"
25
24
#include "drizzled/internal/m_string.h"
26
25
#include <fcntl.h>
27
26
 
35
34
                                              Table *table,
36
35
                                              uint32_t key_nr,
37
36
                                              bool no_alloc,
38
 
                                              memory::Root *parent_alloc,
39
 
                                              bool *create_error)
 
37
                                              memory::Root *parent_alloc)
40
38
  :
41
39
    cursor(NULL),
42
40
    ranges(),
43
41
    in_ror_merged_scan(false),
44
 
    column_bitmap(),
 
42
    column_bitmap(NULL),
45
43
    save_read_set(NULL),
46
44
    save_write_set(NULL),
47
45
    free_file(false),
54
52
    mrr_flags(0),
55
53
    alloc()
56
54
{
57
 
  my_bitmap_map *bitmap= NULL;
58
 
 
59
55
  sorted= 0;
60
56
  index= key_nr;
61
57
  head= table;
80
76
  record= head->record[0];
81
77
  save_read_set= head->read_set;
82
78
  save_write_set= head->write_set;
83
 
 
84
 
  /* Allocate a bitmap for used columns. Using memory::sql_alloc instead of malloc
85
 
     simply as a "fix" to the MySQL 6.0 code that also free()s it at the
86
 
     same time we destroy the mem_root.
87
 
   */
88
 
 
89
 
  bitmap= reinterpret_cast<my_bitmap_map*>(memory::sql_alloc(head->getShare()->column_bitmap_size));
90
 
  if (! bitmap)
91
 
  {
92
 
    column_bitmap.setBitmap(NULL);
93
 
    *create_error= 1;
94
 
  }
95
 
  else
96
 
  {
97
 
    column_bitmap.init(bitmap, head->getShare()->sizeFields());
98
 
  }
 
79
  column_bitmap= new boost::dynamic_bitset<>(table->getShare()->sizeFields());
99
80
}
100
81
 
101
82
 
135
116
      }
136
117
    }
137
118
    delete_dynamic(&ranges); /* ranges are allocated in alloc */
 
119
    delete column_bitmap;
138
120
    alloc.free_root(MYF(0));
139
121
  }
140
 
  head->column_bitmaps_set(save_read_set, save_write_set);
 
122
  head->column_bitmaps_set(*save_read_set, *save_write_set);
141
123
}
142
124
 
143
125
 
153
135
    {
154
136
      return 0;
155
137
    }
156
 
    head->column_bitmaps_set(&column_bitmap, &column_bitmap);
 
138
    head->column_bitmaps_set(*column_bitmap, *column_bitmap);
157
139
    goto end;
158
140
  }
159
141
 
179
161
    goto failure;
180
162
  }
181
163
 
182
 
  head->column_bitmaps_set(&column_bitmap, &column_bitmap);
 
164
  head->column_bitmaps_set(*column_bitmap, *column_bitmap);
183
165
 
184
166
  if (cursor->ha_external_lock(session, F_RDLCK))
185
167
    goto failure;
210
192
  }
211
193
  head->prepare_for_position();
212
194
  head->cursor= org_file;
213
 
  column_bitmap= *head->read_set;
214
 
  head->column_bitmaps_set(&column_bitmap, &column_bitmap);
 
195
  *column_bitmap|= *head->read_set;
 
196
  head->column_bitmaps_set(*column_bitmap, *column_bitmap);
215
197
 
216
198
  return 0;
217
199
 
218
200
failure:
219
 
  head->column_bitmaps_set(save_read_set, save_write_set);
 
201
  head->column_bitmaps_set(*save_read_set, *save_write_set);
220
202
  delete cursor;
221
203
  cursor= save_file;
222
204
  return 0;
288
270
      We don't need to signal the bitmap change as the bitmap is always the
289
271
      same for this head->cursor
290
272
    */
291
 
    head->column_bitmaps_set(&column_bitmap, &column_bitmap);
 
273
    head->column_bitmaps_set(*column_bitmap, *column_bitmap);
292
274
  }
293
275
 
294
276
  int result= cursor->multi_range_read_next(&dummy);
296
278
  if (in_ror_merged_scan)
297
279
  {
298
280
    /* Restore bitmaps set on entry */
299
 
    head->column_bitmaps_set(save_read_set, save_write_set);
 
281
    head->column_bitmaps_set(*save_read_set, *save_write_set);
300
282
  }
301
283
  return result;
302
284
}