522
522
table_options.key_block_size() : 0;
524
524
share->fields= table.field_size();
526
share->stored_fields= share->fields;
528
/* share->field= (Field**) alloc_root(&share->mem_root,
529
(share->fields * sizeof(Field*)));
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;
718
724
unsigned char forminfo[288];
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;
761
768
/*share->keys= */keys= disk_buff[0];
762
769
/*share->key_parts=*/ key_parts= disk_buff[1];
764
// share->keys_for_keyread.init(0);
765
// share->keys_in_use.init(keys);
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))))
771
772
/* the magic uint2korr(disk_buff+4) is the key names size */
773
// goto err; /* purecov: inspected */
774
// memset(keyinfo, 0, n_length);
775
// share->key_info= keyinfo;
777
774
keyinfo= share->key_info;
778
775
key_part= reinterpret_cast<KEY_PART_INFO*> (keyinfo+keys);
779
776
strpos=disk_buff+6;
781
// if (!(rec_per_key= (ulong*) alloc_root(&share->mem_root,
782
// sizeof(ulong*)*key_parts)))
785
778
for (i=0 ; i < keys ; i++, keyinfo++)
787
// keyinfo->table= 0; // Updated in open_frm
788
780
if (new_frm_ver >= 3)
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);
798
// keyinfo->key_part= key_part;
799
// keyinfo->rec_per_key= rec_per_key;
800
785
for (j=keyinfo->key_parts ; j-- ; key_part++)
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)
809
//key_part->key_part_flag= *(strpos+4);
810
//key_part->length= (uint) uint2korr(strpos+7);
815
795
abort(); // Old FRM version, we abort as we should never see it.
817
//key_part->store_length=key_part->length;
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);
943
share->stored_fields= share->fields;
921
// share->vfields= 0;
922
// share->stored_fields= share->fields;
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*)+
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];
1126
field_type= (enum_field_types) f_packtype(pack_flag);
1127
if (f_is_binary(pack_flag))
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.
1135
if (!f_is_blob(pack_flag))
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;
1142
charset= &my_charset_bin;
1145
charset= share->table_charset;
1146
memset(&comment, 0, sizeof(comment));
1098
assert(false); /* Old (pre-4.1) FRM file. This is Drizzle. */
1149
1101
if (interval_nr && charset->mbminlen > 1)
2518
2470
int4store(fileinfo+51, tmp);
2519
2471
int4store(fileinfo+55, create_info->extra_size);
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
2524
2476
int2store(fileinfo+62, create_info->key_block_size);