~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Monty Taylor
  • Date: 2009-02-17 05:44:23 UTC
  • mfrom: (887 drizzle)
  • mto: This revision was merged to the branch mainline in revision 888.
  • Revision ID: mordred@inaugust.com-20090217054423-u7e8vcwb5vsfdgt5
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
522
522
    table_options.key_block_size() : 0;
523
523
 
524
524
  share->fields= table.field_size();
 
525
  share->vfields= 0;
 
526
  share->stored_fields= share->fields;
 
527
 
 
528
/*  share->field= (Field**) alloc_root(&share->mem_root,
 
529
                                     (share->fields * sizeof(Field*)));
 
530
 
 
531
*/
525
532
 
526
533
  return 0;
527
534
}
712
719
  uint32_t db_create_options, keys, key_parts, n_length;
713
720
  uint32_t key_info_length, com_length, null_bit_pos=0;
714
721
  uint32_t vcol_screen_length;
715
 
  uint32_t extra_rec_buf_length;
716
722
  uint32_t i,j;
717
723
  bool use_hash;
718
724
  unsigned char forminfo[288];
731
737
 
732
738
  new_field_pack_flag= head[27];
733
739
  new_frm_ver= (head[2] - FRM_VER);
734
 
  field_pack_length= new_frm_ver < 2 ? 11 : 17;
 
740
  assert(new_frm_ver >= 2); /* If this fails, we're on old FRM */
 
741
  field_pack_length= 17;
735
742
  disk_buff= 0;
736
743
 
737
744
  error= 3;
761
768
    /*share->keys=      */keys=      disk_buff[0];
762
769
    /*share->key_parts=*/ key_parts= disk_buff[1];
763
770
  }
764
 
//  share->keys_for_keyread.init(0);
765
 
//  share->keys_in_use.init(keys);
766
 
 
767
 
//  n_length=keys*sizeof(KEY)+key_parts*sizeof(KEY_PART_INFO);
768
 
//  if (!(keyinfo = (KEY*) alloc_root(&share->mem_root,
769
 
//                                  n_length + uint2korr(disk_buff+4))))
770
771
 
771
772
    /* the magic uint2korr(disk_buff+4) is  the key names size */
772
773
 
773
 
//    goto err;                                   /* purecov: inspected */
774
 
//  memset(keyinfo, 0, n_length);
775
 
//  share->key_info= keyinfo;
776
 
 
777
774
  keyinfo= share->key_info;
778
775
  key_part= reinterpret_cast<KEY_PART_INFO*> (keyinfo+keys);
779
776
  strpos=disk_buff+6;
780
777
 
781
 
//  if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root,
782
 
//                                       sizeof(ulong*)*key_parts)))
783
 
//    goto err;
784
 
 
785
778
  for (i=0 ; i < keys ; i++, keyinfo++)
786
779
  {
787
 
//    keyinfo->table= 0;                           // Updated in open_frm
788
780
    if (new_frm_ver >= 3)
789
781
    {
790
 
      /*keyinfo->flags=*/          (uint) uint2korr(strpos) ^ HA_NOSAME;
791
 
      /*keyinfo->key_length=*/ (uint) uint2korr(strpos+2);
792
 
      /*keyinfo->key_parts=*/  (uint) strpos[4];
793
 
//      /*keyinfo->algorithm=*/  (enum ha_key_alg) strpos[5];
794
 
//      /*keyinfo->block_size=*/ uint2korr(strpos+6);
795
782
      strpos+=8;
796
783
    }
797
784
 
798
 
//    keyinfo->key_part=         key_part;
799
 
//    keyinfo->rec_per_key= rec_per_key;
800
785
    for (j=keyinfo->key_parts ; j-- ; key_part++)
801
786
    {
802
 
//      *rec_per_key++=0;
803
 
      //key_part->fieldnr=      (uint16_t) (uint2korr(strpos) & FIELD_NR_MASK);
804
787
      key_part->offset= (uint) uint2korr(strpos+2)-1;
805
788
      key_part->key_type=       (uint) uint2korr(strpos+5);
806
 
      // key_part->field=       (Field*) 0;     // Will be fixed later
807
789
      if (new_frm_ver >= 1)
808
790
      {
809
 
        //key_part->key_part_flag= *(strpos+4);
810
 
        //key_part->length=     (uint) uint2korr(strpos+7);
811
791
        strpos+=9;
812
792
      }
813
793
      else
814
794
      {
815
795
        abort(); // Old FRM version, we abort as we should never see it.
816
796
      }
817
 
      //key_part->store_length=key_part->length;
818
797
    }
819
798
  }
