MDEV-26221: DYNAMIC_ARRAY use size_t for sizes

https://jira.mariadb.org/browse/MDEV-26221
my_sys DYNAMIC_ARRAY and DYNAMIC_STRING inconsistancy

The DYNAMIC_STRING uses size_t for sizes, but DYNAMIC_ARRAY used uint.
This patch adjusts DYNAMIC_ARRAY to use size_t like DYNAMIC_STRING.

As the MY_DIR member number_of_files is copied from a DYNAMIC_ARRAY,
this is changed to be size_t.

As MY_TMPDIR members 'cur' and 'max' are copied from a DYNAMIC_ARRAY,
these are also changed to be size_t.

The lists of plugins and stored procedures use DYNAMIC_ARRAY,
but their APIs assume a size of 'uint'; these are unchanged.
This commit is contained in:
Eric Herman 2021-09-03 06:38:54 +02:00 committed by Vicențiu-Marian Ciorbaru
parent 9ab0d07e10
commit 401ff6994d
46 changed files with 188 additions and 191 deletions

View File

@ -954,7 +954,7 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
Log_event *e= NULL; Log_event *e= NULL;
// Print the row_event from the last one to the first one // Print the row_event from the last one to the first one
for (uint i= events_in_stmt.elements; i > 0; --i) for (size_t i= events_in_stmt.elements; i > 0; --i)
{ {
e= *(dynamic_element(&events_in_stmt, i - 1, Log_event**)); e= *(dynamic_element(&events_in_stmt, i - 1, Log_event**));
result= result || print_base64(print_event_info, e); result= result || print_base64(print_event_info, e);
@ -962,7 +962,7 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
// Copy all output into the Log_event // Copy all output into the Log_event
ev->output_buf.copy(e->output_buf); ev->output_buf.copy(e->output_buf);
// Delete Log_event // Delete Log_event
for (uint i= 0; i < events_in_stmt.elements-1; ++i) for (size_t i= 0; i < events_in_stmt.elements-1; ++i)
{ {
e= *(dynamic_element(&events_in_stmt, i, Log_event**)); e= *(dynamic_element(&events_in_stmt, i, Log_event**));
delete e; delete e;
@ -3170,7 +3170,7 @@ int main(int argc, char** argv)
*/ */
if (opt_flashback && retval != ERROR_STOP) if (opt_flashback && retval != ERROR_STOP)
{ {
for (uint i= binlog_events.elements; i > 0; --i) for (size_t i= binlog_events.elements; i > 0; --i)
{ {
LEX_STRING *event_str= dynamic_element(&binlog_events, i - 1, LEX_STRING *event_str= dynamic_element(&binlog_events, i - 1,
LEX_STRING*); LEX_STRING*);

View File

@ -3646,8 +3646,7 @@ void do_remove_file(struct st_command *command)
void do_remove_files_wildcard(struct st_command *command) void do_remove_files_wildcard(struct st_command *command)
{ {
int error= 0, sys_errno= 0; int error= 0, sys_errno= 0;
uint i; size_t i, directory_length;
size_t directory_length;
MY_DIR *dir_info; MY_DIR *dir_info;
FILEINFO *file; FILEINFO *file;
char dir_separator[2]; char dir_separator[2];
@ -3686,7 +3685,7 @@ void do_remove_files_wildcard(struct st_command *command)
/* Set default wild chars for wild_compare, is changed in embedded mode */ /* Set default wild chars for wild_compare, is changed in embedded mode */
set_wild_chars(1); set_wild_chars(1);
for (i= 0; i < (uint) dir_info->number_of_files; i++) for (i= 0; i < dir_info->number_of_files; i++)
{ {
file= dir_info->dir_entry + i; file= dir_info->dir_entry + i;
/* Remove only regular files, i.e. no directories etc. */ /* Remove only regular files, i.e. no directories etc. */
@ -3960,7 +3959,7 @@ void do_rmdir(struct st_command *command)
static int get_list_files(DYNAMIC_STRING *ds, const DYNAMIC_STRING *ds_dirname, static int get_list_files(DYNAMIC_STRING *ds, const DYNAMIC_STRING *ds_dirname,
const DYNAMIC_STRING *ds_wild) const DYNAMIC_STRING *ds_wild)
{ {
uint i; size_t i;
MY_DIR *dir_info; MY_DIR *dir_info;
FILEINFO *file; FILEINFO *file;
DBUG_ENTER("get_list_files"); DBUG_ENTER("get_list_files");
@ -3969,7 +3968,7 @@ static int get_list_files(DYNAMIC_STRING *ds, const DYNAMIC_STRING *ds_dirname,
if (!(dir_info= my_dir(ds_dirname->str, MYF(MY_WANT_SORT)))) if (!(dir_info= my_dir(ds_dirname->str, MYF(MY_WANT_SORT))))
DBUG_RETURN(1); DBUG_RETURN(1);
set_wild_chars(1); set_wild_chars(1);
for (i= 0; i < (uint) dir_info->number_of_files; i++) for (i= 0; i < dir_info->number_of_files; i++)
{ {
file= dir_info->dir_entry + i; file= dir_info->dir_entry + i;
if (ds_wild && ds_wild->length && if (ds_wild && ds_wild->length &&

View File

@ -440,7 +440,7 @@ static void clean_up(struct languages *lang_head, struct errors *error_head)
{ {
struct languages *tmp_lang, *next_language; struct languages *tmp_lang, *next_language;
struct errors *tmp_error, *next_error; struct errors *tmp_error, *next_error;
uint count, i; size_t count, i;
if (default_language_changed) if (default_language_changed)
my_free((void*) default_language); my_free((void*) default_language);
@ -724,7 +724,7 @@ static struct message *find_message(struct errors *err, const char *lang,
my_bool no_default) my_bool no_default)
{ {
struct message *tmp, *return_val= 0; struct message *tmp, *return_val= 0;
uint i, count; size_t i, count;
DBUG_ENTER("find_message"); DBUG_ENTER("find_message");
count= (err->msg).elements; count= (err->msg).elements;

View File

@ -64,8 +64,8 @@ typedef struct st_hash {
typedef uint HASH_SEARCH_STATE; typedef uint HASH_SEARCH_STATE;
#define my_hash_init(A,B,C,D,E,F,G,H,I) my_hash_init2(A,B,0,C,D,E,F,G,0,H,I) #define my_hash_init(A,B,C,D,E,F,G,H,I) my_hash_init2(A,B,0,C,D,E,F,G,0,H,I)
my_bool my_hash_init2(PSI_memory_key psi_key, HASH *hash, uint growth_size, my_bool my_hash_init2(PSI_memory_key psi_key, HASH *hash, size_t growth_size,
CHARSET_INFO *charset, ulong default_array_elements, CHARSET_INFO *charset, size_t default_array_elements,
size_t key_offset, size_t key_length, size_t key_offset, size_t key_length,
my_hash_get_key get_key, my_hash_function hash_function, my_hash_get_key get_key, my_hash_function hash_function,
void (*free_element)(void*), uint flags); void (*free_element)(void*), uint flags);

View File

@ -94,13 +94,13 @@ typedef struct fileinfo
typedef struct st_my_dir /* Struct returned from my_dir */ typedef struct st_my_dir /* Struct returned from my_dir */
{ {
/* /*
These members are just copies of parts of DYNAMIC_ARRAY structure, These members are just copies of parts of DYNAMIC_ARRAY structure,
which is allocated right after the end of MY_DIR structure (MEM_ROOT which is allocated right after the end of MY_DIR structure (MEM_ROOT
for storing names is also resides there). We've left them here because for storing names is also resides there). We've left them here because
we don't want to change code that uses my_dir. we don't want to change code that uses my_dir.
*/ */
struct fileinfo *dir_entry; struct fileinfo *dir_entry;
uint number_of_files; size_t number_of_files;
} MY_DIR; } MY_DIR;
extern MY_DIR *my_dir(const char *path,myf MyFlags); extern MY_DIR *my_dir(const char *path,myf MyFlags);

View File

@ -345,9 +345,9 @@ typedef void (*FREE_FUNC)(void *);
typedef struct st_dynamic_array typedef struct st_dynamic_array
{ {
uchar *buffer; uchar *buffer;
uint elements,max_element; size_t elements, max_element;
uint alloc_increment; size_t alloc_increment;
uint size_of_element; size_t size_of_element;
PSI_memory_key m_psi_key; PSI_memory_key m_psi_key;
myf malloc_flags; myf malloc_flags;
} DYNAMIC_ARRAY; } DYNAMIC_ARRAY;
@ -356,7 +356,7 @@ typedef struct st_my_tmpdir
{ {
DYNAMIC_ARRAY full_list; DYNAMIC_ARRAY full_list;
char **list; char **list;
uint cur, max; size_t cur, max;
mysql_mutex_t mutex; mysql_mutex_t mutex;
} MY_TMPDIR; } MY_TMPDIR;
@ -836,18 +836,18 @@ File create_temp_file(char *to, const char *dir, const char *pfx,
#define my_init_dynamic_array(A,B,C,D,E,F) init_dynamic_array2(A,B,C,NULL,D,E,F) #define my_init_dynamic_array(A,B,C,D,E,F) init_dynamic_array2(A,B,C,NULL,D,E,F)
#define my_init_dynamic_array2(A,B,C,D,E,F,G) init_dynamic_array2(A,B,C,D,E,F,G) #define my_init_dynamic_array2(A,B,C,D,E,F,G) init_dynamic_array2(A,B,C,D,E,F,G)
extern my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array, extern my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array,
uint element_size, void *init_buffer, size_t element_size, void *init_buffer,
uint init_alloc, uint alloc_increment, size_t init_alloc, size_t alloc_increment,
myf my_flags); myf my_flags);
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void* element); extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void* element);
extern void *alloc_dynamic(DYNAMIC_ARRAY *array); extern void *alloc_dynamic(DYNAMIC_ARRAY *array);
extern void *pop_dynamic(DYNAMIC_ARRAY*); extern void *pop_dynamic(DYNAMIC_ARRAY*);
extern my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, extern my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element,
uint array_index); size_t array_index);
extern my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements); extern my_bool allocate_dynamic(DYNAMIC_ARRAY *array, size_t max_elements);
extern void get_dynamic(DYNAMIC_ARRAY *array, void *element, uint array_index); extern void get_dynamic(DYNAMIC_ARRAY *array, void *element, size_t array_index);
extern void delete_dynamic(DYNAMIC_ARRAY *array); extern void delete_dynamic(DYNAMIC_ARRAY *array);
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); extern void delete_dynamic_element(DYNAMIC_ARRAY *array, size_t array_index);
extern void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f); extern void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f);
extern void freeze_size(DYNAMIC_ARRAY *array); extern void freeze_size(DYNAMIC_ARRAY *array);
extern int get_index_dynamic(DYNAMIC_ARRAY *array, void *element); extern int get_index_dynamic(DYNAMIC_ARRAY *array, void *element);

View File

@ -41,8 +41,9 @@
*/ */
my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array, my_bool init_dynamic_array2(PSI_memory_key psi_key, DYNAMIC_ARRAY *array,
uint element_size, void *init_buffer, size_t element_size, void *init_buffer,
uint init_alloc, uint alloc_increment, myf my_flags) size_t init_alloc, size_t alloc_increment,
myf my_flags)
{ {
DBUG_ENTER("init_dynamic_array2"); DBUG_ENTER("init_dynamic_array2");
if (!alloc_increment) if (!alloc_increment)
@ -198,7 +199,7 @@ void *pop_dynamic(DYNAMIC_ARRAY *array)
FALSE Ok FALSE Ok
*/ */
my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, uint idx) my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, size_t idx)
{ {
if (idx >= array->elements) if (idx >= array->elements)
{ {
@ -209,7 +210,7 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, uint idx)
array->elements=idx+1; array->elements=idx+1;
} }
memcpy(array->buffer+(idx * array->size_of_element),element, memcpy(array->buffer+(idx * array->size_of_element),element,
(size_t) array->size_of_element); array->size_of_element);
return FALSE; return FALSE;
} }
@ -230,13 +231,13 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, const void *element, uint idx)
TRUE Allocation of new memory failed TRUE Allocation of new memory failed
*/ */
my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements) my_bool allocate_dynamic(DYNAMIC_ARRAY *array, size_t max_elements)
{ {
DBUG_ENTER("allocate_dynamic"); DBUG_ENTER("allocate_dynamic");
if (max_elements >= array->max_element) if (max_elements >= array->max_element)
{ {
uint size; size_t size;
uchar *new_ptr; uchar *new_ptr;
size= (max_elements + array->alloc_increment)/array->alloc_increment; size= (max_elements + array->alloc_increment)/array->alloc_increment;
size*= array->alloc_increment; size*= array->alloc_increment;
@ -277,7 +278,7 @@ my_bool allocate_dynamic(DYNAMIC_ARRAY *array, uint max_elements)
idx Index of element wanted. idx Index of element wanted.
*/ */
void get_dynamic(DYNAMIC_ARRAY *array, void *element, uint idx) void get_dynamic(DYNAMIC_ARRAY *array, void *element, size_t idx)
{ {
if (idx >= array->elements) if (idx >= array->elements)
{ {
@ -320,7 +321,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array)
idx Index of element to be deleted idx Index of element to be deleted
*/ */
void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx) void delete_dynamic_element(DYNAMIC_ARRAY *array, size_t idx)
{ {
char *ptr= (char*) array->buffer+array->size_of_element*idx; char *ptr= (char*) array->buffer+array->size_of_element*idx;
array->elements--; array->elements--;
@ -339,7 +340,7 @@ void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx)
deleting the array; deleting the array;
*/ */
void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f) { void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f) {
uint i; size_t i;
char *ptr= (char*) array->buffer; char *ptr= (char*) array->buffer;
for (i= 0; i < array->elements; i++, ptr+= array->size_of_element) { for (i= 0; i < array->elements; i++, ptr+= array->size_of_element) {
f(ptr); f(ptr);
@ -357,7 +358,7 @@ void delete_dynamic_with_callback(DYNAMIC_ARRAY *array, FREE_FUNC f) {
void freeze_size(DYNAMIC_ARRAY *array) void freeze_size(DYNAMIC_ARRAY *array)
{ {
uint elements; size_t elements;
/* /*
Do nothing if we are using a static buffer Do nothing if we are using a static buffer

View File

@ -76,8 +76,8 @@ my_hash_value_type my_hash_sort(CHARSET_INFO *cs, const uchar *key,
@retval 1 failure @retval 1 failure
*/ */
my_bool my_bool
my_hash_init2(PSI_memory_key psi_key, HASH *hash, uint growth_size, my_hash_init2(PSI_memory_key psi_key, HASH *hash, size_t growth_size,
CHARSET_INFO *charset, ulong size, size_t key_offset, CHARSET_INFO *charset, size_t size, size_t key_offset,
size_t key_length, my_hash_get_key get_key, size_t key_length, my_hash_get_key get_key,
my_hash_function hash_function, my_hash_function hash_function,
void (*free_element)(void*), uint flags) void (*free_element)(void*), uint flags)

View File

@ -466,7 +466,7 @@ int my_load_defaults(const char *conf_file, const char **groups, int *argc,
if (*argc) if (*argc)
memcpy(res + args.elements, *argv, *argc * sizeof(char*)); memcpy(res + args.elements, *argv, *argc * sizeof(char*));
(*argc)+= args.elements; (*argc)+= (int)args.elements;
*argv= res; *argv= res;
(*argv)[*argc]= 0; (*argv)[*argc]= 0;
*(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */ *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */
@ -602,7 +602,7 @@ static int search_default_file_with_ext(struct handle_option_ctx *ctx,
MYSQL_FILE *fp; MYSQL_FILE *fp;
uint line=0; uint line=0;
enum { NONE, PARSE, SKIP } found_group= NONE; enum { NONE, PARSE, SKIP } found_group= NONE;
uint i; size_t i;
MY_DIR *search_dir; MY_DIR *search_dir;
FILEINFO *search_file; FILEINFO *search_file;
@ -690,7 +690,7 @@ static int search_default_file_with_ext(struct handle_option_ctx *ctx,
if (!(search_dir= my_dir(ptr, MYF(MY_WME | MY_WANT_SORT)))) if (!(search_dir= my_dir(ptr, MYF(MY_WME | MY_WANT_SORT))))
goto err; goto err;
for (i= 0; i < (uint) search_dir->number_of_files; i++) for (i= 0; i < search_dir->number_of_files; i++)
{ {
search_file= search_dir->dir_entry + i; search_file= search_dir->dir_entry + i;
ext= fn_ext2(search_file->name); ext= fn_ext2(search_file->name);

View File

@ -193,7 +193,7 @@ int my_rmtree(const char *dir, myf MyFlags)
char path[FN_REFLEN]; char path[FN_REFLEN];
char sep[] = { FN_LIBCHAR, 0 }; char sep[] = { FN_LIBCHAR, 0 };
int err = 0; int err = 0;
uint i; size_t i;
MY_DIR *dir_info = my_dir(dir, MYF(MY_DONT_SORT | MY_WANT_STAT)); MY_DIR *dir_info = my_dir(dir, MYF(MY_DONT_SORT | MY_WANT_STAT));
if (!dir_info) if (!dir_info)

View File

@ -598,7 +598,7 @@ static int deadlock_search(struct deadlock_arg *arg, WT_THD *blocker,
{ {
WT_RESOURCE *rc, *volatile *shared_ptr= &blocker->waiting_for; WT_RESOURCE *rc, *volatile *shared_ptr= &blocker->waiting_for;
WT_THD *cursor; WT_THD *cursor;
uint i; size_t i;
int ret= WT_OK; int ret= WT_OK;
DBUG_ENTER("deadlock_search"); DBUG_ENTER("deadlock_search");
DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, depth=%u", DBUG_PRINT("wt", ("enter: thd=%s, blocker=%s, depth=%u",

View File

@ -232,7 +232,7 @@ int extension_based_table_discovery(MY_DIR *dirp, const char *ext_meta,
cur++; cur++;
} }
advance(from, to, cur, skip); advance(from, to, cur, skip);
dirp->number_of_files= (uint)(to - dirp->dir_entry); dirp->number_of_files= to - dirp->dir_entry;
return 0; return 0;
} }

View File

@ -2638,12 +2638,11 @@ static void setup_windows_event_source()
static int find_uniq_filename(char *name, ulong min_log_number_to_use, static int find_uniq_filename(char *name, ulong min_log_number_to_use,
ulong *last_used_log_number) ulong *last_used_log_number)
{ {
uint i;
char buff[FN_REFLEN], ext_buf[FN_REFLEN]; char buff[FN_REFLEN], ext_buf[FN_REFLEN];
struct st_my_dir *dir_info; struct st_my_dir *dir_info;
struct fileinfo *file_info; struct fileinfo *file_info;
ulong max_found= 0, next= 0, number= 0; ulong max_found= 0, next= 0, number= 0;
size_t buf_length, length; size_t i, buf_length, length;
char *start, *end; char *start, *end;
int error= 0; int error= 0;
DBUG_ENTER("find_uniq_filename"); DBUG_ENTER("find_uniq_filename");

View File

@ -1184,7 +1184,7 @@ void Rows_log_event::change_to_flashback_event(PRINT_EVENT_INFO *print_event_inf
} }
/* Copying rows from the end to the begining into event */ /* Copying rows from the end to the begining into event */
for (uint i= rows_arr.elements; i > 0; --i) for (size_t i= rows_arr.elements; i > 0; --i)
{ {
LEX_STRING *one_row= dynamic_element(&rows_arr, i - 1, LEX_STRING*); LEX_STRING *one_row= dynamic_element(&rows_arr, i - 1, LEX_STRING*);

View File

@ -470,7 +470,7 @@ static void cleanup_load_tmpdir(LEX_CSTRING *connection_name)
{ {
MY_DIR *dirp; MY_DIR *dirp;
FILEINFO *file; FILEINFO *file;
uint i; size_t i;
char dir[FN_REFLEN], fname[FN_REFLEN]; char dir[FN_REFLEN], fname[FN_REFLEN];
char prefbuf[31 + MAX_CONNECTION_NAME* MAX_FILENAME_MBWIDTH + 1]; char prefbuf[31 + MAX_CONNECTION_NAME* MAX_FILENAME_MBWIDTH + 1];
DBUG_ENTER("cleanup_load_tmpdir"); DBUG_ENTER("cleanup_load_tmpdir");
@ -491,7 +491,7 @@ static void cleanup_load_tmpdir(LEX_CSTRING *connection_name)
load_data_tmp_prefix(prefbuf, connection_name); load_data_tmp_prefix(prefbuf, connection_name);
DBUG_PRINT("enter", ("dir: '%s' prefix: '%s'", dir, prefbuf)); DBUG_PRINT("enter", ("dir: '%s' prefix: '%s'", dir, prefbuf));
for (i=0 ; i < (uint)dirp->number_of_files; i++) for (i=0 ; i < dirp->number_of_files; i++)
{ {
file=dirp->dir_entry+i; file=dirp->dir_entry+i;
if (is_prefix(file->name, prefbuf)) if (is_prefix(file->name, prefbuf))

View File

@ -12608,10 +12608,10 @@ int QUICK_RANGE_SELECT::reset()
if (!mrr_buf_desc) if (!mrr_buf_desc)
empty_buf.buffer= empty_buf.buffer_end= empty_buf.end_of_used_area= NULL; empty_buf.buffer= empty_buf.buffer_end= empty_buf.end_of_used_area= NULL;
error= file->multi_range_read_init(&seq_funcs, (void*)this, ranges.elements, error= file->multi_range_read_init(&seq_funcs, (void*)this,
mrr_flags, mrr_buf_desc? mrr_buf_desc: (uint)ranges.elements, mrr_flags,
&empty_buf); mrr_buf_desc? mrr_buf_desc: &empty_buf);
err: err:
/* Restore bitmaps set on entry */ /* Restore bitmaps set on entry */
if (in_ror_merged_scan) if (in_ror_merged_scan)
@ -12723,7 +12723,7 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length,
} }
} }
uint count= ranges.elements - (uint)(cur_range - (QUICK_RANGE**) ranges.buffer); size_t count= ranges.elements - (size_t)(cur_range - (QUICK_RANGE**) ranges.buffer);
if (count == 0) if (count == 0)
{ {
/* Ranges have already been used up before. None is left for read. */ /* Ranges have already been used up before. None is left for read. */
@ -12768,7 +12768,7 @@ int QUICK_RANGE_SELECT_GEOM::get_next()
DBUG_RETURN(result); DBUG_RETURN(result);
} }
uint count= ranges.elements - (uint)(cur_range - (QUICK_RANGE**) ranges.buffer); size_t count= ranges.elements - (size_t)(cur_range - (QUICK_RANGE**) ranges.buffer);
if (count == 0) if (count == 0)
{ {
/* Ranges have already been used up before. None is left for read. */ /* Ranges have already been used up before. None is left for read. */
@ -12809,9 +12809,9 @@ int QUICK_RANGE_SELECT_GEOM::get_next()
bool QUICK_RANGE_SELECT::row_in_ranges() bool QUICK_RANGE_SELECT::row_in_ranges()
{ {
QUICK_RANGE *res; QUICK_RANGE *res;
uint min= 0; size_t min= 0;
uint max= ranges.elements - 1; size_t max= ranges.elements - 1;
uint mid= (max + min)/2; size_t mid= (max + min)/2;
while (min != max) while (min != max)
{ {
@ -15797,7 +15797,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range()
DBUG_ASSERT(min_max_ranges.elements > 0); DBUG_ASSERT(min_max_ranges.elements > 0);
for (uint range_idx= min_max_ranges.elements; range_idx > 0; range_idx--) for (size_t range_idx= min_max_ranges.elements; range_idx > 0; range_idx--)
{ /* Search from the right-most range to the left. */ { /* Search from the right-most range to the left. */
get_dynamic(&min_max_ranges, (uchar*)&cur_range, range_idx - 1); get_dynamic(&min_max_ranges, (uchar*)&cur_range, range_idx - 1);
@ -16343,7 +16343,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::dbug_dump(int indent, bool verbose)
} }
if (min_max_ranges.elements > 0) if (min_max_ranges.elements > 0)
{ {
fprintf(DBUG_FILE, "%*susing %d quick_ranges for MIN/MAX:\n", fprintf(DBUG_FILE, "%*susing %zu quick_ranges for MIN/MAX:\n",
indent, "", min_max_ranges.elements); indent, "", min_max_ranges.elements);
} }
} }

View File

@ -704,7 +704,7 @@ double spl_postjoin_oper_cost(THD *thd, double join_record_count, uint rec_len)
void JOIN::add_keyuses_for_splitting() void JOIN::add_keyuses_for_splitting()
{ {
uint i; uint i;
uint idx; size_t idx;
KEYUSE_EXT *keyuse_ext; KEYUSE_EXT *keyuse_ext;
KEYUSE_EXT keyuse_ext_end; KEYUSE_EXT keyuse_ext_end;
double oper_cost; double oper_cost;

View File

@ -747,7 +747,7 @@ int flush_master_info(Master_info* mi,
(1 + mi->ignore_server_ids.elements), MYF(MY_WME)); (1 + mi->ignore_server_ids.elements), MYF(MY_WME));
if (!ignore_server_ids_buf) if (!ignore_server_ids_buf)
DBUG_RETURN(1); /* error */ DBUG_RETURN(1); /* error */
ulong cur_len= sprintf(ignore_server_ids_buf, "%u", ulong cur_len= sprintf(ignore_server_ids_buf, "%zu",
mi->ignore_server_ids.elements); mi->ignore_server_ids.elements);
for (ulong i= 0; i < mi->ignore_server_ids.elements; i++) for (ulong i= 0; i < mi->ignore_server_ids.elements; i++)
{ {
@ -1929,7 +1929,7 @@ char *Domain_id_filter::as_string(enum_list_type type)
return NULL; return NULL;
// Store the total number of elements followed by the individual elements. // Store the total number of elements followed by the individual elements.
size_t cur_len= sprintf(buf, "%u", ids->elements); size_t cur_len= sprintf(buf, "%zu", ids->elements);
sz-= cur_len; sz-= cur_len;
for (uint i= 0; i < ids->elements; i++) for (uint i= 0; i < ids->elements; i++)

View File

@ -85,7 +85,7 @@ 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)
{ {
uint saved_elements= long_options->elements; size_t saved_elements= long_options->elements;
DBUG_ENTER("sys_var_add_options"); DBUG_ENTER("sys_var_add_options");

View File

@ -561,7 +561,7 @@ public:
{ return m_flags & MODIFIES_DATA; } { return m_flags & MODIFIES_DATA; }
inline uint instructions() inline uint instructions()
{ return m_instr.elements; } { return (uint)m_instr.elements; }
inline sp_instr * inline sp_instr *
last_instruction() last_instruction()

View File

@ -3618,14 +3618,14 @@ static void init_check_host(void)
(my_hash_get_key) check_get_key, 0, 0); (my_hash_get_key) check_get_key, 0, 0);
if (!allow_all_hosts) if (!allow_all_hosts)
{ {
for (uint i=0 ; i < acl_users.elements ; i++) for (size_t i=0 ; i < acl_users.elements ; i++)
{ {
ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*); ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
if (strchr(acl_user->host.hostname,wild_many) || if (strchr(acl_user->host.hostname,wild_many) ||
strchr(acl_user->host.hostname,wild_one) || strchr(acl_user->host.hostname,wild_one) ||
acl_user->host.ip_mask) acl_user->host.ip_mask)
{ // Has wildcard { // Has wildcard
uint j; size_t j;
for (j=0 ; j < acl_wild_hosts.elements ; j++) for (j=0 ; j < acl_wild_hosts.elements ; j++)
{ // Check if host already exists { // Check if host already exists
acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,j, acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,j,
@ -3744,7 +3744,7 @@ static bool add_role_user_mapping(const char *uname, const char *hname,
static void remove_ptr_from_dynarray(DYNAMIC_ARRAY *array, void *ptr) static void remove_ptr_from_dynarray(DYNAMIC_ARRAY *array, void *ptr)
{ {
bool found __attribute__((unused))= false; bool found __attribute__((unused))= false;
for (uint i= 0; i < array->elements; i++) for (size_t i= 0; i < array->elements; i++)
{ {
if (ptr == *dynamic_element(array, i, void**)) if (ptr == *dynamic_element(array, i, void**))
{ {
@ -3793,7 +3793,7 @@ static void rebuild_role_grants(void)
/* /*
Reset every user's and role's role_grants array Reset every user's and role's role_grants array
*/ */
for (uint i=0; i < acl_users.elements; i++) { for (size_t i=0; i < acl_users.elements; i++) {
ACL_USER *user= dynamic_element(&acl_users, i, ACL_USER *); ACL_USER *user= dynamic_element(&acl_users, i, ACL_USER *);
reset_dynamic(&user->role_grants); reset_dynamic(&user->role_grants);
} }
@ -3819,7 +3819,7 @@ bool acl_check_host(const char *host, const char *ip)
mysql_mutex_unlock(&acl_cache->lock); mysql_mutex_unlock(&acl_cache->lock);
return 0; // Found host return 0; // Found host
} }
for (uint i=0 ; i < acl_wild_hosts.elements ; i++) for (size_t i=0 ; i < acl_wild_hosts.elements ; i++)
{ {
acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,i,acl_host_and_ip*); acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,i,acl_host_and_ip*);
if (compare_hostname(acl, host, ip)) if (compare_hostname(acl, host, ip))
@ -5022,7 +5022,7 @@ acl_update_proxy_user(ACL_PROXY_USER *new_value, bool is_revoke)
mysql_mutex_assert_owner(&acl_cache->lock); mysql_mutex_assert_owner(&acl_cache->lock);
DBUG_ENTER("acl_update_proxy_user"); DBUG_ENTER("acl_update_proxy_user");
for (uint i= 0; i < acl_proxy_users.elements; i++) for (size_t i= 0; i < acl_proxy_users.elements; i++)
{ {
ACL_PROXY_USER *acl_user= ACL_PROXY_USER *acl_user=
dynamic_element(&acl_proxy_users, i, ACL_PROXY_USER *); dynamic_element(&acl_proxy_users, i, ACL_PROXY_USER *);
@ -6294,7 +6294,7 @@ static int traverse_role_graph_impl(ACL_USER_BASE *user, void *context,
end: end:
/* Cleanup */ /* Cleanup */
for (uint i= 0; i < to_clear.elements(); i++) for (size_t i= 0; i < to_clear.elements(); i++)
{ {
ACL_USER_BASE *current= to_clear.at(i); ACL_USER_BASE *current= to_clear.at(i);
DBUG_ASSERT(current->flags & (ROLE_EXPLORED | ROLE_ON_STACK | ROLE_OPENED)); DBUG_ASSERT(current->flags & (ROLE_EXPLORED | ROLE_ON_STACK | ROLE_OPENED));
@ -6362,7 +6362,7 @@ static bool merge_role_global_privileges(ACL_ROLE *grantee)
DBUG_EXECUTE_IF("role_merge_stats", role_global_merges++;); DBUG_EXECUTE_IF("role_merge_stats", role_global_merges++;);
for (uint i= 0; i < grantee->role_grants.elements; i++) for (size_t i= 0; i < grantee->role_grants.elements; i++)
{ {
ACL_ROLE *r= *dynamic_element(&grantee->role_grants, i, ACL_ROLE**); ACL_ROLE *r= *dynamic_element(&grantee->role_grants, i, ACL_ROLE**);
grantee->access|= r->access; grantee->access|= r->access;
@ -6501,8 +6501,8 @@ static bool merge_role_db_privileges(ACL_ROLE *grantee, const char *dbname,
if (update_flags & 4) if (update_flags & 4)
{ {
// Remove elements marked for deletion. // Remove elements marked for deletion.
uint count= 0; size_t count= 0;
for(uint i= 0; i < acl_dbs.elements(); i++) for(size_t i= 0; i < acl_dbs.elements(); i++)
{ {
ACL_DB *acl_db= &acl_dbs.at(i); ACL_DB *acl_db= &acl_dbs.at(i);
if (acl_db->sort) if (acl_db->sort)
@ -6865,7 +6865,7 @@ static int merge_role_privileges(ACL_ROLE *role __attribute__((unused)),
if (data->what != PRIVS_TO_MERGE::GLOBAL) if (data->what != PRIVS_TO_MERGE::GLOBAL)
{ {
role_hash.insert(grantee); role_hash.insert(grantee);
for (uint i= 0; i < grantee->role_grants.elements; i++) for (size_t i= 0; i < grantee->role_grants.elements; i++)
role_hash.insert(*dynamic_element(&grantee->role_grants, i, ACL_ROLE**)); role_hash.insert(*dynamic_element(&grantee->role_grants, i, ACL_ROLE**));
} }
@ -9440,7 +9440,7 @@ static bool show_role_grants(THD *thd, const char *hostname,
ACL_USER_BASE *acl_entry, ACL_USER_BASE *acl_entry,
char *buff, size_t buffsize) char *buff, size_t buffsize)
{ {
uint counter; size_t counter;
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
LEX_CSTRING host= {const_cast<char*>(hostname), strlen(hostname)}; LEX_CSTRING host= {const_cast<char*>(hostname), strlen(hostname)};
@ -9553,7 +9553,7 @@ static bool show_database_privileges(THD *thd, const char *username,
privilege_t want_access(NO_ACL); privilege_t want_access(NO_ACL);
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
for (uint i=0 ; i < acl_dbs.elements() ; i++) for (size_t i=0 ; i < acl_dbs.elements() ; i++)
{ {
const char *user, *host; const char *user, *host;
@ -10245,14 +10245,14 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
propagate_role_grants(acl_role, PRIVS_TO_MERGE::ALL); propagate_role_grants(acl_role, PRIVS_TO_MERGE::ALL);
// delete the role from cross-reference arrays // delete the role from cross-reference arrays
for (uint i=0; i < acl_role->role_grants.elements; i++) for (size_t i=0; i < acl_role->role_grants.elements; i++)
{ {
ACL_ROLE *grant= *dynamic_element(&acl_role->role_grants, ACL_ROLE *grant= *dynamic_element(&acl_role->role_grants,
i, ACL_ROLE**); i, ACL_ROLE**);
remove_ptr_from_dynarray(&grant->parent_grantee, acl_role); remove_ptr_from_dynarray(&grant->parent_grantee, acl_role);
} }
for (uint i=0; i < acl_role->parent_grantee.elements; i++) for (size_t i=0; i < acl_role->parent_grantee.elements; i++)
{ {
ACL_USER_BASE *grantee= *dynamic_element(&acl_role->parent_grantee, ACL_USER_BASE *grantee= *dynamic_element(&acl_role->parent_grantee,
i, ACL_USER_BASE**); i, ACL_USER_BASE**);
@ -10273,7 +10273,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
/* Get the number of elements in the in-memory structure. */ /* Get the number of elements in the in-memory structure. */
switch (struct_no) { switch (struct_no) {
case USER_ACL: case USER_ACL:
elements= acl_users.elements; elements= int(acl_users.elements);
break; break;
case DB_ACL: case DB_ACL:
elements= int(acl_dbs.elements()); elements= int(acl_dbs.elements());
@ -10299,7 +10299,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
elements= grant_name_hash->records; elements= grant_name_hash->records;
break; break;
case PROXY_USERS_ACL: case PROXY_USERS_ACL:
elements= acl_proxy_users.elements; elements= int(acl_proxy_users.elements);
break; break;
case ROLES_MAPPINGS_HASH: case ROLES_MAPPINGS_HASH:
roles_mappings_hash= &acl_roles_mappings; roles_mappings_hash= &acl_roles_mappings;

View File

@ -114,19 +114,19 @@ 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, size_t prealloc=16, size_t increment=16)
{ {
init(psi_key, prealloc, increment); init(psi_key, prealloc, increment);
} }
Dynamic_array(MEM_ROOT *root, uint prealloc=16, uint increment=16) Dynamic_array(MEM_ROOT *root, size_t prealloc=16, size_t increment=16)
{ {
void *init_buffer= alloc_root(root, sizeof(Elem) * prealloc); void *init_buffer= alloc_root(root, sizeof(Elem) * prealloc);
init_dynamic_array2(root->psi_key, &array, sizeof(Elem), init_buffer, init_dynamic_array2(root->psi_key, &array, sizeof(Elem), init_buffer,
prealloc, increment, MYF(0)); prealloc, increment, MYF(0));
} }
void init(PSI_memory_key psi_key, uint prealloc=16, uint increment=16) void init(PSI_memory_key psi_key, size_t prealloc=16, size_t increment=16)
{ {
init_dynamic_array2(psi_key, &array, sizeof(Elem), 0, prealloc, increment, MYF(0)); init_dynamic_array2(psi_key, &array, sizeof(Elem), 0, prealloc, increment, MYF(0));
} }
@ -217,7 +217,7 @@ public:
void del(size_t idx) void del(size_t idx)
{ {
DBUG_ASSERT(idx <= array.max_element); DBUG_ASSERT(idx <= array.max_element);
delete_dynamic_element(&array, (uint)idx); delete_dynamic_element(&array, idx);
} }
size_t elements() const size_t elements() const
@ -228,7 +228,7 @@ public:
void elements(size_t num_elements) void elements(size_t num_elements)
{ {
DBUG_ASSERT(num_elements <= array.max_element); DBUG_ASSERT(num_elements <= array.max_element);
array.elements= (uint)num_elements; array.elements= num_elements;
} }
void clear() void clear()
@ -236,7 +236,7 @@ public:
elements(0); elements(0);
} }
void set(uint idx, const Elem &el) void set(size_t idx, const Elem &el)
{ {
set_dynamic(&array, &el, idx); set_dynamic(&array, &el, idx);
} }
@ -248,7 +248,7 @@ public:
bool reserve(size_t new_size) bool reserve(size_t new_size)
{ {
return allocate_dynamic(&array, (uint)new_size); return allocate_dynamic(&array, new_size);
} }
@ -260,7 +260,7 @@ public:
if (new_size > old_size) if (new_size > old_size)
{ {
set_dynamic(&array, (uchar*)&default_val, (uint)(new_size - 1)); set_dynamic(&array, (uchar*)&default_val, new_size - 1);
/*for (size_t i= old_size; i != new_size; i++) /*for (size_t i= old_size; i != new_size; i++)
{ {
at(i)= default_val; at(i)= default_val;

View File

@ -8934,7 +8934,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, Field **ptr,
my_bool mysql_rm_tmp_tables(void) my_bool mysql_rm_tmp_tables(void)
{ {
uint i, idx; size_t i, idx;
char path[FN_REFLEN], *tmpdir, path_copy[FN_REFLEN]; char path[FN_REFLEN], *tmpdir, path_copy[FN_REFLEN];
MY_DIR *dirp; MY_DIR *dirp;
FILEINFO *file; FILEINFO *file;
@ -8956,7 +8956,7 @@ my_bool mysql_rm_tmp_tables(void)
/* Remove all SQLxxx tables from directory */ /* Remove all SQLxxx tables from directory */
for (idx=0 ; idx < (uint) dirp->number_of_files ; idx++) for (idx=0 ; idx < dirp->number_of_files ; idx++)
{ {
file=dirp->dir_entry+idx; file=dirp->dir_entry+idx;

View File

@ -1363,9 +1363,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
*tables= tot_list; *tables= tot_list;
/* and at last delete all non-table files */ /* and at last delete all non-table files */
for (uint idx=0 ; for (size_t idx=0; idx < dirp->number_of_files && !thd->killed; idx++)
idx < (uint) dirp->number_of_files && !thd->killed ;
idx++)
{ {
FILEINFO *file=dirp->dir_entry+idx; FILEINFO *file=dirp->dir_entry+idx;
char *extension; char *extension;
@ -1488,9 +1486,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path)
DBUG_ENTER("mysql_rm_arc_files"); DBUG_ENTER("mysql_rm_arc_files");
DBUG_PRINT("enter", ("path: %s", org_path)); DBUG_PRINT("enter", ("path: %s", org_path));
for (uint idx=0 ; for (size_t idx=0; idx < dirp->number_of_files && !thd->killed; idx++)
idx < (uint) dirp->number_of_files && !thd->killed ;
idx++)
{ {
FILEINFO *file=dirp->dir_entry+idx; FILEINFO *file=dirp->dir_entry+idx;
char *extension, *revision; char *extension, *revision;
@ -1970,8 +1966,8 @@ bool mysql_upgrade_db(THD *thd, const LEX_CSTRING *old_db)
/* Step2: Move tables to the new database */ /* Step2: Move tables to the new database */
if ((dirp = my_dir(path,MYF(MY_DONT_SORT)))) if ((dirp = my_dir(path,MYF(MY_DONT_SORT))))
{ {
uint nfiles= (uint) dirp->number_of_files; size_t nfiles= dirp->number_of_files;
for (uint idx=0 ; idx < nfiles && !thd->killed ; idx++) for (size_t idx=0 ; idx < nfiles && !thd->killed ; idx++)
{ {
FILEINFO *file= dirp->dir_entry + idx; FILEINFO *file= dirp->dir_entry + idx;
char *extension, tname[FN_REFLEN + 1]; char *extension, tname[FN_REFLEN + 1];
@ -2060,8 +2056,8 @@ bool mysql_upgrade_db(THD *thd, const LEX_CSTRING *old_db)
if ((dirp = my_dir(path,MYF(MY_DONT_SORT)))) if ((dirp = my_dir(path,MYF(MY_DONT_SORT))))
{ {
uint nfiles= (uint) dirp->number_of_files; size_t nfiles= dirp->number_of_files;
for (uint idx=0 ; idx < nfiles ; idx++) for (size_t idx=0 ; idx < nfiles ; idx++)
{ {
FILEINFO *file= dirp->dir_entry + idx; FILEINFO *file= dirp->dir_entry + idx;
char oldname[FN_REFLEN + 1], newname[FN_REFLEN + 1]; char oldname[FN_REFLEN + 1], newname[FN_REFLEN + 1];

View File

@ -1342,7 +1342,7 @@ void lex_unlock_plugins(LEX *lex)
/* release used plugins */ /* release used plugins */
if (lex->plugins.elements) /* No function call and no mutex if no plugins. */ if (lex->plugins.elements) /* No function call and no mutex if no plugins. */
{ {
plugin_unlock_list(0, (plugin_ref*)lex->plugins.buffer, plugin_unlock_list(0, (plugin_ref*)lex->plugins.buffer,
lex->plugins.elements); lex->plugins.elements);
} }
reset_dynamic(&lex->plugins); reset_dynamic(&lex->plugins);

View File

@ -456,7 +456,7 @@ static int item_val_real(struct st_mysql_value *value, double *buf)
static struct st_plugin_dl *plugin_dl_find(const LEX_CSTRING *dl) static struct st_plugin_dl *plugin_dl_find(const LEX_CSTRING *dl)
{ {
uint i; size_t i;
struct st_plugin_dl *tmp; struct st_plugin_dl *tmp;
DBUG_ENTER("plugin_dl_find"); DBUG_ENTER("plugin_dl_find");
for (i= 0; i < plugin_dl_array.elements; i++) for (i= 0; i < plugin_dl_array.elements; i++)
@ -473,7 +473,7 @@ static struct st_plugin_dl *plugin_dl_find(const LEX_CSTRING *dl)
static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl) static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl)
{ {
uint i; size_t i;
struct st_plugin_dl *tmp; struct st_plugin_dl *tmp;
DBUG_ENTER("plugin_dl_insert_or_reuse"); DBUG_ENTER("plugin_dl_insert_or_reuse");
for (i= 0; i < plugin_dl_array.elements; i++) for (i= 0; i < plugin_dl_array.elements; i++)
@ -1080,7 +1080,7 @@ plugin_ref plugin_lock_by_name(THD *thd, const LEX_CSTRING *name, int type)
static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin) static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)
{ {
uint i; size_t i;
struct st_plugin_int *tmp; struct st_plugin_int *tmp;
DBUG_ENTER("plugin_insert_or_reuse"); DBUG_ENTER("plugin_insert_or_reuse");
for (i= 0; i < plugin_array.elements; i++) for (i= 0; i < plugin_array.elements; i++)
@ -1309,7 +1309,7 @@ static void plugin_del(struct st_plugin_int *plugin)
static void reap_plugins(void) static void reap_plugins(void)
{ {
uint count; size_t count;
struct st_plugin_int *plugin, **reap, **list; struct st_plugin_int *plugin, **reap, **list;
mysql_mutex_assert_owner(&LOCK_plugin); mysql_mutex_assert_owner(&LOCK_plugin);
@ -1353,7 +1353,7 @@ static void reap_plugins(void)
static void intern_plugin_unlock(LEX *lex, plugin_ref plugin) static void intern_plugin_unlock(LEX *lex, plugin_ref plugin)
{ {
int i; ssize_t i;
st_plugin_int *pi; st_plugin_int *pi;
DBUG_ENTER("intern_plugin_unlock"); DBUG_ENTER("intern_plugin_unlock");
@ -1419,7 +1419,7 @@ void plugin_unlock(THD *thd, plugin_ref plugin)
} }
void plugin_unlock_list(THD *thd, plugin_ref *list, uint count) void plugin_unlock_list(THD *thd, plugin_ref *list, size_t count)
{ {
LEX *lex= thd ? thd->lex : 0; LEX *lex= thd ? thd->lex : 0;
DBUG_ENTER("plugin_unlock_list"); DBUG_ENTER("plugin_unlock_list");
@ -1592,7 +1592,7 @@ static void init_plugin_psi_keys(void) {}
*/ */
int plugin_init(int *argc, char **argv, int flags) int plugin_init(int *argc, char **argv, int flags)
{ {
uint i; size_t i;
struct st_maria_plugin **builtins; struct st_maria_plugin **builtins;
struct st_maria_plugin *plugin; struct st_maria_plugin *plugin;
struct st_plugin_int tmp, *plugin_ptr, **reap; struct st_plugin_int tmp, *plugin_ptr, **reap;
@ -2023,7 +2023,7 @@ error:
void plugin_shutdown(void) void plugin_shutdown(void)
{ {
uint i, count= plugin_array.elements; size_t i, count= plugin_array.elements;
struct st_plugin_int **plugins, *plugin; struct st_plugin_int **plugins, *plugin;
struct st_plugin_dl **dl; struct st_plugin_dl **dl;
DBUG_ENTER("plugin_shutdown"); DBUG_ENTER("plugin_shutdown");
@ -2467,7 +2467,7 @@ wsrep_error_label:
bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
int type, uint state_mask, void *arg) int type, uint state_mask, void *arg)
{ {
uint idx, total= 0; size_t idx, total= 0;
struct st_plugin_int *plugin; struct st_plugin_int *plugin;
plugin_ref *plugins; plugin_ref *plugins;
my_bool res= FALSE; my_bool res= FALSE;
@ -3318,7 +3318,7 @@ static void cleanup_variables(struct system_variables *vars)
void plugin_thdvar_cleanup(THD *thd) void plugin_thdvar_cleanup(THD *thd)
{ {
uint idx; size_t idx;
plugin_ref *list; plugin_ref *list;
DBUG_ENTER("plugin_thdvar_cleanup"); DBUG_ENTER("plugin_thdvar_cleanup");
@ -4302,7 +4302,7 @@ void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root)
if (!initialized) if (!initialized)
return; return;
for (uint idx= 0; idx < plugin_array.elements; idx++) for (size_t idx= 0; idx < plugin_array.elements; idx++)
{ {
p= *dynamic_element(&plugin_array, idx, struct st_plugin_int **); p= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);

View File

@ -172,7 +172,7 @@ extern plugin_ref plugin_lock(THD *thd, plugin_ref ptr);
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_CSTRING *name, extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_CSTRING *name,
int type); int type);
extern void plugin_unlock(THD *thd, plugin_ref plugin); extern void plugin_unlock(THD *thd, plugin_ref plugin);
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint count); extern void plugin_unlock_list(THD *thd, plugin_ref *list, size_t count);
extern bool mysql_install_plugin(THD *thd, const LEX_CSTRING *name, extern bool mysql_install_plugin(THD *thd, const LEX_CSTRING *name,
const LEX_CSTRING *dl); const LEX_CSTRING *dl);
extern bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name, extern bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name,

View File

@ -12453,9 +12453,9 @@ static
bool generate_derived_keys(DYNAMIC_ARRAY *keyuse_array) bool generate_derived_keys(DYNAMIC_ARRAY *keyuse_array)
{ {
KEYUSE *keyuse= dynamic_element(keyuse_array, 0, KEYUSE*); KEYUSE *keyuse= dynamic_element(keyuse_array, 0, KEYUSE*);
uint elements= keyuse_array->elements; size_t elements= keyuse_array->elements;
TABLE *prev_table= 0; TABLE *prev_table= 0;
for (uint i= 0; i < elements; i++, keyuse++) for (size_t i= 0; i < elements; i++, keyuse++)
{ {
if (!keyuse->table) if (!keyuse->table)
break; break;
@ -28529,7 +28529,7 @@ JOIN::reoptimize(Item *added_where, table_map join_tables,
{ {
DYNAMIC_ARRAY added_keyuse; DYNAMIC_ARRAY added_keyuse;
SARGABLE_PARAM *sargables= 0; /* Used only as a dummy parameter. */ SARGABLE_PARAM *sargables= 0; /* Used only as a dummy parameter. */
uint org_keyuse_elements; size_t org_keyuse_elements;
/* Re-run the REF optimizer to take into account the new conditions. */ /* Re-run the REF optimizer to take into account the new conditions. */
if (update_ref_and_keys(thd, &added_keyuse, join_tab, table_count, added_where, if (update_ref_and_keys(thd, &added_keyuse, join_tab, table_count, added_where,

View File

@ -354,7 +354,7 @@ int fill_all_plugins(THD *thd, TABLE_LIST *tables, COND *cond)
plugin_dl_foreach(thd, 0, show_plugins, table); plugin_dl_foreach(thd, 0, show_plugins, table);
const char *wstr= lookup.db_value.str, *wend= wstr + lookup.db_value.length; const char *wstr= lookup.db_value.str, *wend= wstr + lookup.db_value.length;
for (uint i=0; i < (uint) dirp->number_of_files; i++) for (size_t i=0; i < dirp->number_of_files; i++)
{ {
FILEINFO *file= dirp->dir_entry+i; FILEINFO *file= dirp->dir_entry+i;
LEX_CSTRING dl= { file->name, strlen(file->name) }; LEX_CSTRING dl= { file->name, strlen(file->name) };
@ -952,7 +952,7 @@ find_files(THD *thd, Dynamic_array<LEX_CSTRING*> *files, LEX_CSTRING *db,
if (!db) /* Return databases */ if (!db) /* Return databases */
{ {
for (uint i=0; i < (uint) dirp->number_of_files; i++) for (size_t i=0; i < dirp->number_of_files; i++)
{ {
FILEINFO *file= dirp->dir_entry+i; FILEINFO *file= dirp->dir_entry+i;
#ifdef USE_SYMDIR #ifdef USE_SYMDIR

View File

@ -264,7 +264,7 @@ static void print_keyuse(KEYUSE *keyuse)
void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array) void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array)
{ {
DBUG_LOCK_FILE; DBUG_LOCK_FILE;
fprintf(DBUG_FILE, "KEYUSE array (%d elements)\n", keyuse_array->elements); fprintf(DBUG_FILE, "KEYUSE array (%zu elements)\n", keyuse_array->elements);
for(uint i=0; i < keyuse_array->elements; i++) for(uint i=0; i < keyuse_array->elements; i++)
print_keyuse((KEYUSE*)dynamic_array_ptr(keyuse_array, i)); print_keyuse((KEYUSE*)dynamic_array_ptr(keyuse_array, i));
DBUG_UNLOCK_FILE; DBUG_UNLOCK_FILE;

View File

@ -2524,7 +2524,7 @@ scan_tz_dir(char * name_end, uint symlink_recursion_level, uint verbose)
{ {
MY_DIR *cur_dir; MY_DIR *cur_dir;
char *name_end_tmp; char *name_end_tmp;
uint i; size_t i;
/* Sort directory data, to pass mtr tests on different platforms. */ /* Sort directory data, to pass mtr tests on different platforms. */
if (!(cur_dir= my_dir(fullname, MYF(MY_WANT_STAT|MY_WANT_SORT)))) if (!(cur_dir= my_dir(fullname, MYF(MY_WANT_STAT|MY_WANT_SORT))))

View File

@ -709,7 +709,7 @@ bool Unique::merge(TABLE *table, uchar *buff, size_t buff_size,
{ {
IO_CACHE *outfile= &sort.io_cache; IO_CACHE *outfile= &sort.io_cache;
Merge_chunk *file_ptr= (Merge_chunk*) file_ptrs.buffer; Merge_chunk *file_ptr= (Merge_chunk*) file_ptrs.buffer;
uint maxbuffer= file_ptrs.elements - 1; uint maxbuffer= (uint)file_ptrs.elements - 1;
my_off_t save_pos; my_off_t save_pos;
bool error= 1; bool error= 1;
Sort_param sort_param; Sort_param sort_param;

View File

@ -211,7 +211,7 @@ ulong federatedx_io_mysql::last_savepoint() const
ulong federatedx_io_mysql::actual_savepoint() const ulong federatedx_io_mysql::actual_savepoint() const
{ {
SAVEPT *savept= NULL; SAVEPT *savept= NULL;
uint index= savepoints.elements; size_t index= savepoints.elements;
DBUG_ENTER("federatedx_io_mysql::last_savepoint"); DBUG_ENTER("federatedx_io_mysql::last_savepoint");
while (index) while (index)
@ -285,7 +285,7 @@ ulong federatedx_io_mysql::savepoint_release(ulong sp)
ulong federatedx_io_mysql::savepoint_rollback(ulong sp) ulong federatedx_io_mysql::savepoint_rollback(ulong sp)
{ {
SAVEPT *savept; SAVEPT *savept;
uint index; size_t index;
DBUG_ENTER("federatedx_io_mysql::savepoint_release"); DBUG_ENTER("federatedx_io_mysql::savepoint_release");
DBUG_PRINT("info",("savepoint=%lu", sp)); DBUG_PRINT("info",("savepoint=%lu", sp));
@ -320,7 +320,7 @@ ulong federatedx_io_mysql::savepoint_rollback(ulong sp)
void federatedx_io_mysql::savepoint_restrict(ulong sp) void federatedx_io_mysql::savepoint_restrict(ulong sp)
{ {
SAVEPT *savept; SAVEPT *savept;
uint index= savepoints.elements; size_t index= savepoints.elements;
DBUG_ENTER("federatedx_io_mysql::savepoint_restrict"); DBUG_ENTER("federatedx_io_mysql::savepoint_restrict");
while (index) while (index)
@ -360,7 +360,7 @@ bool federatedx_io_mysql::test_all_restrict() const
{ {
bool result= FALSE; bool result= FALSE;
SAVEPT *savept; SAVEPT *savept;
uint index= savepoints.elements; size_t index= savepoints.elements;
DBUG_ENTER("federatedx_io_mysql::test_all_restrict"); DBUG_ENTER("federatedx_io_mysql::test_all_restrict");
while (index) while (index)

View File

@ -661,7 +661,7 @@ static void _ma_bitmap_unpin_all(MARIA_SHARE *share)
dynamic_array_ptr(&bitmap->pinned_pages, 0)); dynamic_array_ptr(&bitmap->pinned_pages, 0));
MARIA_PINNED_PAGE *pinned_page= page_link + bitmap->pinned_pages.elements; MARIA_PINNED_PAGE *pinned_page= page_link + bitmap->pinned_pages.elements;
DBUG_ENTER("_ma_bitmap_unpin_all"); DBUG_ENTER("_ma_bitmap_unpin_all");
DBUG_PRINT("info", ("pinned: %u", bitmap->pinned_pages.elements)); DBUG_PRINT("info", ("pinned: %zu", bitmap->pinned_pages.elements));
while (pinned_page-- != page_link) while (pinned_page-- != page_link)
pagecache_unlock_by_link(share->pagecache, pinned_page->link, pagecache_unlock_by_link(share->pagecache, pinned_page->link,
pinned_page->unlock, PAGECACHE_UNPIN, pinned_page->unlock, PAGECACHE_UNPIN,
@ -1731,7 +1731,7 @@ static my_bool find_head(MARIA_HA *info, uint length, uint position)
1 error 1 error
*/ */
static my_bool find_tail(MARIA_HA *info, uint length, uint position) static my_bool find_tail(MARIA_HA *info, uint length, size_t position)
{ {
MARIA_FILE_BITMAP *bitmap= &info->s->bitmap; MARIA_FILE_BITMAP *bitmap= &info->s->bitmap;
MARIA_BITMAP_BLOCK *block; MARIA_BITMAP_BLOCK *block;
@ -1812,7 +1812,7 @@ static my_bool find_blob(MARIA_HA *info, ulong length)
uint full_page_size= FULL_PAGE_SIZE(info->s); uint full_page_size= FULL_PAGE_SIZE(info->s);
ulong pages; ulong pages;
uint rest_length, used; uint rest_length, used;
uint UNINIT_VAR(first_block_pos); size_t UNINIT_VAR(first_block_pos);
MARIA_BITMAP_BLOCK *first_block= 0; MARIA_BITMAP_BLOCK *first_block= 0;
DBUG_ENTER("find_blob"); DBUG_ENTER("find_blob");
DBUG_PRINT("enter", ("length: %lu", length)); DBUG_PRINT("enter", ("length: %lu", length));
@ -1862,7 +1862,8 @@ static my_bool find_blob(MARIA_HA *info, ulong length)
DBUG_RETURN(1); DBUG_RETURN(1);
first_block= dynamic_element(&info->bitmap_blocks, first_block_pos, first_block= dynamic_element(&info->bitmap_blocks, first_block_pos,
MARIA_BITMAP_BLOCK*); MARIA_BITMAP_BLOCK*);
first_block->sub_blocks= info->bitmap_blocks.elements - first_block_pos; first_block->sub_blocks= (uint)(info->bitmap_blocks.elements
- first_block_pos);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -1883,7 +1884,7 @@ static my_bool find_blob(MARIA_HA *info, ulong length)
static my_bool allocate_blobs(MARIA_HA *info, MARIA_ROW *row) static my_bool allocate_blobs(MARIA_HA *info, MARIA_ROW *row)
{ {
ulong *length, *end; ulong *length, *end;
uint elements; size_t elements;
/* /*
Reserve size for: Reserve size for:
head block head block
@ -1897,7 +1898,7 @@ static my_bool allocate_blobs(MARIA_HA *info, MARIA_ROW *row)
if (*length && find_blob(info, *length)) if (*length && find_blob(info, *length))
return 1; return 1;
} }
row->extents_count= (info->bitmap_blocks.elements - elements); row->extents_count= (uint)(info->bitmap_blocks.elements - elements);
return 0; return 0;
} }
@ -2170,7 +2171,7 @@ end:
MARIA_BITMAP_BLOCK*); MARIA_BITMAP_BLOCK*);
blocks->block->sub_blocks= ELEMENTS_RESERVED_FOR_MAIN_PART - position; blocks->block->sub_blocks= ELEMENTS_RESERVED_FOR_MAIN_PART - position;
/* First block's page_count is for all blocks */ /* First block's page_count is for all blocks */
blocks->count= info->bitmap_blocks.elements - position; blocks->count= (uint)(info->bitmap_blocks.elements - position);
res= 0; res= 0;
abort: abort:
@ -2271,7 +2272,7 @@ end:
MARIA_BITMAP_BLOCK*); MARIA_BITMAP_BLOCK*);
blocks->block->sub_blocks= ELEMENTS_RESERVED_FOR_MAIN_PART - position; blocks->block->sub_blocks= ELEMENTS_RESERVED_FOR_MAIN_PART - position;
/* First block's page_count is for all blocks */ /* First block's page_count is for all blocks */
blocks->count= info->bitmap_blocks.elements - position; blocks->count= (uint)(info->bitmap_blocks.elements - position);
res= 0; res= 0;
abort: abort:

View File

@ -320,7 +320,7 @@ my_bool _ma_ft_convert_to_ft2(MARIA_HA *info, MARIA_KEY *key)
/* we'll generate one pageful at once, and insert the rest one-by-one */ /* we'll generate one pageful at once, and insert the rest one-by-one */
/* calculating the length of this page ...*/ /* calculating the length of this page ...*/
length=(keyinfo->block_length-2) / keyinfo->keylength; length=(keyinfo->block_length-2) / keyinfo->keylength;
set_if_smaller(length, da->elements); set_if_smaller(length, (uint)da->elements);
length=length * keyinfo->keylength; length=length * keyinfo->keylength;
get_key_full_length_rdonly(key_length, key->data); get_key_full_length_rdonly(key_length, key->data);

View File

@ -140,7 +140,7 @@ my_bool maria_upgrade()
We start by renaming all log files, so that if we get a crash We start by renaming all log files, so that if we get a crash
we will continue from where we left. we will continue from where we left.
*/ */
uint i; size_t i;
MY_DIR *dir= my_dir(maria_data_root, MYF(MY_WME)); MY_DIR *dir= my_dir(maria_data_root, MYF(MY_WME));
if (!dir) if (!dir)
DBUG_RETURN(1); DBUG_RETURN(1);

View File

@ -1342,7 +1342,7 @@ struct st_file_counter
static void translog_mark_file_unfinished(uint32 file) static void translog_mark_file_unfinished(uint32 file)
{ {
int place, i; ssize_t place, i;
struct st_file_counter fc, *fc_ptr; struct st_file_counter fc, *fc_ptr;
DBUG_ENTER("translog_mark_file_unfinished"); DBUG_ENTER("translog_mark_file_unfinished");
@ -1375,7 +1375,7 @@ static void translog_mark_file_unfinished(uint32 file)
goto end; goto end;
} }
if (place == (int)log_descriptor.unfinished_files.elements) if (place == (ssize_t)log_descriptor.unfinished_files.elements)
{ {
insert_dynamic(&log_descriptor.unfinished_files, (uchar*) &fc); insert_dynamic(&log_descriptor.unfinished_files, (uchar*) &fc);
DBUG_PRINT("info", ("The last element inserted")); DBUG_PRINT("info", ("The last element inserted"));
@ -3503,7 +3503,7 @@ my_bool translog_walk_filenames(const char *directory,
const char *)) const char *))
{ {
MY_DIR *dirp; MY_DIR *dirp;
uint i; size_t i;
my_bool rc= FALSE; my_bool rc= FALSE;
/* Finds and removes transaction log files */ /* Finds and removes transaction log files */
@ -5626,8 +5626,8 @@ translog_write_variable_record_mgroup(LSN *lsn,
TRANSLOG_ADDRESS horizon; TRANSLOG_ADDRESS horizon;
struct st_buffer_cursor cursor; struct st_buffer_cursor cursor;
int rc= 0; int rc= 0;
uint i, chunk2_page, full_pages; size_t i, curr_group= 0;
uint curr_group= 0; uint chunk2_page, full_pages;
translog_size_t record_rest, first_page, chunk3_pages, chunk0_pages= 1; translog_size_t record_rest, first_page, chunk3_pages, chunk0_pages= 1;
translog_size_t done= 0; translog_size_t done= 0;
struct st_translog_group_descriptor group; struct st_translog_group_descriptor group;
@ -5894,7 +5894,7 @@ translog_write_variable_record_mgroup(LSN *lsn,
DBUG_ASSERT(cursor.buffs.unlck_ptr == cursor.buffs.wrt_ptr); DBUG_ASSERT(cursor.buffs.unlck_ptr == cursor.buffs.wrt_ptr);
rc= translog_advance_pointer(pages_to_skip + (int)(chunk0_pages - 1), rc= translog_advance_pointer(pages_to_skip + (int)(chunk0_pages - 1),
record_rest + header_fixed_part + record_rest + header_fixed_part +
(groups.elements - ((uint)groups.elements -
((page_capacity - ((page_capacity -
header_fixed_part) / (7 + 1)) * header_fixed_part) / (7 + 1)) *
(chunk0_pages - 1)) * (7 + 1), (chunk0_pages - 1)) * (7 + 1),
@ -5985,7 +5985,7 @@ translog_write_variable_record_mgroup(LSN *lsn,
header_length); header_length);
do do
{ {
int limit; size_t limit;
if (new_page_before_chunk0 && if (new_page_before_chunk0 &&
translog_chaser_page_next(&horizon, &cursor)) translog_chaser_page_next(&horizon, &cursor))
{ {
@ -6027,9 +6027,8 @@ translog_write_variable_record_mgroup(LSN *lsn,
*/ */
limit= (groups_per_page < groups.elements - curr_group ? limit= (groups_per_page < groups.elements - curr_group ?
groups_per_page : groups.elements - curr_group); groups_per_page : groups.elements - curr_group);
DBUG_PRINT("info", ("Groups: %u curr: %u limit: %u", DBUG_PRINT("info", ("Groups: %zu curr: %zu limit: %zu",
(uint) groups.elements, (uint) curr_group, groups.elements, curr_group, limit));
(uint) limit));
if (chunk0_pages == 1) if (chunk0_pages == 1)
{ {

View File

@ -119,7 +119,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info,
PAGECACHE_LOCK_READ_UNLOCK); PAGECACHE_LOCK_READ_UNLOCK);
page_link.changed= 0; page_link.changed= 0;
push_dynamic(&info->pinned_pages, (void*) &page_link); push_dynamic(&info->pinned_pages, (void*) &page_link);
page->link_offset= info->pinned_pages.elements-1; page->link_offset= (uint)info->pinned_pages.elements-1;
} }
if (tmp == info->buff) if (tmp == info->buff)

View File

@ -50,7 +50,7 @@ extern void print_error(const char *fmt,...);
static ha_rows find_all_keys(MARIA_SORT_PARAM *info, ha_keys keys, static ha_rows find_all_keys(MARIA_SORT_PARAM *info, ha_keys keys,
uchar **sort_keys, uchar **sort_keys,
DYNAMIC_ARRAY *buffpek,uint *maxbuffer, DYNAMIC_ARRAY *buffpek,size_t *maxbuffer,
IO_CACHE *tempfile, IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions); IO_CACHE *tempfile_for_exceptions);
static int write_keys(MARIA_SORT_PARAM *info,uchar **sort_keys, static int write_keys(MARIA_SORT_PARAM *info,uchar **sort_keys,
@ -61,7 +61,7 @@ static int write_index(MARIA_SORT_PARAM *info, uchar **sort_keys,
ha_keys count); ha_keys count);
static int merge_many_buff(MARIA_SORT_PARAM *info, ha_keys keys, static int merge_many_buff(MARIA_SORT_PARAM *info, ha_keys keys,
uchar **sort_keys, uchar **sort_keys,
BUFFPEK *buffpek, uint *maxbuffer, BUFFPEK *buffpek, size_t *maxbuffer,
IO_CACHE *t_file); IO_CACHE *t_file);
static my_off_t read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek, static my_off_t read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
uint sort_length); uint sort_length);
@ -69,7 +69,7 @@ static int merge_buffers(MARIA_SORT_PARAM *info, ha_keys keys,
IO_CACHE *from_file, IO_CACHE *to_file, IO_CACHE *from_file, IO_CACHE *to_file,
uchar **sort_keys, BUFFPEK *lastbuff, uchar **sort_keys, BUFFPEK *lastbuff,
BUFFPEK *Fb, BUFFPEK *Tb); BUFFPEK *Fb, BUFFPEK *Tb);
static int merge_index(MARIA_SORT_PARAM *,ha_keys,uchar **,BUFFPEK *, uint, static int merge_index(MARIA_SORT_PARAM *,ha_keys,uchar **,BUFFPEK *, size_t,
IO_CACHE *); IO_CACHE *);
static int flush_maria_ft_buf(MARIA_SORT_PARAM *info); static int flush_maria_ft_buf(MARIA_SORT_PARAM *info);
@ -126,8 +126,8 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
size_t sortbuff_size) size_t sortbuff_size)
{ {
int error; int error;
uint sort_length, maxbuffer; uint sort_length;
size_t memavl, old_memavl; size_t memavl, old_memavl, maxbuffer;
DYNAMIC_ARRAY buffpek; DYNAMIC_ARRAY buffpek;
ha_rows records, UNINIT_VAR(keys); ha_rows records, UNINIT_VAR(keys);
uchar **sort_keys; uchar **sort_keys;
@ -165,7 +165,7 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
will be allocated when needed. will be allocated when needed.
*/ */
keys= memavl / (sort_length+sizeof(char*)); keys= memavl / (sort_length+sizeof(char*));
maxbuffer= (uint) MY_MIN((ulonglong) 1000, (records / keys)+1); maxbuffer= (size_t) MY_MIN((ulonglong) 1000, (records / keys)+1);
} }
else else
{ {
@ -173,7 +173,7 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
All keys can't fit in memory. All keys can't fit in memory.
Calculate how many keys + buffers we can keep in memory Calculate how many keys + buffers we can keep in memory
*/ */
uint maxbuffer_org; size_t maxbuffer_org;
do do
{ {
maxbuffer_org= maxbuffer; maxbuffer_org= maxbuffer;
@ -190,7 +190,7 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
goto err; goto err;
} }
} }
while ((maxbuffer= (uint) (records/(keys-1)+1)) != maxbuffer_org); while ((maxbuffer= (size_t) (records/(keys-1)+1)) != maxbuffer_org);
} }
if ((sort_keys= ((uchar**) if ((sort_keys= ((uchar**)
@ -310,7 +310,7 @@ err:
static ha_rows find_all_keys(MARIA_SORT_PARAM *info, ha_rows keys, static ha_rows find_all_keys(MARIA_SORT_PARAM *info, ha_rows keys,
uchar **sort_keys, DYNAMIC_ARRAY *buffpek, uchar **sort_keys, DYNAMIC_ARRAY *buffpek,
uint *maxbuffer, IO_CACHE *tempfile, size_t *maxbuffer, IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions) IO_CACHE *tempfile_for_exceptions)
{ {
int error; int error;
@ -371,7 +371,7 @@ static my_bool _ma_thr_find_all_keys_exec(MARIA_SORT_PARAM* sort_param)
longlong sortbuff_size; longlong sortbuff_size;
ha_keys UNINIT_VAR(keys), idx; ha_keys UNINIT_VAR(keys), idx;
uint sort_length; uint sort_length;
uint maxbuffer; size_t maxbuffer;
uchar **sort_keys= NULL; uchar **sort_keys= NULL;
DBUG_ENTER("_ma_thr_find_all_keys_exec"); DBUG_ENTER("_ma_thr_find_all_keys_exec");
DBUG_PRINT("enter", ("master: %d", sort_param->master)); DBUG_PRINT("enter", ("master: %d", sort_param->master));
@ -406,11 +406,11 @@ static my_bool _ma_thr_find_all_keys_exec(MARIA_SORT_PARAM* sort_param)
will be allocated when needed. will be allocated when needed.
*/ */
keys= memavl / (sort_length+sizeof(char*)); keys= memavl / (sort_length+sizeof(char*));
maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1); maxbuffer= (size_t) MY_MIN((ulonglong) 1000, (idx / keys)+1);
} }
else else
{ {
uint maxbuffer_org; size_t maxbuffer_org;
do do
{ {
maxbuffer_org= maxbuffer; maxbuffer_org= maxbuffer;
@ -622,7 +622,7 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
if (sinfo->buffpek.elements) if (sinfo->buffpek.elements)
{ {
uint maxbuffer=sinfo->buffpek.elements-1; size_t maxbuffer=sinfo->buffpek.elements-1;
if (!mergebuf) if (!mergebuf)
{ {
length=(size_t)param->sort_buffer_length; length=(size_t)param->sort_buffer_length;
@ -838,9 +838,9 @@ static int write_index(MARIA_SORT_PARAM *info, register uchar **sort_keys,
static int merge_many_buff(MARIA_SORT_PARAM *info, ha_keys keys, static int merge_many_buff(MARIA_SORT_PARAM *info, ha_keys keys,
uchar **sort_keys, BUFFPEK *buffpek, uchar **sort_keys, BUFFPEK *buffpek,
uint *maxbuffer, IO_CACHE *t_file) size_t *maxbuffer, IO_CACHE *t_file)
{ {
uint tmp, merges, max_merges; size_t tmp, merges, max_merges;
IO_CACHE t_file2, *from_file, *to_file, *temp; IO_CACHE t_file2, *from_file, *to_file, *temp;
BUFFPEK *lastbuff; BUFFPEK *lastbuff;
DBUG_ENTER("merge_many_buff"); DBUG_ENTER("merge_many_buff");
@ -866,7 +866,7 @@ static int merge_many_buff(MARIA_SORT_PARAM *info, ha_keys keys,
from_file= t_file ; to_file= &t_file2; from_file= t_file ; to_file= &t_file2;
while (*maxbuffer >= MERGEBUFF2) while (*maxbuffer >= MERGEBUFF2)
{ {
uint i; size_t i;
reinit_io_cache(from_file,READ_CACHE,0L,0,0); reinit_io_cache(from_file,READ_CACHE,0L,0,0);
reinit_io_cache(to_file,WRITE_CACHE,0L,0,0); reinit_io_cache(to_file,WRITE_CACHE,0L,0,0);
lastbuff=buffpek; lastbuff=buffpek;
@ -884,7 +884,7 @@ static int merge_many_buff(MARIA_SORT_PARAM *info, ha_keys keys,
if (flush_io_cache(to_file)) if (flush_io_cache(to_file))
break; /* purecov: inspected */ break; /* purecov: inspected */
temp=from_file; from_file=to_file; to_file=temp; temp=from_file; from_file=to_file; to_file=temp;
*maxbuffer= (uint) (lastbuff-buffpek)-1; *maxbuffer= (size_t) (lastbuff-buffpek)-1;
if (info->sort_info->param->max_stage != 1) /* If not parallel */ if (info->sort_info->param->max_stage != 1) /* If not parallel */
_ma_report_progress(info->sort_info->param, merges++, max_merges); _ma_report_progress(info->sort_info->param, merges++, max_merges);
} }
@ -1140,7 +1140,7 @@ err:
static int static int
merge_index(MARIA_SORT_PARAM *info, ha_keys keys, uchar **sort_keys, merge_index(MARIA_SORT_PARAM *info, ha_keys keys, uchar **sort_keys,
BUFFPEK *buffpek, uint maxbuffer, IO_CACHE *tempfile) BUFFPEK *buffpek, size_t maxbuffer, IO_CACHE *tempfile)
{ {
DBUG_ENTER("merge_index"); DBUG_ENTER("merge_index");
if (merge_buffers(info,keys,tempfile,(IO_CACHE*) 0,sort_keys,buffpek,buffpek, if (merge_buffers(info,keys,tempfile,(IO_CACHE*) 0,sort_keys,buffpek,buffpek,

View File

@ -21,7 +21,7 @@
my_bool maria_log_remove(const char *testdir) my_bool maria_log_remove(const char *testdir)
{ {
MY_DIR *dirp; MY_DIR *dirp;
uint i; size_t i;
MY_STAT stat_buff; MY_STAT stat_buff;
char file_name[FN_REFLEN]; char file_name[FN_REFLEN];

View File

@ -301,7 +301,8 @@ uint _mi_ft_convert_to_ft2(MI_INFO *info, uint keynr, uchar *key)
DYNAMIC_ARRAY *da=info->ft1_to_ft2; DYNAMIC_ARRAY *da=info->ft1_to_ft2;
MI_KEYDEF *keyinfo=&info->s->ft2_keyinfo; MI_KEYDEF *keyinfo=&info->s->ft2_keyinfo;
uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end; uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end;
uint length, key_length; size_t length;
uint key_length;
DBUG_ENTER("_mi_ft_convert_to_ft2"); DBUG_ENTER("_mi_ft_convert_to_ft2");
/* we'll generate one pageful at once, and insert the rest one-by-one */ /* we'll generate one pageful at once, and insert the rest one-by-one */

View File

@ -47,7 +47,7 @@ extern void print_error(const char *fmt,...);
static ha_rows find_all_keys(MI_SORT_PARAM *info, ha_keys keys, static ha_rows find_all_keys(MI_SORT_PARAM *info, ha_keys keys,
uchar **sort_keys, uchar **sort_keys,
DYNAMIC_ARRAY *buffpek,uint *maxbuffer, DYNAMIC_ARRAY *buffpek, size_t *maxbuffer,
IO_CACHE *tempfile, IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions); IO_CACHE *tempfile_for_exceptions);
static int write_keys(MI_SORT_PARAM *info,uchar **sort_keys, static int write_keys(MI_SORT_PARAM *info,uchar **sort_keys,
@ -58,7 +58,7 @@ static int write_index(MI_SORT_PARAM *info,uchar * *sort_keys,
ha_keys count); ha_keys count);
static int merge_many_buff(MI_SORT_PARAM *info, ha_keys keys, static int merge_many_buff(MI_SORT_PARAM *info, ha_keys keys,
uchar * *sort_keys, uchar * *sort_keys,
BUFFPEK *buffpek, uint *maxbuffer, BUFFPEK *buffpek, size_t *maxbuffer,
IO_CACHE *t_file); IO_CACHE *t_file);
static my_off_t read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek, static my_off_t read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
uint sort_length); uint sort_length);
@ -66,7 +66,7 @@ static int merge_buffers(MI_SORT_PARAM *info, ha_keys keys,
IO_CACHE *from_file, IO_CACHE *to_file, IO_CACHE *from_file, IO_CACHE *to_file,
uchar * *sort_keys, BUFFPEK *lastbuff, uchar * *sort_keys, BUFFPEK *lastbuff,
BUFFPEK *Fb, BUFFPEK *Tb); BUFFPEK *Fb, BUFFPEK *Tb);
static int merge_index(MI_SORT_PARAM *,ha_keys,uchar **,BUFFPEK *, uint, static int merge_index(MI_SORT_PARAM *,ha_keys,uchar **,BUFFPEK *, size_t,
IO_CACHE *); IO_CACHE *);
static int flush_ft_buf(MI_SORT_PARAM *info); static int flush_ft_buf(MI_SORT_PARAM *info);
@ -124,7 +124,8 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
ulonglong sortbuff_size) ulonglong sortbuff_size)
{ {
int error; int error;
uint sort_length, maxbuffer; uint sort_length;
size_t maxbuffer;
ulonglong memavl, old_memavl; ulonglong memavl, old_memavl;
DYNAMIC_ARRAY buffpek; DYNAMIC_ARRAY buffpek;
ha_rows records, UNINIT_VAR(keys); ha_rows records, UNINIT_VAR(keys);
@ -161,7 +162,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
will be allocated when needed. will be allocated when needed.
*/ */
keys= memavl / (sort_length+sizeof(char*)); keys= memavl / (sort_length+sizeof(char*));
maxbuffer= (uint) MY_MIN((ulonglong) 1000, (records / keys)+1); maxbuffer= (size_t) MY_MIN((ulonglong) 1000, (records / keys)+1);
} }
else else
{ {
@ -169,7 +170,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
All keys can't fit in memory. All keys can't fit in memory.
Calculate how many keys + buffers we can keep in memory Calculate how many keys + buffers we can keep in memory
*/ */
uint maxbuffer_org; size_t maxbuffer_org;
do do
{ {
maxbuffer_org= maxbuffer; maxbuffer_org= maxbuffer;
@ -186,7 +187,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
goto err; goto err;
} }
} }
while ((maxbuffer= (uint) (records/(keys-1)+1)) != maxbuffer_org); while ((maxbuffer= (size_t) (records/(keys-1)+1)) != maxbuffer_org);
} }
if ((sort_keys= ((uchar **) if ((sort_keys= ((uchar **)
@ -298,7 +299,7 @@ err:
static ha_rows find_all_keys(MI_SORT_PARAM *info, ha_rows keys, static ha_rows find_all_keys(MI_SORT_PARAM *info, ha_rows keys,
uchar **sort_keys, DYNAMIC_ARRAY *buffpek, uchar **sort_keys, DYNAMIC_ARRAY *buffpek,
uint *maxbuffer, IO_CACHE *tempfile, size_t *maxbuffer, IO_CACHE *tempfile,
IO_CACHE *tempfile_for_exceptions) IO_CACHE *tempfile_for_exceptions)
{ {
int error; int error;
@ -349,7 +350,7 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
ulonglong memavl, old_memavl, sortbuff_size; ulonglong memavl, old_memavl, sortbuff_size;
ha_keys UNINIT_VAR(keys), idx; ha_keys UNINIT_VAR(keys), idx;
uint sort_length; uint sort_length;
uint maxbuffer; size_t maxbuffer;
uchar **sort_keys= NULL; uchar **sort_keys= NULL;
int error= 0; int error= 0;
DBUG_ENTER("thr_find_all_keys"); DBUG_ENTER("thr_find_all_keys");
@ -386,18 +387,18 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
will be allocated when needed. will be allocated when needed.
*/ */
keys= memavl / (sort_length+sizeof(char*)); keys= memavl / (sort_length+sizeof(char*));
maxbuffer= (uint) MY_MIN((ulonglong) 1000, (idx / keys)+1); maxbuffer= (size_t) MY_MIN((ulonglong) 1000, (idx / keys)+1);
} }
else else
{ {
uint maxbuffer_org; size_t maxbuffer_org;
do do
{ {
maxbuffer_org= maxbuffer; maxbuffer_org= maxbuffer;
if (memavl < sizeof(BUFFPEK)*maxbuffer || if (memavl < sizeof(BUFFPEK)*maxbuffer ||
(keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/ (keys=(memavl-sizeof(BUFFPEK)*maxbuffer)/
(sort_length+sizeof(char*))) <= 1 || (sort_length+sizeof(char*))) <= 1 ||
keys < (uint) maxbuffer) keys < maxbuffer)
{ {
mi_check_print_error(sort_param->sort_info->param, mi_check_print_error(sort_param->sort_info->param,
"myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u", "myisam_sort_buffer_size is too small. Current myisam_sort_buffer_size: %llu rows: %llu sort_length: %u",
@ -405,7 +406,7 @@ static my_bool thr_find_all_keys_exec(MI_SORT_PARAM *sort_param)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
} }
while ((maxbuffer= (uint) (idx/(keys-1)+1)) != maxbuffer_org); while ((maxbuffer= (size_t) (idx/(keys-1)+1)) != maxbuffer_org);
} }
if ((sort_keys= (uchar**) my_malloc(PSI_INSTRUMENT_ME, if ((sort_keys= (uchar**) my_malloc(PSI_INSTRUMENT_ME,
(size_t)(keys * (sort_length + sizeof(char*)) + (size_t)(keys * (sort_length + sizeof(char*)) +
@ -604,7 +605,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
if (sinfo->buffpek.elements) if (sinfo->buffpek.elements)
{ {
uint maxbuffer=sinfo->buffpek.elements-1; size_t maxbuffer=sinfo->buffpek.elements-1;
if (!mergebuf) if (!mergebuf)
{ {
length=param->sort_buffer_length; length=param->sort_buffer_length;
@ -806,9 +807,9 @@ static int write_index(MI_SORT_PARAM *info, register uchar **sort_keys,
static int merge_many_buff(MI_SORT_PARAM *info, ha_keys keys, static int merge_many_buff(MI_SORT_PARAM *info, ha_keys keys,
uchar **sort_keys, BUFFPEK *buffpek, uchar **sort_keys, BUFFPEK *buffpek,
uint *maxbuffer, IO_CACHE *t_file) size_t *maxbuffer, IO_CACHE *t_file)
{ {
register uint i; register size_t i;
IO_CACHE t_file2, *from_file, *to_file, *temp; IO_CACHE t_file2, *from_file, *to_file, *temp;
BUFFPEK *lastbuff; BUFFPEK *lastbuff;
DBUG_ENTER("merge_many_buff"); DBUG_ENTER("merge_many_buff");
@ -838,7 +839,7 @@ static int merge_many_buff(MI_SORT_PARAM *info, ha_keys keys,
if (flush_io_cache(to_file)) if (flush_io_cache(to_file))
break; /* purecov: inspected */ break; /* purecov: inspected */
temp=from_file; from_file=to_file; to_file=temp; temp=from_file; from_file=to_file; to_file=temp;
*maxbuffer= (uint) (lastbuff-buffpek)-1; *maxbuffer= (size_t) (lastbuff-buffpek)-1;
} }
cleanup: cleanup:
close_cached_file(to_file); /* This holds old result */ close_cached_file(to_file); /* This holds old result */
@ -1099,7 +1100,7 @@ err:
static int static int
merge_index(MI_SORT_PARAM *info, ha_keys keys, uchar **sort_keys, merge_index(MI_SORT_PARAM *info, ha_keys keys, uchar **sort_keys,
BUFFPEK *buffpek, uint maxbuffer, IO_CACHE *tempfile) BUFFPEK *buffpek, size_t maxbuffer, IO_CACHE *tempfile)
{ {
DBUG_ENTER("merge_index"); DBUG_ENTER("merge_index");
if (merge_buffers(info,keys,tempfile,(IO_CACHE*) 0,sort_keys,buffpek,buffpek, if (merge_buffers(info,keys,tempfile,(IO_CACHE*) 0,sort_keys,buffpek,buffpek,

View File

@ -702,7 +702,7 @@ static int rmdir_force(const char *dir) {
if (!dir_info) if (!dir_info)
return 1; return 1;
for (uint i = 0; i < dir_info->number_of_files; i++) { for (size_t i = 0; i < dir_info->number_of_files; i++) {
FILEINFO *file = dir_info->dir_entry + i; FILEINFO *file = dir_info->dir_entry + i;
strxnmov(path, sizeof(path), dir, sep, file->name, NULL); strxnmov(path, sizeof(path), dir, sep, file->name, NULL);

View File

@ -3852,7 +3852,7 @@ bool Rdb_validate_tbls::scan_for_frms(const std::string &datadir,
/* Scan through the files in the directory */ /* Scan through the files in the directory */
struct fileinfo *file_info = dir_info->dir_entry; struct fileinfo *file_info = dir_info->dir_entry;
for (uint ii = 0; ii < dir_info->number_of_files; ii++, file_info++) { for (size_t ii = 0; ii < dir_info->number_of_files; ii++, file_info++) {
/* Find .frm files that are not temp files (those that contain '#sql') */ /* Find .frm files that are not temp files (those that contain '#sql') */
const char *ext = strrchr(file_info->name, '.'); const char *ext = strrchr(file_info->name, '.');
if (ext != nullptr && strstr(file_info->name, tmp_file_prefix) == nullptr && if (ext != nullptr && strstr(file_info->name, tmp_file_prefix) == nullptr &&
@ -3897,7 +3897,7 @@ bool Rdb_validate_tbls::compare_to_actual_tables(const std::string &datadir,
} }
file_info = dir_info->dir_entry; file_info = dir_info->dir_entry;
for (uint ii = 0; ii < dir_info->number_of_files; ii++, file_info++) { for (size_t ii = 0; ii < dir_info->number_of_files; ii++, file_info++) {
/* Ignore files/dirs starting with '.' */ /* Ignore files/dirs starting with '.' */
if (file_info->name[0] == '.') continue; if (file_info->name[0] == '.') continue;

View File

@ -542,7 +542,7 @@ void Rdb_sst_info::init(const rocksdb::DB *const db) {
// Scan through the files in the directory // Scan through the files in the directory
const struct fileinfo *file_info = dir_info->dir_entry; const struct fileinfo *file_info = dir_info->dir_entry;
for (uint ii= 0; ii < dir_info->number_of_files; ii++, file_info++) { for (size_t ii= 0; ii < dir_info->number_of_files; ii++, file_info++) {
// find any files ending with m_suffix ... // find any files ending with m_suffix ...
const std::string name = file_info->name; const std::string name = file_info->name;
const size_t pos = name.find(m_suffix); const size_t pos = name.find(m_suffix);

View File

@ -264,9 +264,9 @@ json_norm_array_append_value(struct json_norm_array *arr,
int int
json_norm_init_dynamic_array(size_t element_size, void *where) json_norm_init_dynamic_array(size_t element_size, void *where)
{ {
const uint init_alloc= 20; const size_t init_alloc= 20;
const uint alloc_increment= 20; const size_t alloc_increment= 20;
return my_init_dynamic_array(PSI_JSON, where, (uint)element_size, return my_init_dynamic_array(PSI_JSON, where, element_size,
init_alloc, alloc_increment, init_alloc, alloc_increment,
JSON_MALLOC_FLAGS); JSON_MALLOC_FLAGS);
} }