mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
>255 keys support in frm
This commit is contained in:
parent
293a61ed35
commit
572e18aeb3
2 changed files with 30 additions and 12 deletions
17
sql/table.cc
17
sql/table.cc
|
@ -156,7 +156,16 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
|||
VOID(my_seek(file,(ulong) uint2korr(head+6),MY_SEEK_SET,MYF(0)));
|
||||
if (read_string(file,(gptr*) &disk_buff,key_info_length))
|
||||
goto err_not_open; /* purecov: inspected */
|
||||
outparam->keys=keys= disk_buff[0];
|
||||
if (disk_buff[1] & 0x80)
|
||||
{
|
||||
outparam->keys= keys= uint2korr(disk_buff) & 0x7fff;
|
||||
outparam->key_parts= key_parts= uint2korr(disk_buff+2);
|
||||
}
|
||||
else
|
||||
{
|
||||
outparam->keys= keys= disk_buff[0];
|
||||
outparam->key_parts= key_parts= disk_buff[1];
|
||||
}
|
||||
outparam->keys_for_keyread.init().set_prefix(keys);
|
||||
outparam->keys_in_use.init().set_prefix(keys);
|
||||
outparam->read_only_keys.init().clear_all();
|
||||
|
@ -164,7 +173,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
|||
outparam->used_keys.init();
|
||||
outparam->keys_in_use_for_query.init();
|
||||
|
||||
outparam->key_parts=key_parts=disk_buff[1];
|
||||
n_length=keys*sizeof(KEY)+key_parts*sizeof(KEY_PART_INFO);
|
||||
if (!(keyinfo = (KEY*) alloc_root(&outparam->mem_root,
|
||||
n_length+uint2korr(disk_buff+4))))
|
||||
|
@ -269,7 +277,9 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
|||
record[outparam->reclength]=0; // For purify and ->c_ptr()
|
||||
outparam->rec_buff_length=rec_buff_length;
|
||||
if (my_pread(file,(byte*) record,(uint) outparam->reclength,
|
||||
(ulong) (uint2korr(head+6)+uint2korr(head+14)),
|
||||
(ulong) (uint2korr(head+6)+
|
||||
((uint2korr(head+14) == 0xffff ?
|
||||
uint4korr(head+10) : uint2korr(head+14)))),
|
||||
MYF(MY_NABP)))
|
||||
goto err_not_open; /* purecov: inspected */
|
||||
/* HACK: table->record[2] is used instead of table->default_values here */
|
||||
|
@ -1114,6 +1124,7 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo,
|
|||
key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;
|
||||
length=(ulong) next_io_size((ulong) (IO_SIZE+key_length+reclength));
|
||||
int4store(fileinfo+10,length);
|
||||
if (key_length > 0xffff) key_length=0xffff;
|
||||
int2store(fileinfo+14,key_length);
|
||||
int2store(fileinfo+16,reclength);
|
||||
int4store(fileinfo+18,create_info->max_rows);
|
||||
|
|
|
@ -92,15 +92,15 @@ int rea_create_table(THD *thd, my_string file_name,
|
|||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
uint key_buff_length=uint2korr(fileinfo+14);
|
||||
keybuff=(uchar*) my_alloca(key_buff_length);
|
||||
uint key_buff_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;
|
||||
keybuff=(uchar*) my_malloc(key_buff_length, MYF(0));
|
||||
key_info_length=pack_keys(keybuff,keys,key_info);
|
||||
VOID(get_form_pos(file,fileinfo,&formnames));
|
||||
if (!(filepos=make_new_entry(file,fileinfo,&formnames,"")))
|
||||
goto err;
|
||||
maxlength=(uint) next_io_size((ulong) (uint2korr(forminfo)+1000));
|
||||
int2store(forminfo+2,maxlength);
|
||||
int4store(fileinfo+10,(ulong) (filepos+maxlength));
|
||||
int4store(fileinfo+10,key_buff_length);
|
||||
fileinfo[26]= (uchar) test((create_info->max_rows == 1) &&
|
||||
(create_info->min_rows == 1) && (keys == 0));
|
||||
int2store(fileinfo+28,key_info_length);
|
||||
|
@ -148,7 +148,7 @@ int rea_create_table(THD *thd, my_string file_name,
|
|||
#endif
|
||||
|
||||
my_free((gptr) screen_buff,MYF(0));
|
||||
my_afree((gptr) keybuff);
|
||||
my_free((gptr) keybuff, MYF(0));
|
||||
VOID(my_close(file,MYF(MY_WME)));
|
||||
if (ha_create_table(file_name,create_info,0))
|
||||
goto err2;
|
||||
|
@ -156,7 +156,7 @@ int rea_create_table(THD *thd, my_string file_name,
|
|||
|
||||
err:
|
||||
my_free((gptr) screen_buff,MYF(0));
|
||||
my_afree((gptr) keybuff);
|
||||
my_free((gptr) keybuff, MYF(0));
|
||||
VOID(my_close(file,MYF(MY_WME)));
|
||||
err2:
|
||||
my_delete(file_name,MYF(0));
|
||||
|
@ -291,10 +291,17 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo)
|
|||
}
|
||||
*(pos++)=0;
|
||||
|
||||
keybuff[0]=(uchar) key_count;
|
||||
keybuff[1]=(uchar) key_parts;
|
||||
length=(uint) (keyname_pos-keybuff);
|
||||
int2store(keybuff+2,length);
|
||||
if (key_count > 127 || key_parts > 127)
|
||||
{
|
||||
key_count|=0x8000;
|
||||
int2store(keybuff,key_count);
|
||||
int2store(keybuff+2,key_parts);
|
||||
}
|
||||
else
|
||||
{
|
||||
keybuff[0]=(uchar) key_count;
|
||||
keybuff[1]=(uchar) key_parts;
|
||||
}
|
||||
length=(uint) (pos-keyname_pos);
|
||||
int2store(keybuff+4,length);
|
||||
DBUG_RETURN((uint) (pos-keybuff));
|
||||
|
|
Loading…
Reference in a new issue