~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_open.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
  have an open count of 0.
77
77
******************************************************************************/
78
78
 
79
 
MI_INFO *mi_open(const char *name, int mode, uint32_t open_flags)
 
79
MI_INFO *mi_open(const drizzled::TableIdentifier &identifier, int mode, uint32_t open_flags)
80
80
{
81
81
  int lock_error,kfile,open_mode,save_errno,have_rtree=0;
82
82
  uint32_t i,j,len,errpos,head_length,base_pos,offset,info_length,keys,
97
97
  head_length=sizeof(share_buff.state.header);
98
98
  memset(&info, 0, sizeof(info));
99
99
 
100
 
  (void)internal::fn_format(org_name,name,"",MI_NAME_IEXT, MY_UNPACK_FILENAME);
 
100
  (void)internal::fn_format(org_name,
 
101
                            identifier.getPath().c_str(), 
 
102
                            "",
 
103
                            MI_NAME_IEXT,
 
104
                            MY_UNPACK_FILENAME);
101
105
  if (!realpath(org_name,rp_buff))
102
106
    internal::my_load_path(rp_buff,org_name, NULL);
103
107
  rp_buff[FN_REFLEN-1]= '\0';
104
108
  strcpy(name_buff,rp_buff);
105
 
  pthread_mutex_lock(&THR_LOCK_myisam);
 
109
  THR_LOCK_myisam.lock();
106
110
  if (!(old_info=test_if_reopen(name_buff)))
107
111
  {
108
112
    share= &share_buff;
110
114
    share_buff.state.rec_per_key_part=rec_per_key_part;
111
115
    share_buff.state.key_root=key_root;
112
116
    share_buff.state.key_del=key_del;
113
 
    share_buff.key_cache= dflt_key_cache;
 
117
    share_buff.setKeyCache();
114
118
 
115
119
    if ((kfile=internal::my_open(name_buff,(open_mode=O_RDWR),MYF(0))) < 0)
116
120
    {
247
251
           &share->state.key_root,keys*sizeof(uint64_t),
248
252
           &share->state.key_del,
249
253
           (share->state.header.max_block_size_index*sizeof(uint64_t)),
250
 
           &share->key_root_lock,sizeof(pthread_rwlock_t)*keys,
251
 
           &share->mmap_lock,sizeof(pthread_rwlock_t),
252
254
           NULL))
253
255
      goto err;
254
256
    errpos=4;
389
391
    disk_cache= NULL;
390
392
    mi_setup_functions(share);
391
393
    share->is_log_table= false;
392
 
    thr_lock_init(&share->lock);
393
 
    pthread_mutex_init(&share->intern_lock,MY_MUTEX_INIT_FAST);
394
 
    for (i=0; i<keys; i++)
395
 
      pthread_rwlock_init(&share->key_root_lock[i], NULL);
396
 
    pthread_rwlock_init(&share->mmap_lock, NULL);
397
 
    if (!thr_lock_inited)
398
 
    {
399
 
      /* Probably a single threaded program; Don't use concurrent inserts */
400
 
      myisam_concurrent_insert=0;
401
 
    }
402
 
    else if (myisam_concurrent_insert)
 
394
    if (myisam_concurrent_insert)
403
395
    {
404
396
      share->concurrent_insert=
405
397
        ((share->options & (HA_OPTION_READ_ONLY_DATA | HA_OPTION_TMP_TABLE |
408
400
         (open_flags & HA_OPEN_TMP_TABLE) || have_rtree) ? 0 : 1;
409
401
      if (share->concurrent_insert)
410
402
      {
411
 
        share->lock.get_status= mi_get_status;
412
 
        share->lock.copy_status= mi_copy_status;
413
 
        share->lock.update_status= mi_update_status;
414
 
        share->lock.restore_status= mi_restore_status;
415
 
        share->lock.check_status= mi_check_status;
 
403
        assert(0);
416
404
      }
417
405
    }
418
406
  }
438
426
                     share->base.max_key_length),
439
427
         &info.lastkey,share->base.max_key_length*3+1,
440
428
         &info.first_mbr_key, share->base.max_key_length,
441
 
         &info.filename,strlen(name)+1,
 
429
         &info.filename, identifier.getPath().length()+1,
442
430
         &info.rtree_recursion_state,have_rtree ? 1024 : 0,
443
431
         NULL))
444
432
    goto err;
447
435
  if (!have_rtree)
448
436
    info.rtree_recursion_state= NULL;
449
437
 
450
 
  strcpy(info.filename,name);
 
438
  strcpy(info.filename, identifier.getPath().c_str());
451
439
  memcpy(info.blobs,share->blobs,sizeof(MI_BLOB)*share->base.blobs);
452
440
  info.lastkey2=info.lastkey+share->base.max_key_length;
453
441
 
468
456
  info.bulk_insert=0;
469
457
  info.errkey= -1;
470
458
  info.page_changed=1;
471
 
  pthread_mutex_lock(&share->intern_lock);
472
459
  info.read_record=share->read_record;
473
460
  share->reopen++;
474
461
  share->write_flag=MYF(MY_NABP | MY_WAIT_IF_FULL);
498
485
 
499
486
  share->delay_key_write= 1;
500
487
  info.state= &share->state.state;      /* Change global values by default */
501
 
  pthread_mutex_unlock(&share->intern_lock);
502
488
 
503
489
  /* Allocate buffer for one record */
504
490
 
508
494
  memset(info.rec_buff, 0, mi_get_rec_buff_len(&info, info.rec_buff));
509
495
 
510
496
  *m_info=info;
511
 
  thr_lock_data_init(&share->lock,&m_info->lock,(void*) m_info);
512
497
  myisam_open_list.push_front(m_info);
513
498
 
514
 
  pthread_mutex_unlock(&THR_LOCK_myisam);
 
499
  THR_LOCK_myisam.unlock();
515
500
  return(m_info);
516
501
 
517
502
err:
521
506
  if ((save_errno == HA_ERR_CRASHED) ||
522
507
      (save_errno == HA_ERR_CRASHED_ON_USAGE) ||
523
508
      (save_errno == HA_ERR_CRASHED_ON_REPAIR))
524
 
    mi_report_error(save_errno, name);
 
509
    mi_report_error(save_errno, identifier.getPath().c_str());
525
510
  switch (errpos) {
526
511
  case 6:
527
512
    free((unsigned char*) m_info);
543
528
  default:
544
529
    break;
545
530
  }
546
 
  pthread_mutex_unlock(&THR_LOCK_myisam);
 
531
  THR_LOCK_myisam.unlock();
547
532
  errno=save_errno;
548
533
  return (NULL);
549
534
} /* mi_open */