Commit cccc96d6 authored by Monty's avatar Monty

Fixed wrong initializations of Dynamic_array

Other things:
- Added size() function to Dynamic_array()
parent 8f33f49e
...@@ -3022,7 +3022,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg) ...@@ -3022,7 +3022,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
Query_arena *arena= NULL, backup; Query_arena *arena= NULL, backup;
int res= FALSE; int res= FALSE;
List<Item> outer; List<Item> outer;
Dynamic_array<EQ_FIELD_OUTER> eqs(5, 5); Dynamic_array<EQ_FIELD_OUTER> eqs(PSI_INSTRUMENT_MEM, 5, 5);
bool will_be_correlated; bool will_be_correlated;
DBUG_ENTER("Item_exists_subselect::exists2in_processor"); DBUG_ENTER("Item_exists_subselect::exists2in_processor");
......
...@@ -8027,7 +8027,7 @@ SEL_TREE *Item_func_in::get_func_row_mm_tree(RANGE_OPT_PARAM *param, ...@@ -8027,7 +8027,7 @@ SEL_TREE *Item_func_in::get_func_row_mm_tree(RANGE_OPT_PARAM *param,
table_map param_comp= ~(param->prev_tables | param->read_tables | table_map param_comp= ~(param->prev_tables | param->read_tables |
param->current_table); param->current_table);
uint row_cols= key_row->cols(); uint row_cols= key_row->cols();
Dynamic_array <Key_col_info> key_cols_info(row_cols); Dynamic_array <Key_col_info> key_cols_info(PSI_INSTRUMENT_MEM,row_cols);
cmp_item_row *row_cmp_item; cmp_item_row *row_cmp_item;
if (array) if (array)
......
...@@ -311,7 +311,8 @@ class Refpos_container_sorted_array : public Sql_alloc ...@@ -311,7 +311,8 @@ class Refpos_container_sorted_array : public Sql_alloc
bool alloc() bool alloc()
{ {
array= new Dynamic_array<char> (elem_size * max_elements, array= new Dynamic_array<char> (PSI_INSTRUMENT_MEM,
elem_size * max_elements,
elem_size * max_elements/sizeof(char) + 1); elem_size * max_elements/sizeof(char) + 1);
return array == NULL; return array == NULL;
} }
......
...@@ -1710,7 +1710,8 @@ scan_all_gtid_slave_pos_table(THD *thd, int (*cb)(THD *, LEX_CSTRING *, void *), ...@@ -1710,7 +1710,8 @@ scan_all_gtid_slave_pos_table(THD *thd, int (*cb)(THD *, LEX_CSTRING *, void *),
else else
{ {
size_t i; size_t i;
Dynamic_array<LEX_CSTRING*> files(dirp->number_of_files); Dynamic_array<LEX_CSTRING*> files(PSI_INSTRUMENT_MEM,
dirp->number_of_files);
Discovered_table_list tl(thd, &files); Discovered_table_list tl(thd, &files);
int err; int err;
......
...@@ -655,7 +655,7 @@ bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username, ...@@ -655,7 +655,7 @@ bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username,
#define ROLE_OPENED (1L << 3) #define ROLE_OPENED (1L << 3)
static DYNAMIC_ARRAY acl_hosts, acl_users, acl_proxy_users; static DYNAMIC_ARRAY acl_hosts, acl_users, acl_proxy_users;
static Dynamic_array<ACL_DB> acl_dbs(PSI_INSTRUMENT_MEM, 0U, 50U); static Dynamic_array<ACL_DB> acl_dbs(PSI_INSTRUMENT_MEM, 0, 50);
typedef Dynamic_array<ACL_DB>::CMP_FUNC acl_dbs_cmp; typedef Dynamic_array<ACL_DB>::CMP_FUNC acl_dbs_cmp;
static HASH acl_roles; static HASH acl_roles;
/* /*
...@@ -2786,7 +2786,7 @@ void acl_free(bool end) ...@@ -2786,7 +2786,7 @@ void acl_free(bool end)
bool acl_reload(THD *thd) bool acl_reload(THD *thd)
{ {
DYNAMIC_ARRAY old_acl_hosts, old_acl_users, old_acl_proxy_users; DYNAMIC_ARRAY old_acl_hosts, old_acl_users, old_acl_proxy_users;
Dynamic_array<ACL_DB> old_acl_dbs(0U,0U); Dynamic_array<ACL_DB> old_acl_dbs(PSI_INSTRUMENT_MEM, 0, 0);
HASH old_acl_roles, old_acl_roles_mappings; HASH old_acl_roles, old_acl_roles_mappings;
MEM_ROOT old_mem; MEM_ROOT old_mem;
int result; int result;
...@@ -6170,8 +6170,8 @@ static int traverse_role_graph_impl(ACL_USER_BASE *user, void *context, ...@@ -6170,8 +6170,8 @@ static int traverse_role_graph_impl(ACL_USER_BASE *user, void *context,
It uses a Dynamic_array to reduce the number of It uses a Dynamic_array to reduce the number of
malloc calls to a minimum malloc calls to a minimum
*/ */
Dynamic_array<NODE_STATE> stack(20,50); Dynamic_array<NODE_STATE> stack(PSI_INSTRUMENT_MEM, 20,50);
Dynamic_array<ACL_USER_BASE *> to_clear(20,50); Dynamic_array<ACL_USER_BASE *> to_clear(PSI_INSTRUMENT_MEM, 20, 50);
NODE_STATE state; /* variable used to insert elements in the stack */ NODE_STATE state; /* variable used to insert elements in the stack */
int result= 0; int result= 0;
......
...@@ -112,7 +112,7 @@ template <typename Element_type> class Bounds_checked_array ...@@ -112,7 +112,7 @@ template <typename Element_type> class Bounds_checked_array
template <class Elem> class Dynamic_array template <class Elem> class Dynamic_array
{ {
DYNAMIC_ARRAY array; DYNAMIC_ARRAY array;
public: public:
Dynamic_array(PSI_memory_key psi_key, uint prealloc=16, uint increment=16) Dynamic_array(PSI_memory_key psi_key, uint prealloc=16, uint increment=16)
{ {
...@@ -170,6 +170,8 @@ template <class Elem> class Dynamic_array ...@@ -170,6 +170,8 @@ template <class Elem> class Dynamic_array
return ((const Elem*)array.buffer) + array.elements - 1; return ((const Elem*)array.buffer) + array.elements - 1;
} }
size_t size() const { return array.elements; }
const Elem *end() const const Elem *end() const
{ {
return back() + 1; return back() + 1;
......
...@@ -1228,7 +1228,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp, ...@@ -1228,7 +1228,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
DBUG_PRINT("enter",("path: %s", path)); DBUG_PRINT("enter",("path: %s", path));
/* first, get the list of tables */ /* first, get the list of tables */
Dynamic_array<LEX_CSTRING*> files(dirp->number_of_files); Dynamic_array<LEX_CSTRING*> files(PSI_INSTRUMENT_MEM, dirp->number_of_files);
Discovered_table_list tl(thd, &files); Discovered_table_list tl(thd, &files);
if (ha_discover_table_names(thd, &db, dirp, &tl, true)) if (ha_discover_table_names(thd, &db, dirp, &tl, true))
DBUG_RETURN(1); DBUG_RETURN(1);
......
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