~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_open.cc

  • Committer: Brian Aker
  • Date: 2010-08-17 01:34:55 UTC
  • mto: (1711.1.23 build)
  • mto: This revision was merged to the branch mainline in revision 1714.
  • Revision ID: brian@tangent.org-20100817013455-zx3nm7qilxvpwrgb
Style on structure cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* open a isam-database */
17
17
 
19
19
 
20
20
#include <string.h>
21
21
#include <algorithm>
22
 
#include <memory>
23
 
#include <boost/scoped_ptr.hpp>
24
 
#include <boost/scoped_array.hpp>
25
22
 
26
23
#include "drizzled/charset_info.h"
27
24
#include "drizzled/internal/m_string.h"
79
76
  have an open count of 0.
80
77
******************************************************************************/
81
78
 
82
 
MI_INFO *mi_open(const drizzled::identifier::Table &identifier, int mode, uint32_t open_flags)
 
79
MI_INFO *mi_open(const char *name, int mode, uint32_t open_flags)
83
80
{
84
81
  int lock_error,kfile,open_mode,save_errno,have_rtree=0;
85
82
  uint32_t i,j,len,errpos,head_length,base_pos,offset,info_length,keys,
89
86
  unsigned char *disk_cache= NULL;
90
87
  unsigned char *disk_pos, *end_pos;
91
88
  MI_INFO info,*m_info,*old_info;
92
 
  boost::scoped_ptr<MYISAM_SHARE> share_buff_ap(new MYISAM_SHARE);
93
 
  MYISAM_SHARE &share_buff= *share_buff_ap.get();
94
 
  MYISAM_SHARE *share;
95
 
  boost::scoped_array<ulong> rec_per_key_part_ap(new ulong[HA_MAX_POSSIBLE_KEY*MI_MAX_KEY_SEG]);
96
 
  ulong *rec_per_key_part= rec_per_key_part_ap.get();
 
89
  MYISAM_SHARE share_buff,*share;
 
90
  ulong rec_per_key_part[HA_MAX_POSSIBLE_KEY*MI_MAX_KEY_SEG];
97
91
  internal::my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE];
98
92
  uint64_t max_key_file_length, max_data_file_length;
99
93
 
103
97
  head_length=sizeof(share_buff.state.header);
104
98
  memset(&info, 0, sizeof(info));
105
99
 
106
 
  (void)internal::fn_format(org_name,
107
 
                            identifier.getPath().c_str(), 
108
 
                            "",
109
 
                            MI_NAME_IEXT,
110
 
                            MY_UNPACK_FILENAME);
 
100
  (void)internal::fn_format(org_name,name,"",MI_NAME_IEXT, MY_UNPACK_FILENAME);
111
101
  if (!realpath(org_name,rp_buff))
112
102
    internal::my_load_path(rp_buff,org_name, NULL);
113
103
  rp_buff[FN_REFLEN-1]= '\0';
143
133
      goto err;
144
134
    }
145
135
    share->options= mi_uint2korr(share->state.header.options);
146
 
    static const uint64_t OLD_FILE_OPTIONS= HA_OPTION_PACK_RECORD |
147
 
            HA_OPTION_PACK_KEYS |
148
 
            HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA |
149
 
            HA_OPTION_TEMP_COMPRESS_RECORD |
150
 
            HA_OPTION_TMP_TABLE;
151
 
    if (share->options & ~OLD_FILE_OPTIONS)
 
136
    if (share->options &
 
137
        ~(HA_OPTION_PACK_RECORD | HA_OPTION_PACK_KEYS |
 
138
          HA_OPTION_COMPRESS_RECORD | HA_OPTION_READ_ONLY_DATA |
 
139
          HA_OPTION_TEMP_COMPRESS_RECORD |
 
140
          HA_OPTION_TMP_TABLE
 
141
          ))
152
142
    {
153
143
      errno=HA_ERR_OLD_FILE;
154
144
      goto err;
397
387
    disk_cache= NULL;
398
388
    mi_setup_functions(share);
399
389
    share->is_log_table= false;
 
390
    thr_lock_init(&share->lock);
400
391
    if (myisam_concurrent_insert)
401
392
    {
402
393
      share->concurrent_insert=
432
423
                     share->base.max_key_length),
433
424
         &info.lastkey,share->base.max_key_length*3+1,
434
425
         &info.first_mbr_key, share->base.max_key_length,
435
 
         &info.filename, identifier.getPath().length()+1,
 
426
         &info.filename,strlen(name)+1,
436
427
         &info.rtree_recursion_state,have_rtree ? 1024 : 0,
437
428
         NULL))
438
429
    goto err;
441
432
  if (!have_rtree)
442
433
    info.rtree_recursion_state= NULL;
443
434
 
444
 
  strcpy(info.filename, identifier.getPath().c_str());
 
435
  strcpy(info.filename,name);
445
436
  memcpy(info.blobs,share->blobs,sizeof(MI_BLOB)*share->base.blobs);
446
437
  info.lastkey2=info.lastkey+share->base.max_key_length;
447
438
 
495
486
  /* Allocate buffer for one record */
496
487
 
497
488
  /* prerequisites: memset(info, 0) && info->s=share; are met. */
498
 
  if (!mi_alloc_rec_buff(&info, SIZE_MAX, &info.rec_buff))
 
489
  if (!mi_alloc_rec_buff(&info, -1, &info.rec_buff))
499
490
    goto err;
500
491
  memset(info.rec_buff, 0, mi_get_rec_buff_len(&info, info.rec_buff));
501
492
 
502
493
  *m_info=info;
 
494
  m_info->lock.init(&share->lock, (void*) m_info);
503
495
  myisam_open_list.push_front(m_info);
504
496
 
505
497
  THR_LOCK_myisam.unlock();
512
504
  if ((save_errno == HA_ERR_CRASHED) ||
513
505
      (save_errno == HA_ERR_CRASHED_ON_USAGE) ||
514
506
      (save_errno == HA_ERR_CRASHED_ON_REPAIR))
515
 
    mi_report_error(save_errno, identifier.getPath().c_str());
 
507
    mi_report_error(save_errno, name);
516
508
  switch (errpos) {
517
509
  case 6:
518
510
    free((unsigned char*) m_info);
550
542
    unsigned char *newptr = *buf;
551
543
 
552
544
    /* to simplify initial init of info->rec_buf in mi_open and mi_extra */
553
 
    if (length == SIZE_MAX)
 
545
    if (length == (ulong) -1)
554
546
    {
555
547
      if (info->s->options & HA_OPTION_COMPRESS_RECORD)
556
548
        length= max(info->s->base.pack_reclength, info->s->max_pack_length);