summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-05-25 18:33:32 +0300
committerunknown <monty@mysql.com>2005-05-25 18:33:32 +0300
commitc6283dbba9e0ec066e9fd8211e0d1629507f193e (patch)
tree42f0d293d887020470308fc65537d1fe4d775e46 /sql/unireg.cc
parentab1ba1341c3eed4375739ec166fc26fdbb9e3631 (diff)
downloadmariadb-git-c6283dbba9e0ec066e9fd8211e0d1629507f193e.tar.gz
Cleanup's during review
Added ASSERT() to detect wrongly packed fields sql/field.h: Fixed comments to right format sql/opt_range.cc: Merged code sql/sql_base.cc: Fixed indentation sql/sql_insert.cc: Fixed comments to right format sql/sql_select.cc: Simplify code sql/unireg.cc: Simply code for calculating key_buff_length Added ASSERT() to detect wrongly packed fields
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 57d9fd07e51..123079291c2 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -73,6 +73,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
handler *db_file)
{
uint reclength,info_length,screens,key_info_length,maxlength;
+ ulong key_buff_length;
File file;
ulong filepos, data_offset;
uchar fileinfo[64],forminfo[288],*keybuff;
@@ -119,7 +120,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
DBUG_RETURN(1);
}
- uint key_buff_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;
+ key_buff_length= uint4korr(fileinfo+47);
keybuff=(uchar*) my_malloc(key_buff_length, MYF(0));
key_info_length= pack_keys(keybuff, keys, key_info, data_offset);
VOID(get_form_pos(file,fileinfo,&formnames));
@@ -128,7 +129,6 @@ bool mysql_create_frm(THD *thd, my_string file_name,
maxlength=(uint) next_io_size((ulong) (uint2korr(forminfo)+1000));
int2store(forminfo+2,maxlength);
int4store(fileinfo+10,(ulong) (filepos+maxlength));
- int4store(fileinfo+47,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);
@@ -411,7 +411,8 @@ static bool pack_header(uchar *forminfo, enum db_type table_type,
DBUG_RETURN(1);
}
- totlength=reclength=0L;
+ totlength= 0L;
+ reclength= data_offset;
no_empty=int_count=int_parts=int_length=time_stamp_pos=null_fields=
com_length=0;
n_length=2L;
@@ -440,6 +441,8 @@ static bool pack_header(uchar *forminfo, enum db_type table_type,
!time_stamp_pos)
time_stamp_pos= (uint) field->offset+ (uint) data_offset + 1;
length=field->pack_length;
+ /* Ensure we don't have any bugs when generating offsets */
+ DBUG_ASSERT(reclength == field->offset + data_offset);
if ((uint) field->offset+ (uint) data_offset+ length > reclength)
reclength=(uint) (field->offset+ data_offset + length);
n_length+= (ulong) strlen(field->field_name)+1;