diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-06-15 19:10:00 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-06-15 19:10:00 +0200 |
commit | 0973b7a8d20751b56c8ca3f861ea2fbf060e5ab3 (patch) | |
tree | 2277f5f7576f6e4d6799609a542fddaf0da7a016 /sql/unireg.cc | |
parent | 54b3472ef1928df18f23869e304a6d018db89094 (diff) | |
download | mariadb-git-0973b7a8d20751b56c8ca3f861ea2fbf060e5ab3.tar.gz |
partitioning frm bugs:
1. default db type for partitions was stored as 1-byte DB_TYPE code,
which doesn't work for dynamically generated codes.
2. storage engine plugin for default db type wasn't locked at all,
which could trivially crash for dynamic plugins.
Now the storage engine name is stored in the extra2 section,
and the plugin is correctly locked.
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r-- | sql/unireg.cc | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc index 099f8ccbc78..d90db0ebab8 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -46,6 +46,38 @@ static bool pack_fields(uchar *, List<Create_field> &, ulong); static size_t packed_fields_length(List<Create_field> &); static bool make_empty_rec(THD *, uchar *, uint, List<Create_field> &, uint, ulong); +static uchar *extra2_write_len(uchar *pos, size_t len) +{ + if (len < 255) + *pos++= len; + else + { + /* + At the moment we support options_len up to 64K. + We can easily extend it in the future, if the need arises. + */ + DBUG_ASSERT(len <= 65535); + int2store(pos + 1, len); + pos+= 3; + } + return pos; +} + +static uchar *extra2_write(uchar *pos, enum extra2_frm_value_type type, + LEX_STRING *str) +{ + *pos++ = type; + pos= extra2_write_len(pos, str->length); + memcpy(pos, str->str, str->length); + return pos + str->length; +} + +static uchar *extra2_write(uchar *pos, enum extra2_frm_value_type type, + LEX_CUSTRING *str) +{ + return extra2_write(pos, type, reinterpret_cast<LEX_STRING *>(str)); +} + /** Create a frm (table definition) file @@ -200,6 +232,9 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table, if (options_len) extra2_size+= 1 + (options_len > 255 ? 3 : 1) + options_len; + if (part_info) + extra2_size+= 1 + 1 + hton_name(part_info->default_engine_type)->length; + key_buff_length= uint4korr(fileinfo+47); frm.length= FRM_HEADER_SIZE; // fileinfo; @@ -223,27 +258,17 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table, /* write the extra2 segment */ pos = frm_ptr + 64; compile_time_assert(EXTRA2_TABLEDEF_VERSION != '/'); - *pos++ = EXTRA2_TABLEDEF_VERSION; // old servers write '/' here - *pos++ = create_info->tabledef_version.length; - memcpy(pos, create_info->tabledef_version.str, - create_info->tabledef_version.length); - pos+= create_info->tabledef_version.length; + pos= extra2_write(pos, EXTRA2_TABLEDEF_VERSION, + &create_info->tabledef_version); + + if (part_info) + pos= extra2_write(pos, EXTRA2_DEFAULT_PART_ENGINE, + hton_name(part_info->default_engine_type)); if (options_len) { *pos++= EXTRA2_ENGINE_TABLEOPTS; - if (options_len < 255) - *pos++= options_len; - else - { - /* - At the moment we support options_len up to 64K. - We can easily extend it in the future, if the need arises. - */ - DBUG_ASSERT(options_len <= 65535); - int2store(pos + 1, options_len); - pos+= 3; - } + pos= extra2_write_len(pos, options_len); pos= engine_table_options_frm_image(pos, create_info->option_list, create_fields, keys, key_info); } |