~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/ha_myisam.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:
216
216
  MI_KEYDEF *keydef;
217
217
  MI_COLUMNDEF *recinfo, *recinfo_pos;
218
218
  HA_KEYSEG *keyseg;
219
 
  TableShare *share= table_arg->s;
 
219
  TableShare *share= table_arg->getMutableShare();
220
220
  uint32_t options= share->db_options_in_use;
221
221
  if (!(memory::multi_malloc(false,
222
222
          recinfo_out, (share->fields * 2 + 2) * sizeof(MI_COLUMNDEF),
590
590
  if (!(file=mi_open(name, mode, test_if_locked)))
591
591
    return (errno ? errno : -1);
592
592
 
593
 
  if (!table->s->tmp_table) /* No need to perform a check for tmp table */
 
593
  if (!table->getShare()->tmp_table) /* No need to perform a check for tmp table */
594
594
  {
595
595
    if ((errno= table2myisam(table, &keyinfo, &recinfo, &recs)))
596
596
    {
597
597
      goto err;
598
598
    }
599
 
    if (check_definition(keyinfo, recinfo, table->s->keys, recs,
 
599
    if (check_definition(keyinfo, recinfo, table->getShare()->keys, recs,
600
600
                         file->s->keyinfo, file->s->rec,
601
601
                         file->s->base.keys, file->s->base.fields, true))
602
602
    {
611
611
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
612
612
  if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
613
613
    mi_extra(file, HA_EXTRA_WAIT_LOCK, 0);
614
 
  if (!table->s->db_record_offset)
 
614
  if (!table->getShare()->db_record_offset)
615
615
    is_ordered= false;
616
616
 
617
617
 
618
618
  keys_with_parts.reset();
619
 
  for (i= 0; i < table->s->keys; i++)
 
619
  for (i= 0; i < table->getShare()->keys; i++)
620
620
  {
621
621
    table->key_info[i].block_size= file->s->keyinfo[i].block_length;
622
622
 
692
692
  {
693
693
    errmsg_printf(ERRMSG_LVL_INFO, "Retrying repair of: '%s' failed. "
694
694
                          "Please try REPAIR EXTENDED or myisamchk",
695
 
                          table->s->getPath());
 
695
                          table->getShare()->getPath());
696
696
    return(HA_ADMIN_FAILED);
697
697
  }
698
698
 
699
 
  param.db_name=    table->s->getSchemaName();
 
699
  param.db_name=    table->getShare()->getSchemaName();
700
700
  param.table_name= table->alias;
701
701
  param.tmpfile_createflag = O_RDWR | O_TRUNC;
702
702
  param.using_global_keycache = 1;
706
706
  strcpy(fixed_name,file->filename);
707
707
 
708
708
  // Don't lock tables if we have used LOCK Table
709
 
  if (mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))
 
709
  if (mi_lock_database(file, table->getShare()->tmp_table ? F_EXTRA_LCK : F_WRLCK))
710
710
  {
711
711
    mi_check_print_error(&param,ER(ER_CANT_LOCK),errno);
712
712
    return(HA_ADMIN_FAILED);
1230
1230
  }
1231
1231
  if (flag & HA_STATUS_CONST)
1232
1232
  {
1233
 
    TableShare *share= table->s;
 
1233
    TableShare *share= table->getMutableShare();
1234
1234
    stats.max_data_file_length=  misam_info.max_data_file_length;
1235
1235
    stats.max_index_file_length= misam_info.max_index_file_length;
1236
1236
    stats.create_time= misam_info.create_time;
1358
1358
int ha_myisam::external_lock(Session *session, int lock_type)
1359
1359
{
1360
1360
  file->in_use= session;
1361
 
  return mi_lock_database(file, !table->s->tmp_table ?
 
1361
  return mi_lock_database(file, !table->getShare()->tmp_table ?
1362
1362
                          lock_type : ((lock_type == F_UNLCK) ?
1363
1363
                                       F_UNLCK : F_EXTRA_LCK));
1364
1364
}
1374
1374
  MI_KEYDEF *keydef;
1375
1375
  MI_COLUMNDEF *recinfo;
1376
1376
  MI_CREATE_INFO create_info;
1377
 
  TableShare *share= table_arg.s;
 
1377
  TableShare *share= table_arg.getMutableShare();
1378
1378
  uint32_t options= share->db_options_in_use;
1379
1379
  if ((error= table2myisam(&table_arg, &keydef, &recinfo, &create_records)))
1380
1380
    return(error);
1429
1429
  int error;
1430
1430
  unsigned char key[MI_MAX_KEY_LENGTH];
1431
1431
 
1432
 
  if (!table->s->next_number_key_offset)
 
1432
  if (!table->getShare()->next_number_key_offset)
1433
1433
  {                                             // Autoincrement at key-start
1434
1434
    ha_myisam::info(HA_STATUS_AUTO);
1435
1435
    *first_value= stats.auto_increment_value;
1439
1439
  }
1440
1440
 
1441
1441
  /* it's safe to call the following if bulk_insert isn't on */
1442
 
  mi_flush_bulk_insert(file, table->s->next_number_index);
 
1442
  mi_flush_bulk_insert(file, table->getShare()->next_number_index);
1443
1443
 
1444
1444
  (void) extra(HA_EXTRA_KEYREAD);
1445
1445
  key_copy(key, table->record[0],
1446
 
           table->key_info + table->s->next_number_index,
1447
 
           table->s->next_number_key_offset);
1448
 
  error= mi_rkey(file, table->record[1], (int) table->s->next_number_index,
1449
 
                 key, make_prev_keypart_map(table->s->next_number_keypart),
 
1446
           table->key_info + table->getShare()->next_number_index,
 
1447
           table->getShare()->next_number_key_offset);
 
1448
  error= mi_rkey(file, table->record[1], (int) table->getShare()->next_number_index,
 
1449
                 key, make_prev_keypart_map(table->getShare()->next_number_keypart),
1450
1450
                 HA_READ_PREFIX_LAST);
1451
1451
  if (error)
1452
1452
    nr= 1;
1454
1454
  {
1455
1455
    /* Get data from record[1] */
1456
1456
    nr= ((uint64_t) table->next_number_field->
1457
 
         val_int_offset(table->s->rec_buff_length)+1);
 
1457
         val_int_offset(table->getShare()->rec_buff_length)+1);
1458
1458
  }
1459
1459
  extra(HA_EXTRA_NO_KEYREAD);
1460
1460
  *first_value= nr;