~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Brian Aker
  • Date: 2008-08-19 22:40:04 UTC
  • Revision ID: brian@tangent.org-20080819224004-tcgp7mptob0jkfmc
More Table cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
4666
4666
  read_set->bitmap= old;
4667
4667
}
4668
4668
 
 
4669
uint Table::find_shortest_key(const key_map *usable_keys)
 
4670
{
 
4671
  uint min_length= (uint) ~0;
 
4672
  uint best= MAX_KEY;
 
4673
  if (!usable_keys->is_clear_all())
 
4674
  {
 
4675
    for (uint nr=0; nr < s->keys ; nr++)
 
4676
    {
 
4677
      if (usable_keys->is_set(nr))
 
4678
      {
 
4679
        if (key_info[nr].key_length < min_length)
 
4680
        {
 
4681
          min_length= key_info[nr].key_length;
 
4682
          best=nr;
 
4683
        }
 
4684
      }
 
4685
    }
 
4686
  }
 
4687
  return best;
 
4688
}
 
4689
 
 
4690
/*****************************************************************************
 
4691
  Remove duplicates from tmp table
 
4692
  This should be recoded to add a unique index to the table and remove
 
4693
  duplicates
 
4694
  Table is a locked single thread table
 
4695
  fields is the number of fields to check (from the end)
 
4696
*****************************************************************************/
 
4697
 
 
4698
bool Table::compare_record(Field **ptr)
 
4699
{
 
4700
  for (; *ptr ; ptr++)
 
4701
  {
 
4702
    if ((*ptr)->cmp_offset(s->rec_buff_length))
 
4703
      return true;
 
4704
  }
 
4705
  return false;
 
4706
}
 
4707
 
 
4708
/* Return false if row hasn't changed */
 
4709
 
 
4710
bool Table::compare_record()
 
4711
{
 
4712
  if (s->blob_fields + s->varchar_fields == 0)
 
4713
    return cmp_record(this, record[1]);
 
4714
  /* Compare null bits */
 
4715
  if (memcmp(null_flags,
 
4716
             null_flags + s->rec_buff_length,
 
4717
             s->null_bytes))
 
4718
    return true;                                // Diff in NULL value
 
4719
  /* Compare updated fields */
 
4720
  for (Field **ptr= field ; *ptr ; ptr++)
 
4721
  {
 
4722
    if (bitmap_is_set(write_set, (*ptr)->field_index) &&
 
4723
        (*ptr)->cmp_binary_offset(s->rec_buff_length))
 
4724
      return true;
 
4725
  }
 
4726
  return false;
 
4727
}
 
4728
 
 
4729
 
 
4730
 
 
4731
 
4669
4732
 
4670
4733
/*****************************************************************************
4671
4734
  The different ways to read a record