~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/heap/ha_heap.cc

  • Committer: Brian Aker
  • Date: 2010-05-20 06:34:25 UTC
  • mto: (1552.1.1 new-staging)
  • mto: This revision was merged to the branch mainline in revision 1553.
  • Revision ID: brian@gaz-20100520063425-0hwu5fx4fmmp2g49
Partial encapsulation of TableShare from Table.

Show diffs side-by-side

added added

removed removed

Lines of Context:
229
229
      ha_heap::info(), which is always called before key statistics are
230
230
      used.
231
231
    */
232
 
    key_stat_version= file->s->key_stat_version-1;
 
232
    key_stat_version= file->s->key_stat_version - 1;
233
233
  }
234
234
  return (file ? 0 : 1);
235
235
}
245
245
 
246
246
  DESCRIPTION
247
247
    Do same as default implementation but use file->s->name instead of
248
 
    table->s->path. This is needed by Windows where the clone() call sees
249
 
    '/'-delimited path in table->s->path, while ha_peap::open() was called
 
248
    table->getShare()->path. This is needed by Windows where the clone() call sees
 
249
    '/'-delimited path in table->getShare()->path, while ha_peap::open() was called
250
250
    with '\'-delimited path.
251
251
*/
252
252
 
253
253
Cursor *ha_heap::clone(memory::Root *mem_root)
254
254
{
255
 
  Cursor *new_handler= table->s->db_type()->getCursor(*table->s, mem_root);
 
255
  Cursor *new_handler= table->getMutableShare()->db_type()->getCursor(*(table->getMutableShare()), mem_root);
256
256
 
257
257
  if (new_handler && !new_handler->ha_open(table, file->s->name, table->db_stat,
258
258
                                           HA_OPEN_IGNORE_IF_LOCKED))
287
287
void ha_heap::set_keys_for_scanning(void)
288
288
{
289
289
  btree_keys.reset();
290
 
  for (uint32_t i= 0 ; i < table->s->keys ; i++)
 
290
  for (uint32_t i= 0 ; i < table->getShare()->keys ; i++)
291
291
  {
292
292
    if (table->key_info[i].algorithm == HA_KEY_ALG_BTREE)
293
293
      btree_keys.set(i);
297
297
 
298
298
void ha_heap::update_key_stats()
299
299
{
300
 
  for (uint32_t i= 0; i < table->s->keys; i++)
 
300
  for (uint32_t i= 0; i < table->getShare()->keys; i++)
301
301
  {
302
302
    KeyInfo *key=table->key_info+i;
303
303
    if (!key->rec_per_key)
368
368
  int res;
369
369
  ha_statistic_increment(&system_status_var::ha_delete_count);
370
370
  res= heap_delete(file,buf);
371
 
  if (!res && table->s->tmp_table == message::Table::STANDARD &&
 
371
  if (!res && table->getShare()->tmp_table == message::Table::STANDARD &&
372
372
      ++records_changed*MEMORY_STATS_UPDATE_THRESHOLD > file->s->records)
373
373
  {
374
374
    /*
526
526
int ha_heap::delete_all_rows()
527
527
{
528
528
  heap_clear(file);
529
 
  if (table->s->tmp_table == message::Table::STANDARD)
 
529
  if (table->getShare()->tmp_table == message::Table::STANDARD)
530
530
  {
531
531
    /*
532
532
       We can perform this safely since only one writer at the time is
709
709
                                  message::Table &create_proto,
710
710
                                  HP_SHARE **internal_share)
711
711
{
712
 
  uint32_t key, parts, mem_per_row_keys= 0, keys= table_arg->s->keys;
 
712
  uint32_t key, parts, mem_per_row_keys= 0, keys= table_arg->getShare()->keys;
713
713
  uint32_t auto_key= 0, auto_key_type= 0;
714
714
  uint32_t max_key_fieldnr = 0, key_part_size = 0, next_field_pos = 0;
715
 
  uint32_t column_idx, column_count= table_arg->s->fields;
 
715
  uint32_t column_idx, column_count= table_arg->getShare()->fields;
716
716
  HP_COLUMNDEF *columndef;
717
717
  HP_KEYDEF *keydef;
718
718
  HA_KEYSEG *seg;
719
719
  char buff[FN_REFLEN];
720
720
  int error;
721
 
  TableShare *share= table_arg->s;
722
721
  bool found_real_auto_increment= 0;
723
722
 
724
723
  /* 
727
726
   * can return a number more than that, we trap it here instead of casting
728
727
   * to a truncated integer.
729
728
   */
730
 
  uint64_t num_rows= share->getMaxRows();
 
729
  uint64_t num_rows= table_arg->getShare()->getMaxRows();
731
730
  if (num_rows > UINT32_MAX)
732
731
    return -1;
733
732
 
843
842
      }
844
843
      if (field->flags & AUTO_INCREMENT_FLAG &&
845
844
          table_arg->found_next_number_field &&
846
 
          key == share->next_number_index)
 
845
          key == table_arg->getShare()->next_number_index)
847
846
      {
848
847
        /*
849
848
          Store key number and type for found auto_increment key
860
859
    }
861
860
  }
862
861
 
863
 
  if (key_part_size < share->null_bytes + ((share->last_null_bit_pos+7) >> 3))
 
862
  if (key_part_size < table_arg->getShare()->null_bytes + ((table_arg->getShare()->last_null_bit_pos+7) >> 3))
864
863
  {
865
864
    /* Make sure to include null fields regardless of the presense of keys */
866
 
    key_part_size = share->null_bytes + ((share->last_null_bit_pos+7) >> 3);
 
865
    key_part_size = table_arg->getShare()->null_bytes + ((table_arg->getShare()->last_null_bit_pos+7) >> 3);
867
866
  }
868
867
 
869
868
 
870
869
 
871
870
  if (table_arg->found_next_number_field)
872
871
  {
873
 
    keydef[share->next_number_index].flag|= HA_AUTO_KEY;
874
 
    found_real_auto_increment= share->next_number_key_offset == 0;
 
872
    keydef[table_arg->getShare()->next_number_index].flag|= HA_AUTO_KEY;
 
873
    found_real_auto_increment= table_arg->getShare()->next_number_key_offset == 0;
875
874
  }
876
875
  HP_CREATE_INFO hp_create_info;
877
876
  hp_create_info.auto_key= auto_key;
881
880
  hp_create_info.max_table_size=session->variables.max_heap_table_size;
882
881
  hp_create_info.with_auto_increment= found_real_auto_increment;
883
882
  hp_create_info.internal_table= internal_table;
884
 
  hp_create_info.max_chunk_size= share->block_size;
885
 
  hp_create_info.is_dynamic= (share->row_type == ROW_TYPE_DYNAMIC);
 
883
  hp_create_info.max_chunk_size= table_arg->getShare()->block_size;
 
884
  hp_create_info.is_dynamic= (table_arg->getShare()->row_type == ROW_TYPE_DYNAMIC);
886
885
 
887
886
  error= heap_create(internal::fn_format(buff,table_name,"","",
888
887
                              MY_REPLACE_EXT|MY_UNPACK_FILENAME),
889
888
                    keys, keydef,
890
889
                    column_count, columndef,
891
890
                    max_key_fieldnr, key_part_size,
892
 
                    share->reclength, mem_per_row_keys,
 
891
                    table_arg->getShare()->reclength, mem_per_row_keys,
893
892
                    static_cast<uint32_t>(num_rows), /* We check for overflow above, so cast is fine here. */
894
893
                    0, // Factor out MIN
895
894
                    &hp_create_info, internal_share);