Commit a0a34398 authored by Nikita Malyavin's avatar Nikita Malyavin

move frm data to separate extra2 section

parent 7e06b63e
......@@ -60,6 +60,7 @@ struct extra2_fields
LEX_CUSTRING system_period;
LEX_CUSTRING application_period;
LEX_CUSTRING field_data_type_info;
LEX_CUSTRING without_overlaps;
void reset()
{ bzero((void*)this, sizeof(*this)); }
};
......@@ -1559,6 +1560,9 @@ bool read_extra2(const uchar *frm_image, size_t len, extra2_fields *fields)
case EXTRA2_APPLICATION_TIME_PERIOD:
fail= fill_extra2(&fields->application_period);
break;
case EXTRA2_PERIOD_WITHOUT_OVERLAPS:
fail= fill_extra2(&fields->without_overlaps);
break;
case EXTRA2_FIELD_DATA_TYPE_INFO:
fail= fill_extra2(&fields->field_data_type_info);
break;
......@@ -2247,8 +2251,11 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (init_period_from_extra2(&period, pos, end))
goto err;
status_var_increment(thd->status_var.feature_application_time_periods);
}
const uchar *key_pos= pos + 2 * frm_fieldno_size;
if (extra2.without_overlaps.str)
{
const uchar *key_pos= extra2.without_overlaps.str;
period.unique_keys= read_frm_keyno(key_pos);
for (uint k= 0; k < period.unique_keys; k++)
{
......@@ -2257,10 +2264,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
key_info[key_nr].without_overlaps= true;
}
if (frm_ident_stored_size(period.name.length)
+ frm_ident_stored_size(period.constr_name.length)
+ (period.unique_keys + 1) * frm_keyno_size + 2 * frm_fieldno_size
!= extra2.application_period.length)
if ((period.unique_keys + 1) * frm_keyno_size
!= extra2.without_overlaps.length)
goto err;
}
......
......@@ -1793,8 +1793,8 @@ static inline uint16 read_frm_keyno(const uchar *data)
{ return uint2korr(data); }
static inline void store_frm_keyno(uchar *data, uint16 fieldno)
{ int2store(data, fieldno); }
static inline size_t frm_ident_stored_size(size_t len)
{ return len + (len > 255 ? 3 : 1); }
static inline size_t extra2_str_size(size_t len)
{ return (len > 255 ? 3 : 1) + len; }
class select_unit;
class TMP_TABLE_PARAM;
......
......@@ -147,12 +147,6 @@ bool has_extra2_field_flags(List<Create_field> &create_fields)
return false;
}
static size_t extra2_str_size(size_t len)
{
return (len > 255 ? 3 : 1) + len;
}
static uint gis_field_options_image(uchar *buff,
List<Create_field> &create_fields)
{
......@@ -256,9 +250,9 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
size_t period_info_len= create_info->period_info.name
? extra2_str_size(create_info->period_info.name.length)
+ extra2_str_size(create_info->period_info.constr->name.length)
+ frm_keyno_size * (create_info->period_info.unique_keys + 1)
+ 2 * frm_fieldno_size
: 0;
size_t without_overlaps_len= frm_keyno_size * (create_info->period_info.unique_keys + 1);
uint e_unique_hash_extra_parts= 0;
uchar fileinfo[FRM_HEADER_SIZE],forminfo[FRM_FORMINFO_SIZE];
const partition_info *part_info= IF_PARTITIONING(thd->work_part_info, 0);
......@@ -391,7 +385,9 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
if (create_info->period_info.name)
{
extra2_size+= 1 + extra2_str_size(period_info_len);
// two extra2 sections are taken after 10.5
extra2_size+= 2 + extra2_str_size(period_info_len)
+ extra2_str_size(without_overlaps_len);
}
bool has_extra2_field_flags_= has_extra2_field_flags(create_fields);
......@@ -486,6 +482,9 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
store_frm_fieldno(pos, get_fieldno_by_name(create_info, create_fields,
create_info->period_info.period.end));
pos+= frm_fieldno_size;
*pos++= EXTRA2_PERIOD_WITHOUT_OVERLAPS;
pos= extra2_write_len(pos, without_overlaps_len);
store_frm_keyno(pos, create_info->period_info.unique_keys);
pos+= frm_keyno_size;
for (uint key= 0; key < keys; key++)
......
......@@ -177,7 +177,8 @@ enum extra2_frm_value_type {
EXTRA2_ENGINE_TABLEOPTS=128,
EXTRA2_FIELD_FLAGS=129,
EXTRA2_FIELD_DATA_TYPE_INFO=130
EXTRA2_FIELD_DATA_TYPE_INFO=130,
EXTRA2_PERIOD_WITHOUT_OVERLAPS=131,
};
enum extra2_field_flags {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment