38 File UNINIT_VAR(dfile), UNINIT_VAR(
file);
39 int errpos,save_errno, create_mode= O_RDWR | O_TRUNC;
41 uint fields,length,max_key_length,packed,pointer,real_length_diff,
42 key_length,info_length,key_segs,options,min_key_length_skip,
43 base_pos,long_varchar_count,varchar_length,
44 max_key_block_length,unique_key_parts,fulltext_keys,
offset;
45 uint aligned_key_start, block_length;
46 uint internal_table= flags & HA_CREATE_INTERNAL_TABLE;
47 ulong reclength, real_reclength,min_pack_length;
48 char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr;
50 ulonglong tot_length,max_rows, tmp;
51 enum en_fieldtype
type;
57 ulong *rec_per_key_part;
58 my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE];
60 DBUG_ENTER(
"mi_create");
61 DBUG_PRINT(
"enter", (
"keys: %u columns: %u uniques: %u flags: %u",
62 keys, columns, uniques, flags));
66 memset(&tmp_create_info, 0,
sizeof(tmp_create_info));
70 if (keys + uniques > MI_MAX_KEY || columns == 0)
72 DBUG_RETURN(my_errno=HA_WRONG_CREATE_OPTION);
77 memset(&share, 0,
sizeof(share));
79 if (flags & HA_DONT_TOUCH_DATA)
81 if (!(ci->old_options & HA_OPTION_TEMP_COMPRESS_RECORD))
82 options=ci->old_options &
83 (HA_OPTION_COMPRESS_RECORD | HA_OPTION_PACK_RECORD |
84 HA_OPTION_READ_ONLY_DATA | HA_OPTION_CHECKSUM |
85 HA_OPTION_TMP_TABLE | HA_OPTION_DELAY_KEY_WRITE);
87 options=ci->old_options &
88 (HA_OPTION_CHECKSUM | HA_OPTION_TMP_TABLE | HA_OPTION_DELAY_KEY_WRITE);
91 if (ci->reloc_rows > ci->max_rows)
92 ci->reloc_rows=ci->max_rows;
94 if (!(rec_per_key_part=
95 (ulong*) my_malloc((keys + uniques)*MI_MAX_KEY_SEG*
sizeof(
long),
96 MYF(MY_WME | MY_ZEROFILL))))
97 DBUG_RETURN(my_errno);
101 reclength=varchar_length=long_varchar_count=packed=
102 min_pack_length=pack_reclength=0;
103 for (rec=recinfo, fields=0 ;
107 reclength+=rec->length;
108 if ((type=(
enum en_fieldtype) rec->type) != FIELD_NORMAL &&
112 if (type == FIELD_BLOB)
115 if (pack_reclength != INT_MAX32)
117 if (rec->length == 4+portable_sizeof_char_ptr)
118 pack_reclength= INT_MAX32;
120 pack_reclength+=(1 << ((rec->length-portable_sizeof_char_ptr)*8));
123 else if (type == FIELD_SKIP_PRESPACE ||
124 type == FIELD_SKIP_ENDSPACE)
126 if (pack_reclength != INT_MAX32)
127 pack_reclength+= rec->length > 255 ? 2 : 1;
130 else if (type == FIELD_VARCHAR)
132 varchar_length+= rec->length-1;
137 if (
test(rec->length >= 257))
139 long_varchar_count++;
143 else if (type != FIELD_SKIP_ZERO)
145 min_pack_length+=rec->length;
150 min_pack_length+=rec->length;
152 if ((packed & 7) == 1)
154 while (rec != recinfo)
157 if (rec->type == (
int) FIELD_SKIP_ZERO && rec->length == 1)
163 rec->type=(int) FIELD_NORMAL;
171 if (packed || (flags & HA_PACK_RECORD))
172 options|=HA_OPTION_PACK_RECORD;
174 if (!(options & HA_OPTION_PACK_RECORD))
175 options&= ~HA_OPTION_CHECKSUM;
176 if (!(options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)))
177 min_pack_length+= varchar_length;
178 if (flags & HA_CREATE_TMP_TABLE)
180 options|= HA_OPTION_TMP_TABLE;
181 create_mode|= O_EXCL | O_NOFOLLOW;
183 if (flags & HA_CREATE_CHECKSUM || (options & HA_OPTION_CHECKSUM))
185 options|= HA_OPTION_CHECKSUM;
188 if (flags & HA_CREATE_DELAY_KEY_WRITE)
189 options|= HA_OPTION_DELAY_KEY_WRITE;
190 if (flags & HA_CREATE_RELIES_ON_SQL_LAYER)
191 options|= HA_OPTION_RELIES_ON_SQL_LAYER;
194 if (pack_reclength != INT_MAX32)
195 pack_reclength+= reclength+packed +
196 test(test_all_bits(options, HA_OPTION_CHECKSUM | HA_OPTION_PACK_RECORD));
197 min_pack_length+=packed;
199 if (!ci->data_file_length && ci->max_rows)
201 if (pack_reclength == INT_MAX32 ||
202 (~(ulonglong) 0)/ci->max_rows < (ulonglong) pack_reclength)
203 ci->data_file_length= ~(ulonglong) 0;
205 ci->data_file_length=(ulonglong) ci->max_rows*pack_reclength;
207 else if (!ci->max_rows)
208 ci->max_rows=(ha_rows) (ci->data_file_length/(min_pack_length +
209 ((options & HA_OPTION_PACK_RECORD) ?
212 if (options & (HA_OPTION_COMPRESS_RECORD | HA_OPTION_PACK_RECORD))
213 pointer=mi_get_pointer_length(ci->data_file_length,myisam_data_pointer_size);
215 pointer=mi_get_pointer_length(ci->max_rows,myisam_data_pointer_size);
216 if (!(max_rows=(ulonglong) ci->max_rows))
217 max_rows= ((((ulonglong) 1 << (pointer*8)) -1) / min_pack_length);
220 real_reclength=reclength;
221 if (!(options & (HA_OPTION_COMPRESS_RECORD | HA_OPTION_PACK_RECORD)))
223 if (reclength <= pointer)
227 reclength+= long_varchar_count;
229 max_key_length=0; tot_length=0 ; key_segs=0;
231 max_key_block_length=0;
232 share.state.rec_per_key_part=rec_per_key_part;
233 share.state.key_root=key_root;
234 share.state.key_del=key_del;
237 max_key_block_length= myisam_block_size;
238 max_key_length= MI_UNIQUE_HASH_LENGTH + pointer;
241 for (i=0, keydef=keydefs ; i < keys ; i++ , keydef++)
244 share.state.key_root[
i]= HA_OFFSET_ERROR;
245 min_key_length_skip=length=real_length_diff=0;
247 if (keydef->flag & HA_SPATIAL)
251 uint sp_segs=SPDIMS*2;
252 keydef->flag=HA_SPATIAL;
254 if (flags & HA_DONT_TOUCH_DATA)
263 keydef->keysegs-=sp_segs-1;
266 for (j=0, keyseg=keydef->seg ; (
int) j < keydef->keysegs ;
269 if (keyseg->type != HA_KEYTYPE_BINARY &&
270 keyseg->type != HA_KEYTYPE_VARBINARY1 &&
271 keyseg->type != HA_KEYTYPE_VARBINARY2)
273 my_errno=HA_WRONG_CREATE_OPTION;
277 keydef->keysegs+=sp_segs;
278 key_length+=SPLEN*sp_segs;
280 min_key_length_skip+=SPLEN*2*SPDIMS;
282 my_errno= HA_ERR_UNSUPPORTED;
286 else if (keydef->flag & HA_FULLTEXT)
288 keydef->flag=HA_FULLTEXT | HA_PACK_KEY | HA_VAR_LENGTH_KEY;
289 options|=HA_OPTION_PACK_KEYS;
291 for (j=0, keyseg=keydef->seg ; (
int) j < keydef->keysegs ;
294 if (keyseg->type != HA_KEYTYPE_TEXT &&
295 keyseg->type != HA_KEYTYPE_VARTEXT1 &&
296 keyseg->type != HA_KEYTYPE_VARTEXT2)
298 my_errno=HA_WRONG_CREATE_OPTION;
301 if (!(keyseg->flag & HA_BLOB_PART) &&
302 (keyseg->type == HA_KEYTYPE_VARTEXT1 ||
303 keyseg->type == HA_KEYTYPE_VARTEXT2))
306 keyseg->flag|= HA_VAR_LENGTH_PART;
308 keyseg->bit_start= ((keyseg->type == HA_KEYTYPE_VARTEXT1)?
314 key_length+= HA_FT_MAXBYTELEN+HA_FT_WLEN;
316 min_key_length_skip+=HA_FT_MAXBYTELEN;
317 real_length_diff=HA_FT_MAXBYTELEN-FT_MAX_WORD_LEN_FOR_SORT;
322 if (keydef->flag & HA_PACK_KEY)
325 if ((keydef->seg[0].flag & HA_SPACE_PACK) &&
326 keydef->seg[0].type == (int) HA_KEYTYPE_NUM)
327 keydef->seg[0].flag&= ~HA_SPACE_PACK;
330 if (!(keydef->seg[0].flag & (HA_SPACE_PACK | HA_BLOB_PART |
331 HA_VAR_LENGTH_PART)))
334 keydef->flag&= ~HA_PACK_KEY;
335 keydef->flag|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
339 keydef->seg[0].flag|=HA_PACK_KEY;
340 keydef->flag|=HA_VAR_LENGTH_KEY;
341 options|=HA_OPTION_PACK_KEYS;
344 if (keydef->flag & HA_BINARY_PACK_KEY)
345 options|=HA_OPTION_PACK_KEYS;
347 if (keydef->flag & HA_AUTO_KEY && ci->with_auto_increment)
348 share.base.auto_key=i+1;
349 for (j=0, keyseg=keydef->seg ; j < keydef->keysegs ; j++, keyseg++)
352 switch (keyseg->type) {
353 case HA_KEYTYPE_SHORT_INT:
354 case HA_KEYTYPE_LONG_INT:
355 case HA_KEYTYPE_FLOAT:
356 case HA_KEYTYPE_DOUBLE:
357 case HA_KEYTYPE_USHORT_INT:
358 case HA_KEYTYPE_ULONG_INT:
359 case HA_KEYTYPE_LONGLONG:
360 case HA_KEYTYPE_ULONGLONG:
361 case HA_KEYTYPE_INT24:
362 case HA_KEYTYPE_UINT24:
363 case HA_KEYTYPE_INT8:
364 keyseg->flag|= HA_SWAP_KEY;
366 case HA_KEYTYPE_VARTEXT1:
367 case HA_KEYTYPE_VARTEXT2:
368 case HA_KEYTYPE_VARBINARY1:
369 case HA_KEYTYPE_VARBINARY2:
370 if (!(keyseg->flag & HA_BLOB_PART))
373 keyseg->flag|= HA_VAR_LENGTH_PART;
375 keyseg->bit_start= ((keyseg->type == HA_KEYTYPE_VARTEXT1 ||
376 keyseg->type == HA_KEYTYPE_VARBINARY1) ?
383 if (keyseg->flag & HA_SPACE_PACK)
385 DBUG_ASSERT(!(keyseg->flag & HA_VAR_LENGTH_PART));
386 keydef->flag |= HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY;
387 options|=HA_OPTION_PACK_KEYS;
389 min_key_length_skip+=keyseg->length;
390 if (keyseg->length >= 255)
392 min_key_length_skip+=2;
396 if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
398 DBUG_ASSERT(!test_all_bits(keyseg->flag,
399 (HA_VAR_LENGTH_PART | HA_BLOB_PART)));
400 keydef->flag|=HA_VAR_LENGTH_KEY;
402 options|=HA_OPTION_PACK_KEYS;
403 min_key_length_skip+=keyseg->length;
404 if (keyseg->length >= 255)
406 min_key_length_skip+=2;
410 key_length+= keyseg->length;
411 if (keyseg->null_bit)
414 options|=HA_OPTION_PACK_KEYS;
415 keyseg->flag|=HA_NULL_PART;
416 keydef->flag|=HA_VAR_LENGTH_KEY | HA_NULL_PART_KEY;
420 key_segs+=keydef->keysegs;
421 if (keydef->keysegs > MI_MAX_KEY_SEG)
423 my_errno=HA_WRONG_CREATE_OPTION;
431 if ((keydef->flag & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME &&
433 share.state.rec_per_key_part[key_segs-1]=1L;
436 block_length= (keydef->block_length ?
437 my_round_up_to_next_power(keydef->block_length) :
439 block_length= MY_MAX(block_length, MI_MIN_KEY_BLOCK_LENGTH);
440 block_length= MY_MIN(block_length, MI_MAX_KEY_BLOCK_LENGTH);
442 keydef->block_length= (uint16) MI_BLOCK_SIZE(length-real_length_diff,
443 pointer,MI_MAX_KEYPTR_SIZE,
445 if (keydef->block_length > MI_MAX_KEY_BLOCK_LENGTH ||
446 length >= MI_MAX_KEY_BUFF)
448 my_errno=HA_WRONG_CREATE_OPTION;
451 set_if_bigger(max_key_block_length,keydef->block_length);
452 keydef->keylength= (uint16) key_length;
453 keydef->minlength= (uint16) (length-min_key_length_skip);
454 keydef->maxlength= (uint16) length;
456 if (length > max_key_length)
457 max_key_length= length;
458 tot_length+= (max_rows/(ulong) (((uint) keydef->block_length-5)/
460 (ulong) keydef->block_length;
462 for (i=max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH ; i-- ; )
463 key_del[i]=HA_OFFSET_ERROR;
466 for (i=0, uniquedef=uniquedefs ; i < uniques ; i++ , uniquedef++)
468 uniquedef->key=keys+
i;
469 unique_key_parts+=uniquedef->keysegs;
470 share.state.key_root[keys+
i]= HA_OFFSET_ERROR;
471 tot_length+= (max_rows/(ulong) (((uint) myisam_block_size-5)/
472 ((MI_UNIQUE_HASH_LENGTH + pointer)*2)))*
473 (ulong) myisam_block_size;
478 base_pos=(MI_STATE_INFO_SIZE + keys * MI_STATE_KEY_SIZE +
479 max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH*
480 MI_STATE_KEYBLOCK_SIZE+
481 key_segs*MI_STATE_KEYSEG_SIZE);
482 info_length=base_pos+(uint) (MI_BASE_INFO_SIZE+
483 keys * MI_KEYDEF_SIZE+
484 uniques * MI_UNIQUEDEF_SIZE +
485 (key_segs + unique_key_parts)*HA_KEYSEG_SIZE+
486 columns*MI_COLUMNDEF_SIZE);
487 DBUG_PRINT(
"info", (
"info_length: %u", info_length));
489 if (info_length > 65535)
491 my_printf_error(0,
"MyISAM table '%s' has too many columns and/or "
492 "indexes and/or unique constraints.",
493 MYF(0), name + dirname_length(name));
494 my_errno= HA_WRONG_CREATE_OPTION;
498 bmove(share.state.header.file_version,(uchar*) myisam_file_magic,4);
499 ci->old_options=options| (ci->old_options & HA_OPTION_TEMP_COMPRESS_RECORD ?
500 HA_OPTION_COMPRESS_RECORD |
501 HA_OPTION_TEMP_COMPRESS_RECORD: 0);
502 mi_int2store(share.state.header.options,ci->old_options);
503 mi_int2store(share.state.header.header_length,info_length);
504 mi_int2store(share.state.header.state_info_length,MI_STATE_INFO_SIZE);
505 mi_int2store(share.state.header.base_info_length,MI_BASE_INFO_SIZE);
506 mi_int2store(share.state.header.base_pos,base_pos);
507 share.state.header.language= (ci->language ?
508 ci->language : default_charset_info->number);
509 share.state.header.max_block_size_index= max_key_block_length/MI_MIN_KEY_BLOCK_LENGTH;
511 share.state.dellink = HA_OFFSET_ERROR;
512 share.state.process= (ulong) getpid();
513 share.state.unique= (ulong) 0;
514 share.state.update_count=(ulong) 0;
515 share.state.version= (ulong) time((time_t*) 0);
516 share.state.sortkey= (ushort) ~0;
517 share.state.auto_increment=ci->auto_increment;
518 share.options=options;
519 share.base.rec_reflength=pointer;
521 tmp= (tot_length + max_key_block_length * keys *
522 MI_INDEX_BLOCK_MARGIN) / MI_MIN_KEY_BLOCK_LENGTH;
527 share.base.key_reflength=
528 mi_get_pointer_length(MY_MAX(ci->key_file_length, tmp), 3);
529 share.base.keys= share.state.header.keys= keys;
530 share.state.header.uniques= uniques;
531 share.state.header.fulltext_keys= fulltext_keys;
532 mi_int2store(share.state.header.key_parts,key_segs);
533 mi_int2store(share.state.header.unique_key_parts,unique_key_parts);
535 mi_set_all_keys_active(share.state.key_map, keys);
536 aligned_key_start= my_round_up_to_next_power(max_key_block_length ?
537 max_key_block_length :
540 share.base.keystart= share.state.state.key_file_length=
541 MY_ALIGN(info_length, aligned_key_start);
542 share.base.max_key_block_length=max_key_block_length;
543 share.base.max_key_length=ALIGN_SIZE(max_key_length+4);
544 share.base.records=ci->max_rows;
545 share.base.reloc= ci->reloc_rows;
546 share.base.reclength=real_reclength;
547 share.base.pack_reclength=reclength+
test(options & HA_OPTION_CHECKSUM);
548 share.base.max_pack_length=pack_reclength;
549 share.base.min_pack_length=min_pack_length;
550 share.base.pack_bits=packed;
551 share.base.fields=fields;
552 share.base.pack_fields=packed;
555 if (options & HA_OPTION_TMP_TABLE)
556 share.base.max_data_file_length=(my_off_t) ci->data_file_length;
558 share.base.min_block_length=
559 (share.base.pack_reclength+3 < MI_EXTEND_BLOCK_LENGTH &&
560 ! share.base.blobs) ?
561 MY_MAX(share.base.pack_reclength, MI_MIN_BLOCK_LENGTH) :
562 MI_EXTEND_BLOCK_LENGTH;
563 if (! (flags & HA_DONT_TOUCH_DATA))
564 share.state.create_time= (long) time((time_t*) 0);
573 if (ci->index_file_name)
575 char *iext= strrchr(ci->index_file_name,
'.');
576 int have_iext= iext && !strcmp(iext, MI_NAME_IEXT);
577 if (options & HA_OPTION_TMP_TABLE)
581 if ((path= strrchr(ci->index_file_name, FN_LIBCHAR)))
583 fn_format(filename, name, ci->index_file_name, MI_NAME_IEXT,
584 MY_REPLACE_DIR | MY_UNPACK_FILENAME |
585 MY_RETURN_REAL_PATH | MY_APPEND_EXT);
589 fn_format(filename, ci->index_file_name,
"", MI_NAME_IEXT,
590 MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
591 (have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
593 fn_format(linkname, name,
"", MI_NAME_IEXT,
594 MY_UNPACK_FILENAME|MY_APPEND_EXT);
595 linkname_ptr=linkname;
604 char *iext= strrchr(name,
'.');
605 int have_iext= iext && !strcmp(iext, MI_NAME_IEXT);
606 fn_format(filename, name,
"", MI_NAME_IEXT,
607 MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
608 (have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
611 create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
624 if (!internal_table && test_if_reopen(filename))
626 my_printf_error(0,
"MyISAM table '%s' is in use "
627 "(most likely by a MERGE table). Try FLUSH TABLES.",
628 MYF(0), name + dirname_length(name));
629 my_errno= HA_ERR_TABLE_EXIST;
634 linkname_ptr, filename, 0,
636 MYF(MY_WME | create_flag))) < 0)
640 if (!(flags & HA_DONT_TOUCH_DATA))
643 if (ci->data_file_name)
645 char *dext= strrchr(ci->data_file_name,
'.');
646 int have_dext= dext && !strcmp(dext, MI_NAME_DEXT);
648 if (options & HA_OPTION_TMP_TABLE)
652 if ((path= strrchr(ci->data_file_name, FN_LIBCHAR)))
654 fn_format(filename, name, ci->data_file_name, MI_NAME_DEXT,
655 MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_APPEND_EXT);
659 fn_format(filename, ci->data_file_name,
"", MI_NAME_DEXT,
661 (have_dext ? MY_REPLACE_EXT : MY_APPEND_EXT));
664 fn_format(linkname, name,
"",MI_NAME_DEXT,
665 MY_UNPACK_FILENAME | MY_APPEND_EXT);
666 linkname_ptr=linkname;
671 fn_format(filename,name,
"", MI_NAME_DEXT,
672 MY_UNPACK_FILENAME | MY_APPEND_EXT);
674 create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
678 linkname_ptr, filename, 0,
680 MYF(MY_WME | create_flag))) < 0)
686 DBUG_PRINT(
"info", (
"write state info and base info"));
687 if (mi_state_info_write(
file, &share.state, 2) ||
688 mi_base_info_write(
file, &share.base))
694 DBUG_PRINT(
"warning",(
"base_length: %d != used_length: %d",
695 base_pos+ MI_BASE_INFO_SIZE, pos));
700 DBUG_PRINT(
"info", (
"write key and keyseg definitions"));
701 for (i=0 ; i < share.base.keys - uniques; i++)
703 uint sp_segs=(keydefs[
i].flag & HA_SPATIAL) ? 2*SPDIMS : 0;
705 if (mi_keydef_write(
file, &keydefs[i]))
707 for (j=0 ; j < keydefs[
i].keysegs-sp_segs ; j++)
708 if (mi_keyseg_write(
file, &keydefs[i].seg[j]))
711 for (j=0 ; j < sp_segs ; j++)
724 sseg.flag= HA_SWAP_KEY;
725 if (mi_keyseg_write(
file, &sseg))
731 offset= real_reclength - uniques * MI_UNIQUE_HASH_LENGTH;
732 memset(&tmp_keydef, 0,
sizeof(tmp_keydef));
733 memset(&tmp_keyseg, 0,
sizeof(tmp_keyseg));
734 for (i=0; i < uniques ; i++)
736 tmp_keydef.keysegs=1;
737 tmp_keydef.flag= HA_UNIQUE_CHECK;
738 tmp_keydef.block_length= (uint16)myisam_block_size;
739 tmp_keydef.keylength= MI_UNIQUE_HASH_LENGTH + pointer;
740 tmp_keydef.minlength=tmp_keydef.maxlength=tmp_keydef.keylength;
741 tmp_keyseg.type= MI_UNIQUE_HASH_TYPE;
742 tmp_keyseg.length= MI_UNIQUE_HASH_LENGTH;
744 offset+= MI_UNIQUE_HASH_LENGTH;
745 if (mi_keydef_write(
file,&tmp_keydef) ||
746 mi_keyseg_write(
file,(&tmp_keyseg)))
751 DBUG_PRINT(
"info", (
"write unique definitions"));
752 for (i=0 ; i < share.state.header.uniques ; i++)
755 keyseg= uniquedefs[
i].seg;
756 if (mi_uniquedef_write(
file, &uniquedefs[i]))
758 for (keyseg= uniquedefs[i].seg, keyseg_end= keyseg+ uniquedefs[i].keysegs;
762 switch (keyseg->type) {
763 case HA_KEYTYPE_VARTEXT1:
764 case HA_KEYTYPE_VARTEXT2:
765 case HA_KEYTYPE_VARBINARY1:
766 case HA_KEYTYPE_VARBINARY2:
767 if (!(keyseg->flag & HA_BLOB_PART))
769 keyseg->flag|= HA_VAR_LENGTH_PART;
770 keyseg->bit_start= ((keyseg->type == HA_KEYTYPE_VARTEXT1 ||
771 keyseg->type == HA_KEYTYPE_VARBINARY1) ?
778 if (mi_keyseg_write(
file, keyseg))
782 DBUG_PRINT(
"info", (
"write field definitions"));
783 for (i=0 ; i < share.base.fields ; i++)
784 if (mi_recinfo_write(
file, &recinfo[i]))
791 DBUG_PRINT(
"warning",(
"info_length: %d != used_length: %d",
797 DBUG_PRINT(
"info", (
"enlarge to keystart: %lu", (ulong) share.base.keystart));
801 if (! (flags & HA_DONT_TOUCH_DATA))
817 my_free(rec_per_key_part);
831 if (! (flags & HA_DONT_TOUCH_DATA))
833 fn_format(filename, name,
"", MI_NAME_DEXT,
834 MY_UNPACK_FILENAME | MY_APPEND_EXT),
839 if (! (flags & HA_DONT_TOUCH_DATA))
841 fn_format(filename, name,
"", MI_NAME_IEXT,
842 MY_UNPACK_FILENAME | MY_APPEND_EXT),
845 my_free(rec_per_key_part);
846 DBUG_RETURN(my_errno=save_errno);
850 uint mi_get_pointer_length(ulonglong file_length, uint def)
852 DBUG_ASSERT(def >= 2 && def <= 7);
855 #ifdef NOT_YET_READY_FOR_8_BYTE_POINTERS
856 if (file_length >= ULL(1) << 56)
860 if (file_length >= ULL(1) << 48)
862 else if (file_length >= ULL(1) << 40)
864 else if (file_length >= ULL(1) << 32)
866 else if (file_length >= ULL(1) << 24)
868 else if (file_length >= ULL(1) << 16)