~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_create.cc

  • Committer: Lee Bieber
  • Date: 2010-01-30 23:42:02 UTC
  • mto: This revision was merged to the branch mainline in revision 1282.
  • Revision ID: lbieber@lee-biebers-macbook-pro.local-20100130234202-sxmqfteqwiq15ptg
add target to japanese tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include "myisam_priv.h"
19
19
#include "drizzled/internal/my_bit.h"
20
 
#include "drizzled/internal/my_sys.h"
21
20
 
22
21
#include "drizzled/util/test.h"
23
22
#include "drizzled/global_charset_info.h"
24
 
#include "drizzled/error.h"
 
23
#include "drizzled/my_error.h"
25
24
 
26
25
#include <cassert>
27
26
#include <algorithm>
28
27
 
29
28
using namespace std;
30
 
using namespace drizzled;
31
29
 
32
30
/*
33
31
  Old options is used when recreating database, from myisamchk
58
56
  HA_KEYSEG *keyseg,tmp_keyseg;
59
57
  MI_COLUMNDEF *rec;
60
58
  ulong *rec_per_key_part;
61
 
  internal::my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE];
 
59
  my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE];
62
60
  MI_CREATE_INFO tmp_create_info;
63
61
 
64
62
  if (!ci)
395
393
  {
396
394
    my_printf_error(0, "MyISAM table '%s' has too many columns and/or "
397
395
                    "indexes and/or unique constraints.",
398
 
                    MYF(0), name + internal::dirname_length(name));
 
396
                    MYF(0), name + dirname_length(name));
399
397
    errno= HA_WRONG_CREATE_OPTION;
400
398
    goto err;
401
399
  }
458
456
 
459
457
  /* max_data_file_length and max_key_file_length are recalculated on open */
460
458
  if (options & HA_OPTION_TMP_TABLE)
461
 
    share.base.max_data_file_length=(internal::my_off_t) ci->data_file_length;
 
459
    share.base.max_data_file_length=(my_off_t) ci->data_file_length;
462
460
 
463
461
  share.base.min_block_length=
