~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/quick_range_select.cc

  • Committer: lbieber
  • Date: 2010-10-01 13:06:31 UTC
  • mfrom: (1802.2.2 drizzle-bug-651948)
  • mto: This revision was merged to the branch mainline in revision 1805.
  • Revision ID: lbieber@orisndriz08-20101001130631-xubscnhmj7r5dn6g
Merge Andrew - Fix bug 651948 - Index lengths not retrieved using drizzledump

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) 2008-2009 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008-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
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),
52
54
    mrr_flags(0),
53
55
    alloc()
54
56
{
 
57
  my_bitmap_map *bitmap= NULL;
 
58
 
55
59
  sorted= 0;
56
60
  index= key_nr;
57
61
  head= table;
76
80
  record= head->record[0];
77
81
  save_read_set= head->read_set;
78
82
  save_write_set= head->write_set;
79
 
  column_bitmap= new boost::dynamic_bitset<>(table->getShare()->sizeFields());
 
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
  }
80
99
}
81
100
 
82
101
 
116
135
      }
117
136
    }
118
137
    delete_dynamic(&ranges); /* ranges are allocated in alloc */
119
 
    delete column_bitmap;
120
138
    alloc.free_root(MYF(0));
121
139
  }
122
 
  head->column_bitmaps_set(*save_read_set, *save_write_set);
 
140
  head->column_bitmaps_set(save_read_set, save_write_set);
123
141
}
124
142
 
125
143
 
135
153
    {
136
154
      return 0;
137
155
    }
138
 
    head->column_bitmaps_set(*column_bitmap, *column_bitmap);
 
156
    head->column_bitmaps_set(&column_bitmap, &column_bitmap);
139
157
    goto end;
140
158
  }
141
159
 
161
179
    goto failure;
162
180
  }
163
181
 
164
 
  head->column_bitmaps_set(*column_bitmap, *column_bitmap);
 
182
  head->column_bitmaps_set(&column_bitmap, &column_bitmap);
165
183
 
166
184
  if (cursor->ha_external_lock(session, F_RDLCK))
167
185
    goto failure;
192
210
  }
193
211
  head->prepare_for_position();
194
212
  head->cursor= org_file;
195
 
  *column_bitmap|= *head->read_set;
196
 
  head->column_bitmaps_set(*column_bitmap, *column_bitmap);
 
213
  column_bitmap= *head->read_set;
 
214
  head->column_bitmaps_set(&column_bitmap, &column_bitmap);
197
215
 
198
216
  return 0;
199
217
 
200
218
failure:
201
 
  head->column_bitmaps_set(*save_read_set, *save_write_set);
 
219
  head->column_bitmaps_set(save_read_set, save_write_set);
202
220
  delete cursor;
203
221
  cursor= save_file;
204
222
  return 0;
270
288
      We don't need to signal the bitmap change as the bitmap is always the
271
289
      same for this head->cursor
272
290
    */
273
 
    head->column_bitmaps_set(*column_bitmap, *column_bitmap);
 
291
    head->column_bitmaps_set(&column_bitmap, &column_bitmap);
274
292
  }
275
293
 
276
294
  int result= cursor->multi_range_read_next(&dummy);
278
296
  if (in_ror_merged_scan)
279
297
  {
280
298
    /* Restore bitmaps set on entry */
281
 
    head->column_bitmaps_set(*save_read_set, *save_write_set);
 
299
    head->column_bitmaps_set(save_read_set, save_write_set);
282
300
  }
283
301
  return result;
284
302
}