~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_create.c

  • Committer: Monty Taylor
  • Date: 2008-07-16 19:10:24 UTC
  • mfrom: (51.1.127 remove-dbug)
  • mto: This revision was merged to the branch mainline in revision 176.
  • Revision ID: monty@inaugust.com-20080716191024-prjgoh7fbri7rx26
MergedĀ fromĀ remove-dbug.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
  ulong *rec_per_key_part;
56
56
  my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE];
57
57
  MI_CREATE_INFO tmp_create_info;
58
 
  DBUG_ENTER("mi_create");
59
 
  DBUG_PRINT("enter", ("keys: %u  columns: %u  uniques: %u  flags: %u",
60
 
                      keys, columns, uniques, flags));
61
58
 
62
59
  if (!ci)
63
60
  {
67
64
 
68
65
  if (keys + uniques > MI_MAX_KEY || columns == 0)
69
66
  {
70
 
    DBUG_RETURN(my_errno=HA_WRONG_CREATE_OPTION);
 
67
    return(my_errno=HA_WRONG_CREATE_OPTION);
71
68
  }
72
69
  errpos= 0;
73
70
  options= 0;
91
88
  if (!(rec_per_key_part=
92
89
        (ulong*) my_malloc((keys + uniques)*MI_MAX_KEY_SEG*sizeof(long),
93
90
                           MYF(MY_WME | MY_ZEROFILL))))
94
 
    DBUG_RETURN(my_errno);
 
91
    return(my_errno);
95
92
 
96
93
        /* Start by checking fields and field-types used */
97
94
 
306
303
        }
307
304
        if (keyseg->flag & HA_SPACE_PACK)
308
305
        {
309
 
          DBUG_ASSERT(!(keyseg->flag & HA_VAR_LENGTH_PART));
 
306
          assert(!(keyseg->flag & HA_VAR_LENGTH_PART));
310
307
          keydef->flag |= HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY;
311
308
          options|=HA_OPTION_PACK_KEYS;         /* Using packed keys */
312
309
          length++;                             /* At least one length byte */
319
316
        }
320
317
        if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
321
318
        {
322
 
          DBUG_ASSERT(!test_all_bits(keyseg->flag,
 
319
          assert(!test_all_bits(keyseg->flag,
323
320
                                    (HA_VAR_LENGTH_PART | HA_BLOB_PART)));
324
321
          keydef->flag|=HA_VAR_LENGTH_KEY;
325
322
          length++;                             /* At least one length byte */
409
406
                               uniques * MI_UNIQUEDEF_SIZE +
410
407
                               (key_segs + unique_key_parts)*HA_KEYSEG_SIZE+
411
408
                               columns*MI_COLUMNDEF_SIZE);
412
 
  DBUG_PRINT("info", ("info_length: %u", info_length));
413
409
  /* There are only 16 bits for the total header length. */
414
410
  if (info_length > 65535)
415
411
  {
603
599
    errpos=3;
604
600
  }
605
601
 
606
 
  DBUG_PRINT("info", ("write state info and base info"));
607
602
  if (mi_state_info_write(file, &share.state, 2) ||
608
603
      mi_base_info_write(file, &share.base))
609
604
    goto err;
610
 
#ifndef DBUG_OFF
611
 
  if ((uint) my_tell(file,MYF(0)) != base_pos+ MI_BASE_INFO_SIZE)
612
 
  {
613
 
    uint pos=(uint) my_tell(file,MYF(0));
614
 
    DBUG_PRINT("warning",("base_length: %d  != used_length: %d",
615
 
                          base_pos+ MI_BASE_INFO_SIZE, pos));
616
 
  }
617
 
#endif
618
605
 
619
606
  /* Write key and keyseg definitions */
620
 
  DBUG_PRINT("info", ("write key and keyseg definitions"));
621
607
  for (i=0 ; i < share.base.keys - uniques; i++)
622
608
  {
623
609
    uint sp_segs= 0;
649
635
  }
650
636
 
651
637
  /* Save unique definition */
652
 
  DBUG_PRINT("info", ("write unique definitions"));
653
638
  for (i=0 ; i < share.state.header.uniques ; i++)
654
639
  {
655
640
    HA_KEYSEG *keyseg_end;
680
665
        goto err;
681
666
    }
682
667
  }
683
 
  DBUG_PRINT("info", ("write field definitions"));
684
668
  for (i=0 ; i < share.base.fields ; i++)
685
669
    if (mi_recinfo_write(file, &recinfo[i]))
686
670
      goto err;
687
671
 
688
 
#ifndef DBUG_OFF
689
 
  if ((uint) my_tell(file,MYF(0)) != info_length)
690
 
  {
691
 
    uint pos= (uint) my_tell(file,MYF(0));
692
 
    DBUG_PRINT("warning",("info_length: %d  != used_length: %d",
693
 
                          info_length, pos));
694
 
  }
695
 
#endif
696
 
 
697
672
        /* Enlarge files */
698
 
  DBUG_PRINT("info", ("enlarge to keystart: %lu", (ulong) share.base.keystart));
699
673
  if (ftruncate(file, (off_t) share.base.keystart))
700
674
    goto err;
701
675
 
714
688
  if (my_close(file,MYF(0)))
715
689
    goto err;
716
690
  my_free((char*) rec_per_key_part,MYF(0));
717
 
  DBUG_RETURN(0);
 
691
  return(0);
718
692
 
719
693
err:
720
694
  pthread_mutex_unlock(&THR_LOCK_myisam);
738
712
                             MYF(0));
739
713
  }
740
714
  my_free((char*) rec_per_key_part, MYF(0));
741
 
  DBUG_RETURN(my_errno=save_errno);             /* return the fatal errno */
 
715
  return(my_errno=save_errno);          /* return the fatal errno */
742
716
}
743
717
 
744
718
 
745
719
uint mi_get_pointer_length(uint64_t file_length, uint def)
746
720
{
747
 
  DBUG_ASSERT(def >= 2 && def <= 7);
 
721
  assert(def >= 2 && def <= 7);
748
722
  if (file_length)                              /* If not default */
749
723
  {
750
724
#ifdef NOT_YET_READY_FOR_8_BYTE_POINTERS