820
799
 
918
897
  }
919
898
 
920
899
  error=4;
921
 
  extra_rec_buf_length= uint2korr(head+59);
922
 
  rec_buff_length= ALIGN_SIZE(share->reclength + 1 + extra_rec_buf_length);
 
900
  /* head+59 was extra_rec_buf_length */
 
901
  rec_buff_length= ALIGN_SIZE(share->reclength + 1);
923
902
  share->rec_buff_length= rec_buff_length;
924
903
  if (!(record= (unsigned char *) alloc_root(&share->mem_root,
925
904
                                     rec_buff_length)))
939
918
  share->null_fields= uint2korr(forminfo+282);
940
919
  com_length= uint2korr(forminfo+284);
941
920
  vcol_screen_length= uint2korr(forminfo+286);
942
 
  share->vfields= 0;
943
 
  share->stored_fields= share->fields;
944
 
 
945
 
 
 
921
//  share->vfields= 0;
 
922
//  share->stored_fields= share->fields;
 
923
 
 
924
 
 
925
  /* WTF is with the share->fields+1 here... */
946
926
  if (!(field_ptr = (Field **)
947
927
        alloc_root(&share->mem_root,
948
928
                   (uint) ((share->fields+1)*sizeof(Field*)+
1115
1095
    }
1116
1096
    else
1117
1097
    {
1118
 
      field_length= (uint) strpos[3];
1119
 
      recpos=       uint2korr(strpos+4),
1120
 
      pack_flag=    uint2korr(strpos+6);
1121
 
      pack_flag&=   ~FIELDFLAG_NO_DEFAULT;     // Safety for old files
1122
 
      unireg_type=  (uint) strpos[8];
1123
 
      interval_nr=  (uint) strpos[10];
1124
 
 
1125
 
      /* old frm file */
1126
 
      field_type= (enum_field_types) f_packtype(pack_flag);
1127
 
      if (f_is_binary(pack_flag))
1128
 
      {
1129
 
        /*
1130
 
          Try to choose the best 4.1 type:
1131
 
          - for 4.0 "CHAR(N) BINARY" or "VARCHAR(N) BINARY"
1132
 
            try to find a binary collation for character set.
1133
 
          - for other types (e.g. BLOB) just use my_charset_bin.
1134
 
        */
1135
 
        if (!f_is_blob(pack_flag))
1136
 
        {
1137
 
          // 3.23 or 4.0 string
1138
 
          if (!(charset= get_charset_by_csname(share->table_charset->csname, MY_CS_BINSORT)))
1139
 
            charset= &my_charset_bin;
1140
 
        }
1141
 
        else
1142
 
          charset= &my_charset_bin;
1143
 
      }
1144
 
      else
1145
 
        charset= share->table_charset;
1146
 
      memset(&comment, 0, sizeof(comment));
 
1098
      assert(false); /* Old (pre-4.1) FRM file. This is Drizzle. */
1147
1099
    }
1148
1100
 
1149
1101
    if (interval_nr && charset->mbminlen > 1)
2518
2470
    int4store(fileinfo+51, tmp);
2519
2471
    int4store(fileinfo+55, create_info->extra_size);
2520
2472
    /*
2521
 
      59-60 is reserved for extra_rec_buf_length,
 
2473
      59-60 is reserved for extra_rec_buf_length (always 0),
2522
2474
      61 for default_part_db_type
2523
2475
    */
2524
2476
    int2store(fileinfo+62, create_info->key_block_size);