Skip to content

Commit cccc96d

Browse files
committed
Fixed wrong initializations of Dynamic_array
Other things: - Added size() function to Dynamic_array()
1 parent 8f33f49 commit cccc96d

File tree

7 files changed

+14
-10
lines changed

7 files changed

+14
-10
lines changed

sql/item_subselect.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3022,7 +3022,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
30223022
Query_arena *arena= NULL, backup;
30233023
int res= FALSE;
30243024
List<Item> outer;
3025-
Dynamic_array<EQ_FIELD_OUTER> eqs(5, 5);
3025+
Dynamic_array<EQ_FIELD_OUTER> eqs(PSI_INSTRUMENT_MEM, 5, 5);
30263026
bool will_be_correlated;
30273027
DBUG_ENTER("Item_exists_subselect::exists2in_processor");
30283028

sql/opt_range.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8027,7 +8027,7 @@ SEL_TREE *Item_func_in::get_func_row_mm_tree(RANGE_OPT_PARAM *param,
80278027
table_map param_comp= ~(param->prev_tables | param->read_tables |
80288028
param->current_table);
80298029
uint row_cols= key_row->cols();
8030-
Dynamic_array <Key_col_info> key_cols_info(row_cols);
8030+
Dynamic_array <Key_col_info> key_cols_info(PSI_INSTRUMENT_MEM,row_cols);
80318031
cmp_item_row *row_cmp_item;
80328032

80338033
if (array)

sql/rowid_filter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ class Refpos_container_sorted_array : public Sql_alloc
311311

312312
bool alloc()
313313
{
314-
array= new Dynamic_array<char> (elem_size * max_elements,
314+
array= new Dynamic_array<char> (PSI_INSTRUMENT_MEM,
315+
elem_size * max_elements,
315316
elem_size * max_elements/sizeof(char) + 1);
316317
return array == NULL;
317318
}

sql/rpl_rli.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,8 @@ scan_all_gtid_slave_pos_table(THD *thd, int (*cb)(THD *, LEX_CSTRING *, void *),
17101710
else
17111711
{
17121712
size_t i;
1713-
Dynamic_array<LEX_CSTRING*> files(dirp->number_of_files);
1713+
Dynamic_array<LEX_CSTRING*> files(PSI_INSTRUMENT_MEM,
1714+
dirp->number_of_files);
17141715
Discovered_table_list tl(thd, &files);
17151716
int err;
17161717

sql/sql_acl.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username,
655655
#define ROLE_OPENED (1L << 3)
656656

657657
static DYNAMIC_ARRAY acl_hosts, acl_users, acl_proxy_users;
658-
static Dynamic_array<ACL_DB> acl_dbs(PSI_INSTRUMENT_MEM, 0U, 50U);
658+
static Dynamic_array<ACL_DB> acl_dbs(PSI_INSTRUMENT_MEM, 0, 50);
659659
typedef Dynamic_array<ACL_DB>::CMP_FUNC acl_dbs_cmp;
660660
static HASH acl_roles;
661661
/*
@@ -2786,7 +2786,7 @@ void acl_free(bool end)
27862786
bool acl_reload(THD *thd)
27872787
{
27882788
DYNAMIC_ARRAY old_acl_hosts, old_acl_users, old_acl_proxy_users;
2789-
Dynamic_array<ACL_DB> old_acl_dbs(0U,0U);
2789+
Dynamic_array<ACL_DB> old_acl_dbs(PSI_INSTRUMENT_MEM, 0, 0);
27902790
HASH old_acl_roles, old_acl_roles_mappings;
27912791
MEM_ROOT old_mem;
27922792
int result;
@@ -6170,8 +6170,8 @@ static int traverse_role_graph_impl(ACL_USER_BASE *user, void *context,
61706170
It uses a Dynamic_array to reduce the number of
61716171
malloc calls to a minimum
61726172
*/
6173-
Dynamic_array<NODE_STATE> stack(20,50);
6174-
Dynamic_array<ACL_USER_BASE *> to_clear(20,50);
6173+
Dynamic_array<NODE_STATE> stack(PSI_INSTRUMENT_MEM, 20,50);
6174+
Dynamic_array<ACL_USER_BASE *> to_clear(PSI_INSTRUMENT_MEM, 20, 50);
61756175
NODE_STATE state; /* variable used to insert elements in the stack */
61766176
int result= 0;
61776177

sql/sql_array.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ template <typename Element_type> class Bounds_checked_array
112112

113113
template <class Elem> class Dynamic_array
114114
{
115-
DYNAMIC_ARRAY array;
115+
DYNAMIC_ARRAY array;
116116
public:
117117
Dynamic_array(PSI_memory_key psi_key, uint prealloc=16, uint increment=16)
118118
{
@@ -170,6 +170,8 @@ template <class Elem> class Dynamic_array
170170
return ((const Elem*)array.buffer) + array.elements - 1;
171171
}
172172

173+
size_t size() const { return array.elements; }
174+
173175
const Elem *end() const
174176
{
175177
return back() + 1;

sql/sql_db.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
12281228
DBUG_PRINT("enter",("path: %s", path));
12291229

12301230
/* first, get the list of tables */
1231-
Dynamic_array<LEX_CSTRING*> files(dirp->number_of_files);
1231+
Dynamic_array<LEX_CSTRING*> files(PSI_INSTRUMENT_MEM, dirp->number_of_files);
12321232
Discovered_table_list tl(thd, &files);
12331233
if (ha_discover_table_names(thd, &db, dirp, &tl, true))
12341234
DBUG_RETURN(1);

0 commit comments

Comments
 (0)