~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/quick_range_select.cc

  • Committer: Monty Taylor
  • Date: 2010-06-19 16:36:52 UTC
  • mto: This revision was merged to the branch mainline in revision 1628.
  • Revision ID: mordred@inaugust.com-20100619163652-6fej38011wsop52k
Moved password parsing code into get_password.cc.

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"
24
25
#include "drizzled/internal/m_string.h"
25
26
#include <fcntl.h>
26
27
 
34
35
                                              Table *table,
35
36
                                              uint32_t key_nr,
36
37
                                              bool no_alloc,
37
 
                                              memory::Root *parent_alloc)
 
38
                                              memory::Root *parent_alloc,
 
39
                                              bool *create_error)
38
40
  :
39
41
    cursor(NULL),
40
42
    ranges(),
41
43
    in_ror_merged_scan(false),
42
 
    column_bitmap(NULL),
 
44
    column_bitmap(),
43
45
    save_read_set(NULL),
44
46
    save_write_set(NULL),
45
47
    free_file(false),
47
49
    last_range(NULL),
48
50
    qr_traversal_ctx(),
49
51
    mrr_buf_size(0),
 
52
    mrr_buf_desc(NULL),
50
53
    key_parts(NULL),
51
54
    dont_free(false),
52
55
    mrr_flags(0),
53
56
    alloc()
54
57
{
 
58
  my_bitmap_map *bitmap= NULL;
 
59
 
55
60
  sorted= 0;
56
61
  index= key_nr;
57
62
  head= table;
60
65
 
61
66
  /* 'session' is not accessible in QuickRangeSelect::reset(). */
62
67
  mrr_buf_size= session->variables.read_rnd_buff_size;
 
68
  mrr_buf_desc= NULL;
63
69
 
64
70
  if (! no_alloc && ! parent_alloc)
65
71
  {
76
82
  record= head->record[0];
77
83
  save_read_set= head->read_set;
78
84
  save_write_set= head->write_set;
79
 
  column_bitmap= new boost::dynamic_bitset<>(table->getShare()->sizeFields());
 
85
 
 
86
  /* Allocate a bitmap for used columns. Using memory::sql_alloc instead of malloc
 
87
     simply as a "fix" to the MySQL 6.0 code that also free()s it at the
 
88
     same time we destroy the mem_root.
 
89
   */
 
90
 
 
91
  bitmap= reinterpret_cast<my_bitmap_map*>(memory::sql_alloc(head->getShare()->column_bitmap_size));
 
92
  if (! bitmap)
 
93
  {
 
94
    column_bitmap.setBitmap(NULL);
 
95
    *create_error= 1;
 
96
  }
 
97
  else
 
98
  {
 
99
    column_bitmap.init(bitmap, head->getShare()->sizeFields());
 
100
  }
80
101
}
81
102
 
82
103
 
116
137
      }
117
138
    }
118
139
    delete_dynamic(&ranges); /* ranges are allocated in alloc */
119
 
    delete column_bitmap;
120
140
    alloc.free_root(MYF(0));
121
141
  }
122
 
  head->column_bitmaps_set(*save_read_set, *save_write_set);
 
142
  head->column_bitmaps_set(save_read_set, save_write_set);
 
143
  assert(mrr_buf_desc == NULL);
 
144
  if (mrr_buf_desc)
 
145
  {
 
146
    free(mrr_buf_desc);
 
147
  }
123
148
}
124
149
 
125
150
 
135
160
    {
136
161
      return 0;
137
162
    }
138
 
    head->column_bitmaps_set(*column_bitmap, *column_bitmap);
 
163
    head->column_bitmaps_set(&column_bitmap, &column_bitmap);
139
164
    goto end;
140
165
  }
141
166
 
161
186
    goto failure;
162
187
  }
163
188
 
164
 
  head->column_bitmaps_set(*column_bitmap, *column_bitmap);
 
189
  head->column_bitmaps_set(&column_bitmap, &column_bitmap);
165
190
 
166
191
  if (cursor->ha_external_lock(session, F_RDLCK))
167
192
    goto failure;
192
217
  }
193
218
  head->prepare_for_position();
194
219
  head->cursor= org_file;
195
 
  *column_bitmap|= *head->read_set;
196
 
  head->column_bitmaps_set(*column_bitmap, *column_bitmap);
 
220
  column_bitmap= *head->read_set;
 
221
  head->column_bitmaps_set(&column_bitmap, &column_bitmap);
197
222
 
198
223
  return 0;
199
224
 
200
225
failure:
201
 
  head->column_bitmaps_set(*save_read_set, *save_write_set);
 
226
  head->column_bitmaps_set(save_read_set, save_write_set);
202
227
  delete cursor;
203
228
  cursor= save_file;
204
229
  return 0;
243
268
    There is a later assert in th code that hoped to catch random free() that might
244
269
    have done this.
245
270
  */
246
 
  assert(not (mrr_buf_size));
 
271
  assert(not (mrr_buf_size && ! mrr_buf_desc));
247
272
 
248
273
  if (sorted)
249
274
  {
270
295
      We don't need to signal the bitmap change as the bitmap is always the
271
296
      same for this head->cursor
272
297
    */
273
 
    head->column_bitmaps_set(*column_bitmap, *column_bitmap);
 
298
    head->column_bitmaps_set(&column_bitmap, &column_bitmap);
274
299
  }
275
300
 
276
301
  int result= cursor->multi_range_read_next(&dummy);
278
303
  if (in_ror_merged_scan)
279
304
  {
280
305
    /* Restore bitmaps set on entry */
281
 
    head->column_bitmaps_set(*save_read_set, *save_write_set);
 
306
    head->column_bitmaps_set(save_read_set, save_write_set);
282
307
  }
283
308
  return result;
284
309
}