464
462
    (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
472
470
 
473
471
  /*
474
472
    NOTE: For test_if_reopen() we need a real path name. Hence we need
475
 
    MY_RETURN_REAL_PATH for every internal::fn_format(filename, ...).
 
473
    MY_RETURN_REAL_PATH for every fn_format(filename, ...).
476
474
  */
477
475
  if (ci->index_file_name)
478
476
  {
484
482
      /* chop off the table name, tempory tables use generated name */
485
483
      if ((path= strrchr((char *)ci->index_file_name, FN_LIBCHAR)))
486
484
        *path= '\0';
487
 
      internal::fn_format(filename, name, ci->index_file_name, MI_NAME_IEXT,
 
485
      fn_format(filename, name, ci->index_file_name, MI_NAME_IEXT,
488
486
                MY_REPLACE_DIR | MY_UNPACK_FILENAME |
489
487
                MY_RETURN_REAL_PATH | MY_APPEND_EXT);
490
488
    }
491
489
    else
492
490
    {
493
 
      internal::fn_format(filename, ci->index_file_name, "", MI_NAME_IEXT,
 
491
      fn_format(filename, ci->index_file_name, "", MI_NAME_IEXT,
494
492
                MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
495
493
                (have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
496
494
    }
497
 
    internal::fn_format(linkname, name, "", MI_NAME_IEXT,
 
495
    fn_format(linkname, name, "", MI_NAME_IEXT,
498
496
              MY_UNPACK_FILENAME|MY_APPEND_EXT);
499
497
    linkname_ptr=linkname;
500
498
    /*
507
505
  {
508
506
    char *iext= strrchr((char *)name, '.');
509
507
    int have_iext= iext && !strcmp(iext, MI_NAME_IEXT);
510
 
    internal::fn_format(filename, name, "", MI_NAME_IEXT,
 
508
    fn_format(filename, name, "", MI_NAME_IEXT,
511
509
              MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
512
510
              (have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
513
511
    linkname_ptr=0;
529
527
  {
530
528
    my_printf_error(0, "MyISAM table '%s' is in use "
531
529
                    "(most likely by a MERGE table). Try FLUSH TABLES.",
532
 
                    MYF(0), name + internal::dirname_length(name));
 
530
                    MYF(0), name + dirname_length(name));
533
531
    errno= HA_ERR_TABLE_EXIST;
534
532
    goto err;
535
533
  }
536
534
 
537
 
  if ((file= internal::my_create_with_symlink(linkname_ptr,
538
 
                                              filename,
539
 
                                              0,
540
 
                                              create_mode,
541
 
                                              MYF(MY_WME | create_flag))) < 0)
 
535
  if ((file= my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
 
536
                                    MYF(MY_WME | create_flag))) < 0)
542
537
    goto err;
543
538
  errpos=1;
544
539
 
556
551
          /* chop off the table name, tempory tables use generated name */
557
552
          if ((path= strrchr((char *)ci->data_file_name, FN_LIBCHAR)))
558
553
            *path= '\0';
559
 
          internal::fn_format(filename, name, ci->data_file_name, MI_NAME_DEXT,
 
554
          fn_format(filename, name, ci->data_file_name, MI_NAME_DEXT,
560
555
                    MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_APPEND_EXT);
561
556
        }
562
557
        else
563
558
        {
564
 
          internal::fn_format(filename, ci->data_file_name, "", MI_NAME_DEXT,
 
559
          fn_format(filename, ci->data_file_name, "", MI_NAME_DEXT,
565
560
                    MY_UNPACK_FILENAME |
566
561
                    (have_dext ? MY_REPLACE_EXT : MY_APPEND_EXT));
567
562
        }
568
563
 
569
 
        internal::fn_format(linkname, name, "",MI_NAME_DEXT,
 
564
        fn_format(linkname, name, "",MI_NAME_DEXT,
570
565
                  MY_UNPACK_FILENAME | MY_APPEND_EXT);
571
566
        linkname_ptr=linkname;
572
567
        create_flag=0;
573
568
      }
574
569
      else
575
570
      {
576
 
        internal::fn_format(filename,name,"", MI_NAME_DEXT,
 
571
        fn_format(filename,name,"", MI_NAME_DEXT,
577
572
                  MY_UNPACK_FILENAME | MY_APPEND_EXT);
578
573
        linkname_ptr=0;
579
574
        create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
580
575
      }
581
 
      if ((dfile= internal::my_create_with_symlink(linkname_ptr,
582
 
                                                   filename, 0, create_mode,
583
 
                                                   MYF(MY_WME | create_flag))) < 0)
 
576
      if ((dfile=
 
577
           my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
 
578
                                  MYF(MY_WME | create_flag))) < 0)
584
579
        goto err;
585
580
    }
586
581
    errpos=3;
667
662
      goto err;
668
663
#endif
669
664
    errpos=2;
670
 
    if (internal::my_close(dfile,MYF(0)))
 
665
    if (my_close(dfile,MYF(0)))
671
666
      goto err;
672
667
  }
673
668
  errpos=0;
674
669
  pthread_mutex_unlock(&THR_LOCK_myisam);
675
 
  if (internal::my_close(file,MYF(0)))
 
670
  if (my_close(file,MYF(0)))
676
671
    goto err;
677
672
  free((char*) rec_per_key_part);
678
673
  return(0);
682
677
  save_errno=errno;
683
678
  switch (errpos) {
684
679
  case 3:
685
 
    internal::my_close(dfile,MYF(0));
 
680
    my_close(dfile,MYF(0));
686
681
    /* fall through */
687
682
  case 2:
688
683
  if (! (flags & HA_DONT_TOUCH_DATA))
689
 
    internal::my_delete_with_symlink(internal::fn_format(filename,name,"",MI_NAME_DEXT,
 
684
    my_delete_with_symlink(fn_format(filename,name,"",MI_NAME_DEXT,
690
685
                                     MY_UNPACK_FILENAME | MY_APPEND_EXT),
691
686
                           MYF(0));
692
687
    /* fall through */
693
688
  case 1:
694
 
    internal::my_close(file,MYF(0));
 
689
    my_close(file,MYF(0));
695
690
    if (! (flags & HA_DONT_TOUCH_DATA))
696
 
      internal::my_delete_with_symlink(internal::fn_format(filename,name,"",MI_NAME_IEXT,
 
691
      my_delete_with_symlink(fn_format(filename,name,"",MI_NAME_IEXT,
697
692
                                       MY_UNPACK_FILENAME | MY_APPEND_EXT),
698
693
                             MYF(0));
699
694
  }