~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/key.cc

  • Committer: Zimin
  • Date: 2010-06-30 06:36:56 UTC
  • mto: (1643.1.5 build)
  • mto: This revision was merged to the branch mainline in revision 1644.
  • Revision ID: ziminq@gmail.com-20100630063656-5oa531u1mfyn6ybl
move the comment of 'create' in TableList as well

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
16
 
17
17
/* Functions to handle keys and fields in forms */
20
20
#include "drizzled/table.h"
21
21
#include "drizzled/key.h"
22
22
#include "drizzled/field/blob.h"
23
 
#include "drizzled/util/test.h"
24
 
 
25
 
#include <boost/dynamic_bitset.hpp>
26
23
 
27
24
#include <string>
28
25
 
211
208
      field->setReadSet();
212
209
      from_key+= HA_KEY_BLOB_LENGTH;
213
210
      key_length-= HA_KEY_BLOB_LENGTH;
214
 
      field->set_ptr_offset(to_record - field->getTable()->getInsertRecord(),
 
211
      field->set_ptr_offset(to_record - field->table->record[0],
215
212
                            (ulong) blob_length, from_key);
216
213
      length= key_part->length;
217
214
    }
218
215
    else if (key_part->key_part_flag & HA_VAR_LENGTH_PART)
219
216
    {
220
217
      Field *field= key_part->field;
221
 
      ptrdiff_t ptrdiff= to_record - field->getTable()->getInsertRecord();
 
218
      ptrdiff_t ptrdiff= to_record - field->table->record[0];
222
219
 
223
220
      field->setReadSet();
224
221
      field->setWriteSet();
277
274
 
278
275
    if (key_part->null_bit)
279
276
    {
280
 
      if (*key != test(table->getInsertRecord()[key_part->null_offset] &
 
277
      if (*key != test(table->record[0][key_part->null_offset] &
281
278
                       key_part->null_bit))
282
279
        return 1;
283
280
      if (*key)
297
294
    {
298
295
      const CHARSET_INFO * const cs= key_part->field->charset();
299
296
      uint32_t char_length= key_part->length / cs->mbmaxlen;
300
 
      const unsigned char *pos= table->getInsertRecord() + key_part->offset;
 
297
      const unsigned char *pos= table->record[0] + key_part->offset;
301
298
      if (length > char_length)
302
299
      {
303
300
        char_length= my_charpos(cs, pos, pos + length, char_length);
309
306
        return 1;
310
307
      continue;
311
308
    }
312
 
    if (memcmp(key,table->getInsertRecord()+key_part->offset,length))
 
309
    if (memcmp(key,table->record[0]+key_part->offset,length))
313
310
      return 1;
314
311
  }
315
312
  return 0;
345
342
      to->append('-');
346
343
    if (key_part->null_bit)
347
344
    {
348
 
      if (table->getInsertRecord()[key_part->null_offset] & key_part->null_bit)
 
345
      if (table->record[0][key_part->null_offset] & key_part->null_bit)
349
346
      {
350
347
        to->append(STRING_WITH_LEN("NULL"));
351
348
        continue;
355
352
    {
356
353
      const CHARSET_INFO * const cs= field->charset();
357
354
      field->setReadSet();
358
 
      field->val_str_internal(&tmp);
 
355
      field->val_str(&tmp);
359
356
      if (cs->mbmaxlen > 1 &&
360
357
          table->getField(key_part->fieldnr - 1)->field_length !=
361
358
          key_part->length)
375
372
      }
376
373
 
377
374
      if (key_part->length < field->pack_length())
378
 
        tmp.length(min(tmp.length(), static_cast<size_t>(key_part->length)));
 
375
        tmp.length(min(tmp.length(),(uint32_t)key_part->length));
379
376
      to->append(tmp);
380
377
    }
381
378
    else
402
399
    FALSE  Otherwise
403
400
*/
404
401
 
405
 
bool is_key_used(Table *table, uint32_t idx, const boost::dynamic_bitset<>& fields)
 
402
bool is_key_used(Table *table, uint32_t idx, const MyBitmap *fields)
406
403
{
407
 
  table->tmp_set.reset();
408
 
  table->mark_columns_used_by_index_no_reset(idx, table->tmp_set);
409
 
  if (table->tmp_set.is_subset_of(fields))
 
404
  table->tmp_set.clearAll();
 
405
  table->mark_columns_used_by_index_no_reset(idx, &table->tmp_set);
 
406
  if (bitmap_is_overlapping(&table->tmp_set, fields))
410
407
    return 1;
411
408
 
412
409
  /*
426
423
  Compare key in row to a given key.
427
424
 
428
425
  @param key_part               Key part handler
429
 
  @param key                    Key to compare to value in table->getInsertRecord()
 
426
  @param key                    Key to compare to value in table->record[0]
430
427
  @param key_length             length of 'key'
431
428
 
432
429
  @return