~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.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:
7827
7827
                  table->file->primary_key_is_clustered())
7828
7828
                tab->index= table->s->primary_key;
7829
7829
              else
7830
 
                tab->index=find_shortest_key(table, & table->covering_keys);
 
7830
                tab->index= table->find_shortest_key(&table->covering_keys);
7831
7831
            }
7832
7832
            tab->read_first_record= join_read_first;
7833
7833
            tab->type=JT_NEXT;          // Read with index_first / index_next
12656
12656
}
12657
12657
 
12658
12658
 
12659
 
uint find_shortest_key(Table *table, const key_map *usable_keys)
12660
 
{
12661
 
  uint min_length= (uint) ~0;
12662
 
  uint best= MAX_KEY;
12663
 
  if (!usable_keys->is_clear_all())
12664
 
  {
12665
 
    for (uint nr=0; nr < table->s->keys ; nr++)
12666
 
    {
12667
 
      if (usable_keys->is_set(nr))
12668
 
      {
12669
 
        if (table->key_info[nr].key_length < min_length)
12670
 
        {
12671
 
          min_length=table->key_info[nr].key_length;
12672
 
          best=nr;
12673
 
        }
12674
 
      }
12675
 
    }
12676
 
  }
12677
 
  return best;
12678
 
}
12679
 
 
12680
12659
/**
12681
12660
  Test if a second key is the subkey of the first one.
12682
12661
 
13445
13424
  return(-1);
13446
13425
}
13447
13426
 
13448
 
/*****************************************************************************
13449
 
  Remove duplicates from tmp table
13450
 
  This should be recoded to add a unique index to the table and remove
13451
 
  duplicates
13452
 
  Table is a locked single thread table
13453
 
  fields is the number of fields to check (from the end)
13454
 
*****************************************************************************/
13455
 
 
13456
 
static bool compare_record(Table *table, Field **ptr)
13457
 
{
13458
 
  for (; *ptr ; ptr++)
13459
 
  {
13460
 
    if ((*ptr)->cmp_offset(table->s->rec_buff_length))
13461
 
      return 1;
13462
 
  }
13463
 
  return 0;
13464
 
}
13465
 
 
13466
13427
static bool copy_blobs(Field **ptr)
13467
13428
{
13468
13429
  for (; *ptr ; ptr++)
13590
13551
          break;
13591
13552
        goto err;
13592
13553
      }
13593
 
      if (compare_record(table, first_field) == 0)
 
13554
      if (table->compare_record(first_field) == 0)
13594
13555
      {
13595
13556
        if ((error=file->ha_delete_row(record)))
13596
13557
          goto err;