Commit 9dbeb988 authored by unknown's avatar unknown

MDEV-4993:Impossible to free a dynamic column

Fix of API of dynamic columns (it made uniform and real function used to free the string).
parent ce0d5539
......@@ -126,11 +126,11 @@ dynamic_column_get(DYNAMIC_COLUMN *org, uint column_nr,
/* new functions */
enum enum_dyncol_func_result
mariadb_dyncol_create_many(DYNAMIC_COLUMN *str,
uint column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values,
my_bool new_string);
mariadb_dyncol_create_many_num(DYNAMIC_COLUMN *str,
uint column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values,
my_bool new_string);
enum enum_dyncol_func_result
mariadb_dyncol_create_many_named(DYNAMIC_COLUMN *str,
uint column_count,
......@@ -140,10 +140,10 @@ mariadb_dyncol_create_many_named(DYNAMIC_COLUMN *str,
enum enum_dyncol_func_result
mariadb_dyncol_update_many(DYNAMIC_COLUMN *str,
uint add_column_count,
uint *column_keys,
DYNAMIC_COLUMN_VALUE *values);
mariadb_dyncol_update_many_num(DYNAMIC_COLUMN *str,
uint add_column_count,
uint *column_keys,
DYNAMIC_COLUMN_VALUE *values);
enum enum_dyncol_func_result
mariadb_dyncol_update_many_named(DYNAMIC_COLUMN *str,
uint add_column_count,
......@@ -152,13 +152,13 @@ mariadb_dyncol_update_many_named(DYNAMIC_COLUMN *str,
enum enum_dyncol_func_result
mariadb_dyncol_exists(DYNAMIC_COLUMN *org, uint column_nr);
mariadb_dyncol_exists_num(DYNAMIC_COLUMN *org, uint column_nr);
enum enum_dyncol_func_result
mariadb_dyncol_exists_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name);
/* List of not NULL columns */
enum enum_dyncol_func_result
mariadb_dyncol_list(DYNAMIC_COLUMN *str, uint *count, uint **nums);
mariadb_dyncol_list_num(DYNAMIC_COLUMN *str, uint *count, uint **nums);
enum enum_dyncol_func_result
mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count,
MYSQL_LEX_STRING **names);
......@@ -167,8 +167,8 @@ mariadb_dyncol_list_named(DYNAMIC_COLUMN *str, uint *count,
if the column do not exists it is NULL
*/
enum enum_dyncol_func_result
mariadb_dyncol_get(DYNAMIC_COLUMN *org, uint column_nr,
DYNAMIC_COLUMN_VALUE *store_it_here);
mariadb_dyncol_get_num(DYNAMIC_COLUMN *org, uint column_nr,
DYNAMIC_COLUMN_VALUE *store_it_here);
enum enum_dyncol_func_result
mariadb_dyncol_get_named(DYNAMIC_COLUMN *str, MYSQL_LEX_STRING *name,
DYNAMIC_COLUMN_VALUE *store_it_here);
......@@ -181,8 +181,8 @@ mariadb_dyncol_check(DYNAMIC_COLUMN *str);
enum enum_dyncol_func_result
mariadb_dyncol_json(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json);
#define dynamic_column_initialize(A) memset((A), 0, sizeof(*(A)))
#define dynamic_column_column_free(V) dynstr_free(V)
#define mariadb_dyncol_init(A) memset((A), 0, sizeof(*(A)))
void mariadb_dyncol_free(DYNAMIC_COLUMN *str);
/* conversion of values to 3 base types */
enum enum_dyncol_func_result
......
......@@ -223,15 +223,16 @@ dynamic_column_exists
dynamic_column_list
dynamic_column_get
dynamic_column_prepare_decimal
mariadb_dyncol_create_many
mariadb_dyncol_create_many_num
mariadb_dyncol_create_many_named
mariadb_dyncol_update_many
mariadb_dyncol_update_many_num
mariadb_dyncol_update_many_named
mariadb_dyncol_exists
mariadb_dyncol_exists_num
mariadb_dyncol_exists_named
mariadb_dyncol_list
mariadb_dyncol_free
mariadb_dyncol_list_num
mariadb_dyncol_list_named
mariadb_dyncol_get
mariadb_dyncol_get_num
mariadb_dyncol_get_named
mariadb_dyncol_has_names
mariadb_dyncol_check
......
......@@ -1632,7 +1632,7 @@ dynamic_new_column_store(DYNAMIC_COLUMN *str,
}
else
{
dynamic_column_initialize(str);
mariadb_dyncol_init(str);
}
}
else
......@@ -1789,7 +1789,7 @@ dynamic_column_create_many_internal_fmt(DYNAMIC_COLUMN *str,
if (new_str)
{
/* to make dynstr_free() working in case of errors */
bzero(str, sizeof(DYNAMIC_COLUMN));
mariadb_dyncol_init(str);
}
if ((rc= calc_var_sizes(&header, column_count, column_keys, values)) < 0)
......@@ -1838,13 +1838,13 @@ dynamic_column_create_many(DYNAMIC_COLUMN *str,
*/
enum enum_dyncol_func_result
mariadb_dyncol_create_many(DYNAMIC_COLUMN *str,
uint column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values,
my_bool new_string)
mariadb_dyncol_create_many_num(DYNAMIC_COLUMN *str,
uint column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values,
my_bool new_string)
{
DBUG_ENTER("mariadb_dyncol_create_many");
DBUG_ENTER("mariadb_dyncol_create_many_num");
DBUG_RETURN(dynamic_column_create_many_internal_fmt(str, column_count,
column_numbers, values,
new_string, FALSE));
......@@ -2199,8 +2199,8 @@ dynamic_column_get(DYNAMIC_COLUMN *str, uint column_nr,
}
enum enum_dyncol_func_result
mariadb_dyncol_get(DYNAMIC_COLUMN *str, uint column_nr,
DYNAMIC_COLUMN_VALUE *store_it_here)
mariadb_dyncol_get_num(DYNAMIC_COLUMN *str, uint column_nr,
DYNAMIC_COLUMN_VALUE *store_it_here)
{
return dynamic_column_get_internal(str, store_it_here, column_nr, NULL);
}
......@@ -2328,7 +2328,7 @@ dynamic_column_exists(DYNAMIC_COLUMN *str, uint column_nr)
}
enum enum_dyncol_func_result
mariadb_dyncol_exists(DYNAMIC_COLUMN *str, uint column_nr)
mariadb_dyncol_exists_num(DYNAMIC_COLUMN *str, uint column_nr)
{
return dynamic_column_exists_internal(str, column_nr, NULL);
}
......@@ -2438,7 +2438,7 @@ dynamic_column_list(DYNAMIC_COLUMN *str, DYNAMIC_ARRAY *array_of_uint)
@return ER_DYNCOL_* return code
*/
enum enum_dyncol_func_result
mariadb_dyncol_list(DYNAMIC_COLUMN *str, uint *count, uint **nums)
mariadb_dyncol_list_num(DYNAMIC_COLUMN *str, uint *count, uint **nums)
{
DYN_HEADER header;
uchar *read;
......@@ -2841,11 +2841,11 @@ dynamic_column_update_copy(DYNAMIC_COLUMN *str, PLAN *plan,
}
}
}
dynamic_column_column_free(str);
mariadb_dyncol_free(str);
*str= tmp;
return ER_DYNCOL_OK;
err:
dynamic_column_column_free(&tmp);
mariadb_dyncol_free(&tmp);
return ER_DYNCOL_FORMAT;
}
......@@ -3257,10 +3257,10 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str,
}
enum enum_dyncol_func_result
mariadb_dyncol_update_many(DYNAMIC_COLUMN *str,
uint add_column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values)
mariadb_dyncol_update_many_num(DYNAMIC_COLUMN *str,
uint add_column_count,
uint *column_numbers,
DYNAMIC_COLUMN_VALUE *values)
{
return dynamic_column_update_many_fmt(str, add_column_count, column_numbers,
values, FALSE);
......@@ -4336,3 +4336,12 @@ mariadb_dyncol_column_count(DYNAMIC_COLUMN *str, uint *column_count)
*column_count= header.column_count;
return rc;
}
/**
Free dynamic column
@param str The packed string
*/
void mariadb_dyncol_free(DYNAMIC_COLUMN *str)
{
dynstr_free(str);
}
......@@ -6309,7 +6309,7 @@ longlong Item_func_dyncol_exists::val_int()
/* We do not change the string, so could do this trick */
col.str= (char *)str->ptr();
rc= ((name == NULL) ?
mariadb_dyncol_exists(&col, (uint) num) :
mariadb_dyncol_exists_num(&col, (uint) num) :
mariadb_dyncol_exists_named(&col, name));
if (rc < 0)
{
......
......@@ -4220,11 +4220,11 @@ String *Item_func_dyncol_create::val_str(String *str)
if ((rc= ((names || force_names) ?
mariadb_dyncol_create_many_named(&col, column_count, keys_str,
vals, TRUE) :
mariadb_dyncol_create_many(&col, column_count, keys_num,
vals, TRUE))))
mariadb_dyncol_create_many_num(&col, column_count, keys_num,
vals, TRUE))))
{
dynamic_column_error_message(rc);
dynamic_column_column_free(&col);
mariadb_dyncol_free(&col);
res= NULL;
null_value= TRUE;
}
......@@ -4363,11 +4363,11 @@ String *Item_func_dyncol_add::val_str(String *str)
if ((rc= ((names || force_names) ?
mariadb_dyncol_update_many_named(&col, column_count,
keys_str, vals) :
mariadb_dyncol_update_many(&col, column_count,
keys_num, vals))))
mariadb_dyncol_update_many_num(&col, column_count,
keys_num, vals))))
{
dynamic_column_error_message(rc);
dynamic_column_column_free(&col);
mariadb_dyncol_free(&col);
goto null;
}
......@@ -4470,7 +4470,7 @@ bool Item_dyncol_get::get_dyn_value(DYNAMIC_COLUMN_VALUE *val, String *tmp)
dyn_str.str= (char*) res->ptr();
dyn_str.length= res->length();
if ((rc= ((name == NULL) ?
mariadb_dyncol_get(&dyn_str, (uint) num, val) :
mariadb_dyncol_get_num(&dyn_str, (uint) num, val) :
mariadb_dyncol_get_named(&dyn_str, name, val))))
{
dynamic_column_error_message(rc);
......
This diff is collapsed.
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