mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Cleanups
- Avoid some realloc() during startup - Ensure that file_key_management_plugin frees it's memory early, even if it's linked statically. - Fixed compiler warnings from unused variables and missing destructors - Fixed wrong indentation
This commit is contained in:
@ -565,7 +565,7 @@ int my_load_defaults(const char *conf_file, const char **groups,
|
|||||||
for (; *groups ; groups++)
|
for (; *groups ; groups++)
|
||||||
group.count++;
|
group.count++;
|
||||||
|
|
||||||
if (my_init_dynamic_array(&args, sizeof(char*),*argc, 32, MYF(0)))
|
if (my_init_dynamic_array(&args, sizeof(char*), 128, 64, MYF(0)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
ctx.alloc= &alloc;
|
ctx.alloc= &alloc;
|
||||||
|
@ -169,6 +169,11 @@ static int file_key_management_plugin_init(void *p)
|
|||||||
return parser.parse(&keys);
|
return parser.parse(&keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int file_key_management_plugin_deinit(void *p)
|
||||||
|
{
|
||||||
|
keys.free_memory();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Plugin library descriptor
|
Plugin library descriptor
|
||||||
*/
|
*/
|
||||||
@ -181,7 +186,7 @@ maria_declare_plugin(file_key_management)
|
|||||||
"File-based key management plugin",
|
"File-based key management plugin",
|
||||||
PLUGIN_LICENSE_GPL,
|
PLUGIN_LICENSE_GPL,
|
||||||
file_key_management_plugin_init,
|
file_key_management_plugin_init,
|
||||||
NULL,
|
file_key_management_plugin_deinit,
|
||||||
0x0100 /* 1.0 */,
|
0x0100 /* 1.0 */,
|
||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
settings,
|
settings,
|
||||||
|
@ -9427,7 +9427,8 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
|
|||||||
|
|
||||||
/* prepare all_options array */
|
/* prepare all_options array */
|
||||||
my_init_dynamic_array(&all_options, sizeof(my_option),
|
my_init_dynamic_array(&all_options, sizeof(my_option),
|
||||||
array_elements(my_long_options),
|
array_elements(my_long_options) +
|
||||||
|
sys_var_elements(),
|
||||||
array_elements(my_long_options)/4, MYF(0));
|
array_elements(my_long_options)/4, MYF(0));
|
||||||
add_many_options(&all_options, my_long_options, array_elements(my_long_options));
|
add_many_options(&all_options, my_long_options, array_elements(my_long_options));
|
||||||
sys_var_add_options(&all_options, 0);
|
sys_var_add_options(&all_options, 0);
|
||||||
|
@ -347,10 +347,11 @@ public:
|
|||||||
|
|
||||||
rpl_parallel parallel;
|
rpl_parallel parallel;
|
||||||
/*
|
/*
|
||||||
The relay_log_state keeps track of the current binlog state of the execution
|
The relay_log_state keeps track of the current binlog state of the
|
||||||
of the relay log. This is used to know where to resume current GTID position
|
execution of the relay log. This is used to know where to resume
|
||||||
if the slave thread is stopped and restarted.
|
current GTID position if the slave thread is stopped and
|
||||||
It is only accessed from the SQL thread, so it does not need any locking.
|
restarted. It is only accessed from the SQL thread, so it does
|
||||||
|
not need any locking.
|
||||||
*/
|
*/
|
||||||
rpl_binlog_state relay_log_state;
|
rpl_binlog_state relay_log_state;
|
||||||
/*
|
/*
|
||||||
|
@ -64,7 +64,7 @@ int sys_var_init()
|
|||||||
/* Must be already initialized. */
|
/* Must be already initialized. */
|
||||||
DBUG_ASSERT(system_charset_info != NULL);
|
DBUG_ASSERT(system_charset_info != NULL);
|
||||||
|
|
||||||
if (my_hash_init(&system_variable_hash, system_charset_info, 100, 0,
|
if (my_hash_init(&system_variable_hash, system_charset_info, 700, 0,
|
||||||
0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
|
0, (my_hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -78,6 +78,11 @@ error:
|
|||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint sys_var_elements()
|
||||||
|
{
|
||||||
|
return system_variable_hash.records;
|
||||||
|
}
|
||||||
|
|
||||||
int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags)
|
int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags)
|
||||||
{
|
{
|
||||||
uint saved_elements= long_options->elements;
|
uint saved_elements= long_options->elements;
|
||||||
|
@ -414,6 +414,7 @@ extern sys_var *Sys_autocommit_ptr;
|
|||||||
CHARSET_INFO *get_old_charset_by_name(const char *old_name);
|
CHARSET_INFO *get_old_charset_by_name(const char *old_name);
|
||||||
|
|
||||||
int sys_var_init();
|
int sys_var_init();
|
||||||
|
uint sys_var_elements();
|
||||||
int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags);
|
int sys_var_add_options(DYNAMIC_ARRAY *long_options, int parse_flags);
|
||||||
void sys_var_end(void);
|
void sys_var_end(void);
|
||||||
|
|
||||||
|
@ -239,6 +239,11 @@ public:
|
|||||||
delete_dynamic(&array);
|
delete_dynamic(&array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_memory()
|
||||||
|
{
|
||||||
|
delete_dynamic(&array);
|
||||||
|
}
|
||||||
|
|
||||||
typedef int (*CMP_FUNC)(const Elem *el1, const Elem *el2);
|
typedef int (*CMP_FUNC)(const Elem *el1, const Elem *el2);
|
||||||
|
|
||||||
void sort(CMP_FUNC cmp_func)
|
void sort(CMP_FUNC cmp_func)
|
||||||
|
@ -1544,22 +1544,26 @@ int plugin_init(int *argc, char **argv, int flags)
|
|||||||
init_alloc_root(&plugin_vars_mem_root, 4096, 4096, MYF(0));
|
init_alloc_root(&plugin_vars_mem_root, 4096, 4096, MYF(0));
|
||||||
init_alloc_root(&tmp_root, 4096, 4096, MYF(0));
|
init_alloc_root(&tmp_root, 4096, 4096, MYF(0));
|
||||||
|
|
||||||
if (my_hash_init(&bookmark_hash, &my_charset_bin, 16, 0, 0,
|
if (my_hash_init(&bookmark_hash, &my_charset_bin, 32, 0, 0,
|
||||||
get_bookmark_hash_key, NULL, HASH_UNIQUE))
|
get_bookmark_hash_key, NULL, HASH_UNIQUE))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
||||||
mysql_mutex_init(key_LOCK_plugin, &LOCK_plugin, MY_MUTEX_INIT_FAST);
|
mysql_mutex_init(key_LOCK_plugin, &LOCK_plugin, MY_MUTEX_INIT_FAST);
|
||||||
|
|
||||||
|
/*
|
||||||
|
The 80 is from 2016-04-27 when we had 71 default plugins
|
||||||
|
Big enough to avoid many mallocs even in future
|
||||||
|
*/
|
||||||
if (my_init_dynamic_array(&plugin_dl_array,
|
if (my_init_dynamic_array(&plugin_dl_array,
|
||||||
sizeof(struct st_plugin_dl *), 16, 16, MYF(0)) ||
|
sizeof(struct st_plugin_dl *), 16, 16, MYF(0)) ||
|
||||||
my_init_dynamic_array(&plugin_array,
|
my_init_dynamic_array(&plugin_array,
|
||||||
sizeof(struct st_plugin_int *), 16, 16, MYF(0)))
|
sizeof(struct st_plugin_int *), 80, 32, MYF(0)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
|
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
|
||||||
{
|
{
|
||||||
if (my_hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0,
|
if (my_hash_init(&plugin_hash[i], system_charset_info, 32, 0, 0,
|
||||||
get_plugin_hash_key, NULL, HASH_UNIQUE))
|
get_plugin_hash_key, NULL, HASH_UNIQUE))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2017,7 +2017,7 @@ JOIN::optimize_inner()
|
|||||||
TODO: Explain the quick_group part of the test below.
|
TODO: Explain the quick_group part of the test below.
|
||||||
*/
|
*/
|
||||||
if ((ordered_index_usage != ordered_index_group_by) &&
|
if ((ordered_index_usage != ordered_index_group_by) &&
|
||||||
(tmp_table_param.quick_group && !procedure ||
|
((tmp_table_param.quick_group && !procedure) ||
|
||||||
(tab->emb_sj_nest &&
|
(tab->emb_sj_nest &&
|
||||||
best_positions[const_tables].sj_strategy == SJ_OPT_LOOSE_SCAN)))
|
best_positions[const_tables].sj_strategy == SJ_OPT_LOOSE_SCAN)))
|
||||||
{
|
{
|
||||||
@ -3123,7 +3123,7 @@ void JOIN::save_explain_data(Explain_query *output, bool can_overwrite,
|
|||||||
Explain_union *eu= output->get_union(nr);
|
Explain_union *eu= output->get_union(nr);
|
||||||
explain= &eu->fake_select_lex_explain;
|
explain= &eu->fake_select_lex_explain;
|
||||||
join_tab[0].tracker= eu->get_fake_select_lex_tracker();
|
join_tab[0].tracker= eu->get_fake_select_lex_tracker();
|
||||||
for (int i=0 ; i < top_join_tab_count + aggr_tables; i++)
|
for (uint i=0 ; i < top_join_tab_count + aggr_tables; i++)
|
||||||
{
|
{
|
||||||
if (join_tab[i].filesort)
|
if (join_tab[i].filesort)
|
||||||
{
|
{
|
||||||
@ -3360,23 +3360,25 @@ JOIN::destroy()
|
|||||||
|
|
||||||
cleanup(1);
|
cleanup(1);
|
||||||
|
|
||||||
uint tables= table_count+aggr_tables;
|
if (join_tab)
|
||||||
|
|
||||||
if (join_tab) // We should not have tables > 0 and join_tab != NULL
|
|
||||||
for (JOIN_TAB *tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITH_CONST_TABLES);
|
|
||||||
tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
|
||||||
{
|
{
|
||||||
if (tab->aggr)
|
DBUG_ASSERT(table_count+aggr_tables > 0);
|
||||||
|
for (JOIN_TAB *tab= first_linear_tab(this, WITH_BUSH_ROOTS,
|
||||||
|
WITH_CONST_TABLES);
|
||||||
|
tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
|
||||||
{
|
{
|
||||||
free_tmp_table(thd, tab->table);
|
if (tab->aggr)
|
||||||
delete tab->tmp_table_param;
|
{
|
||||||
tab->tmp_table_param= NULL;
|
free_tmp_table(thd, tab->table);
|
||||||
tab->aggr= NULL;
|
delete tab->tmp_table_param;
|
||||||
|
tab->tmp_table_param= NULL;
|
||||||
|
tab->aggr= NULL;
|
||||||
|
}
|
||||||
|
tab->table= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tab->table= NULL;
|
|
||||||
}
|
}
|
||||||
/* Cleanup items referencing temporary table columns */
|
|
||||||
|
/* Cleanup items referencing temporary table columns */
|
||||||
cleanup_item_list(tmp_all_fields1);
|
cleanup_item_list(tmp_all_fields1);
|
||||||
cleanup_item_list(tmp_all_fields3);
|
cleanup_item_list(tmp_all_fields3);
|
||||||
destroy_sj_tmp_tables(this);
|
destroy_sj_tmp_tables(this);
|
||||||
@ -24426,9 +24428,6 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
DBUG_ENTER("select_describe");
|
DBUG_ENTER("select_describe");
|
||||||
|
|
||||||
/* Update the QPF with latest values of using_temporary, using_filesort */
|
/* Update the QPF with latest values of using_temporary, using_filesort */
|
||||||
Explain_select *explain_sel;
|
|
||||||
uint select_nr= join->select_lex->select_number;
|
|
||||||
|
|
||||||
for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit();
|
for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit();
|
||||||
unit;
|
unit;
|
||||||
unit= unit->next_unit())
|
unit= unit->next_unit())
|
||||||
|
@ -3044,7 +3044,7 @@ int add_status_vars(SHOW_VAR *list)
|
|||||||
if (status_vars_inited)
|
if (status_vars_inited)
|
||||||
mysql_mutex_lock(&LOCK_show_status);
|
mysql_mutex_lock(&LOCK_show_status);
|
||||||
if (!all_status_vars.buffer && // array is not allocated yet - do it now
|
if (!all_status_vars.buffer && // array is not allocated yet - do it now
|
||||||
my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 200, 20, MYF(0)))
|
my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 250, 50, MYF(0)))
|
||||||
{
|
{
|
||||||
res= 1;
|
res= 1;
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -577,6 +577,8 @@ class Rowid_seq_cursor
|
|||||||
uint ref_length;
|
uint ref_length;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~Rowid_seq_cursor() {}
|
||||||
|
|
||||||
void init(READ_RECORD *info)
|
void init(READ_RECORD *info)
|
||||||
{
|
{
|
||||||
cache_start= info->cache_pos;
|
cache_start= info->cache_pos;
|
||||||
@ -631,6 +633,7 @@ class Table_read_cursor : public Rowid_seq_cursor
|
|||||||
*/
|
*/
|
||||||
READ_RECORD *read_record;
|
READ_RECORD *read_record;
|
||||||
public:
|
public:
|
||||||
|
virtual ~Table_read_cursor() {}
|
||||||
|
|
||||||
void init(READ_RECORD *info)
|
void init(READ_RECORD *info)
|
||||||
{
|
{
|
||||||
|
@ -89,8 +89,8 @@ public:
|
|||||||
class Window_spec : public Sql_alloc
|
class Window_spec : public Sql_alloc
|
||||||
{
|
{
|
||||||
bool window_names_are_checked;
|
bool window_names_are_checked;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~Window_spec() {}
|
||||||
|
|
||||||
LEX_STRING *window_ref;
|
LEX_STRING *window_ref;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user