Commit 9c089b04 authored by Sergei Golubchik's avatar Sergei Golubchik

TABLE_SHARE::free_frm_image() method to free the memory

allocated by the same allocator as in TABLE_SHARE::read_frm_image()
parent 37379ef0
...@@ -2137,6 +2137,13 @@ bool TABLE_SHARE::read_frm_image(const uchar **frm, size_t *len) ...@@ -2137,6 +2137,13 @@ bool TABLE_SHARE::read_frm_image(const uchar **frm, size_t *len)
} }
void TABLE_SHARE::free_frm_image(const uchar *frm)
{
if (frm)
my_free(const_cast<uchar*>(frm));
}
/* /*
@brief @brief
Clear GET_FIXED_FIELDS_FLAG in all fields of a table Clear GET_FIXED_FIELDS_FLAG in all fields of a table
......
...@@ -991,12 +991,38 @@ struct TABLE_SHARE ...@@ -991,12 +991,38 @@ struct TABLE_SHARE
uint actual_n_key_parts(THD *thd); uint actual_n_key_parts(THD *thd);
LEX_CUSTRING *frm_image; ///< only during CREATE TABLE (@sa ha_create_table) LEX_CUSTRING *frm_image; ///< only during CREATE TABLE (@sa ha_create_table)
/*
populates TABLE_SHARE from the table description in the binary frm image.
if 'write' is true, this frm image is also written into a corresponding
frm file, that serves as a persistent metadata cache to avoid
discovering the table over and over again
*/
int init_from_binary_frm_image(THD *thd, bool write, int init_from_binary_frm_image(THD *thd, bool write,
const uchar *frm_image, size_t frm_length); const uchar *frm_image, size_t frm_length);
/*
populates TABLE_SHARE from the table description, specified as the
complete CREATE TABLE sql statement.
if 'write' is true, this frm image is also written into a corresponding
frm file, that serves as a persistent metadata cache to avoid
discovering the table over and over again
*/
int init_from_sql_statement_string(THD *thd, bool write, int init_from_sql_statement_string(THD *thd, bool write,
const char *sql, size_t sql_length); const char *sql, size_t sql_length);
/*
writes the frm image to an frm file, corresponding to this table
*/
bool write_frm_image(const uchar *frm_image, size_t frm_length); bool write_frm_image(const uchar *frm_image, size_t frm_length);
/*
returns an frm image for this table.
the memory is allocated and must be freed later
*/
bool read_frm_image(const uchar **frm_image, size_t *frm_length); bool read_frm_image(const uchar **frm_image, size_t *frm_length);
/* frees the memory allocated in read_frm_image */
void free_frm_image(const uchar *frm);
}; };
......
...@@ -764,7 +764,7 @@ int ha_archive::create(const char *name, TABLE *table_arg, ...@@ -764,7 +764,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
if (!table_arg->s->read_frm_image(&frm_ptr, &frm_len)) if (!table_arg->s->read_frm_image(&frm_ptr, &frm_len))
{ {
azwrite_frm(&create_stream, frm_ptr, frm_len); azwrite_frm(&create_stream, frm_ptr, frm_len);
my_free(const_cast<uchar*>(frm_ptr)); table_arg->s->free_frm_image(frm_ptr);
} }
if (create_info->comment.str) if (create_info->comment.str)
......
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