summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-02-06 12:55:58 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2018-02-06 12:55:58 +0000
commit6c279ad6a71c63cb595fde7c951aadb31c3dbebc (patch)
tree3603f88e1b3bd1e622edb182cccd882dd31ddc8a /sql/sql_cache.cc
parentf271100836d8a91a775894ec36b869a66a3145e5 (diff)
downloadmariadb-git-6c279ad6a71c63cb595fde7c951aadb31c3dbebc.tar.gz
MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from 'size_t' to 'type', possible loss of data)
Handle string length as size_t, consistently (almost always:)) Change function prototypes to accept size_t, where in the past ulong or uint were used. change local/member variables to size_t when appropriate. This fix excludes rocksdb, spider,spider, sphinx and connect for now.
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc257
1 files changed, 128 insertions, 129 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index c340f4afc8b..968cd9970f5 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -817,10 +817,10 @@ inline Query_cache_block * Query_cache_block_table::block()
Query_cache_block method(s)
*****************************************************************************/
-void Query_cache_block::init(ulong block_length)
+void Query_cache_block::init(size_t block_length)
{
DBUG_ENTER("Query_cache_block::init");
- DBUG_PRINT("qcache", ("init block: %p length: %lu", this,
+ DBUG_PRINT("qcache", ("init block: %p length: %zu", this,
block_length));
length = block_length;
used = 0;
@@ -1037,7 +1037,7 @@ uchar *query_cache_query_get_key(const uchar *record, size_t *length,
/**
libmysql convenience wrapper to insert data into query cache.
*/
-void query_cache_insert(void *thd_arg, const char *packet, ulong length,
+void query_cache_insert(void *thd_arg, const char *packet, size_t length,
unsigned pkt_nr)
{
THD *thd= (THD*) thd_arg;
@@ -1053,7 +1053,7 @@ void query_cache_insert(void *thd_arg, const char *packet, ulong length,
return;
query_cache.insert(thd, &thd->query_cache_tls,
- packet, length,
+ packet, (size_t)length,
pkt_nr);
}
@@ -1064,7 +1064,7 @@ void query_cache_insert(void *thd_arg, const char *packet, ulong length,
void
Query_cache::insert(THD *thd, Query_cache_tls *query_cache_tls,
- const char *packet, ulong length,
+ const char *packet, size_t length,
unsigned pkt_nr)
{
DBUG_ENTER("Query_cache::insert");
@@ -1097,7 +1097,7 @@ Query_cache::insert(THD *thd, Query_cache_tls *query_cache_tls,
Query_cache_block *result= header->result();
DUMP(this);
- DBUG_PRINT("qcache", ("insert packet %lu bytes long",length));
+ DBUG_PRINT("qcache", ("insert packet %zu bytes long",length));
/*
On success, STRUCT_UNLOCK is done by append_result_data. Otherwise, we
@@ -1202,8 +1202,8 @@ void Query_cache::end_of_result(THD *thd)
BLOCK_LOCK_WR(query_block);
Query_cache_query *header= query_block->query();
Query_cache_block *last_result_block;
- ulong allign_size;
- ulong len;
+ size_t allign_size;
+ size_t len;
if (header->result() == 0)
{
@@ -1263,9 +1263,9 @@ void mysql_query_cache_invalidate4(THD *thd,
Query_cache methods
*****************************************************************************/
-Query_cache::Query_cache(ulong query_cache_limit_arg,
- ulong min_allocation_unit_arg,
- ulong min_result_data_size_arg,
+Query_cache::Query_cache(size_t query_cache_limit_arg,
+ size_t min_allocation_unit_arg,
+ size_t min_result_data_size_arg,
uint def_query_hash_size_arg,
uint def_table_hash_size_arg)
:query_cache_size(0),
@@ -1279,7 +1279,7 @@ Query_cache::Query_cache(ulong query_cache_limit_arg,
def_table_hash_size(ALIGN_SIZE(def_table_hash_size_arg)),
initialized(0)
{
- ulong min_needed= (ALIGN_SIZE(sizeof(Query_cache_block)) +
+ size_t min_needed= (ALIGN_SIZE(sizeof(Query_cache_block)) +
ALIGN_SIZE(sizeof(Query_cache_block_table)) +
ALIGN_SIZE(sizeof(Query_cache_query)) + 3);
set_if_bigger(min_allocation_unit,min_needed);
@@ -1288,11 +1288,11 @@ Query_cache::Query_cache(ulong query_cache_limit_arg,
}
-ulong Query_cache::resize(ulong query_cache_size_arg)
+size_t Query_cache::resize(size_t query_cache_size_arg)
{
- ulong new_query_cache_size;
+ size_t new_query_cache_size;
DBUG_ENTER("Query_cache::resize");
- DBUG_PRINT("qcache", ("from %lu to %lu",query_cache_size,
+ DBUG_PRINT("qcache", ("from %zu to %zu",query_cache_size,
query_cache_size_arg));
DBUG_ASSERT(initialized);
@@ -1346,7 +1346,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
}
-ulong Query_cache::set_min_res_unit(ulong size)
+size_t Query_cache::set_min_res_unit(size_t size)
{
DBUG_ASSERT(size % 8 == 0);
if (size < min_allocation_unit)
@@ -1358,7 +1358,7 @@ ulong Query_cache::set_min_res_unit(ulong size)
void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
{
TABLE_COUNTER_TYPE local_tables;
- ulong tot_length;
+ size_t tot_length;
const char *query;
size_t query_length;
uint8 tables_type;
@@ -1446,8 +1446,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
DBUG_PRINT("qcache", ("\
long %d, 4.1: %d, eof: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
CS client: %u, CS result: %u, CS conn: %u, limit: %llu, TZ: %p, \
-sql mode: 0x%llx, sort len: %llu, conncat len: %llu, div_precision: %lu, \
-def_week_frmt: %lu, in_trans: %d, autocommit: %d",
+sql mode: 0x%llx, sort len: %llu, conncat len: %llu, div_precision: %zu, \
+def_week_frmt: %zu, in_trans: %d, autocommit: %d",
(int)flags.client_long_flag,
(int)flags.client_protocol_41,
(int)flags.client_depr_eof,
@@ -1531,7 +1531,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
Query_cache_block::QUERY, local_tables);
if (query_block != 0)
{
- DBUG_PRINT("qcache", ("query block %p allocated, %lu",
+ DBUG_PRINT("qcache", ("query block %p allocated, %zu",
query_block, query_block->used));
Query_cache_query *header = query_block->query();
@@ -1609,7 +1609,7 @@ end:
@retval TRUE On error
*/
static bool
-send_data_in_chunks(NET *net, const uchar *packet, ulong len)
+send_data_in_chunks(NET *net, const uchar *packet, size_t len)
{
/*
On the client we may require more memory than max_allowed_packet
@@ -1625,7 +1625,7 @@ send_data_in_chunks(NET *net, const uchar *packet, ulong len)
for max_allowed_packet, but large enough to ensure there is no
unnecessary overhead from too many syscalls per result set.
*/
- static const ulong MAX_CHUNK_LENGTH= 1024*1024;
+ static const size_t MAX_CHUNK_LENGTH= 1024*1024;
while (len > MAX_CHUNK_LENGTH)
{
@@ -1706,7 +1706,7 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length)
#endif
Query_cache_block *result_block;
Query_cache_block_table *block_table, *block_table_end;
- ulong tot_length;
+ size_t tot_length;
Query_cache_query_flags flags;
const char *sql, *sql_end, *found_brace= 0;
DBUG_ENTER("Query_cache::send_result_to_client");
@@ -1944,8 +1944,8 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length)
DBUG_PRINT("qcache", ("\
long %d, 4.1: %d, eof: %d, bin_proto: %d, more results %d, pkt_nr: %d, \
CS client: %u, CS result: %u, CS conn: %u, limit: %llu, TZ: %p, \
-sql mode: 0x%llx, sort len: %llu, conncat len: %llu, div_precision: %lu, \
-def_week_frmt: %lu, in_trans: %d, autocommit: %d",
+sql mode: 0x%llx, sort len: %llu, conncat len: %llu, div_precision: %zu, \
+def_week_frmt: %zu, in_trans: %d, autocommit: %d",
(int)flags.client_long_flag,
(int)flags.client_protocol_41,
(int)flags.client_depr_eof,
@@ -2092,7 +2092,7 @@ lookup:
if (table->callback())
{
char qcache_se_key_name[FN_REFLEN + 10];
- uint qcache_se_key_len, db_length= strlen(table->db());
+ size_t qcache_se_key_len, db_length= strlen(table->db());
engine_data= table->engine_data();
qcache_se_key_len= build_normalized_name(qcache_se_key_name,
@@ -2106,16 +2106,16 @@ lookup:
table->suffix_length());
if (!(*table->callback())(thd, qcache_se_key_name,
- qcache_se_key_len, &engine_data))
+ (uint)qcache_se_key_len, &engine_data))
{
DBUG_PRINT("qcache", ("Handler does not allow caching for %.*s",
- qcache_se_key_len, qcache_se_key_name));
+ (int)qcache_se_key_len, qcache_se_key_name));
BLOCK_UNLOCK_RD(query_block);
if (engine_data != table->engine_data())
{
DBUG_PRINT("qcache",
("Handler require invalidation queries of %.*s %llu-%llu",
- qcache_se_key_len, qcache_se_key_name,
+ (int)qcache_se_key_len, qcache_se_key_name,
engine_data, table->engine_data()));
invalidate_table_internal(thd,
(uchar *) table->db(),
@@ -2155,7 +2155,7 @@ lookup:
THD_STAGE_INFO(thd, stage_sending_cached_result_to_client);
do
{
- DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %u)",
+ DBUG_PRINT("qcache", ("Results (len: %zu used: %zu headers: %u)",
result_block->length, result_block->used,
(uint) (result_block->headers_len()+
ALIGN_SIZE(sizeof(Query_cache_result)))));
@@ -2317,7 +2317,7 @@ void Query_cache::invalidate(THD *thd, TABLE *table,
DBUG_VOID_RETURN;
}
-void Query_cache::invalidate(THD *thd, const char *key, uint32 key_length,
+void Query_cache::invalidate(THD *thd, const char *key, size_t key_length,
my_bool using_transactions)
{
DBUG_ENTER("Query_cache::invalidate (key)");
@@ -2461,7 +2461,7 @@ void Query_cache::flush()
*/
-void Query_cache::pack(THD *thd, ulong join_limit, uint iteration_limit)
+void Query_cache::pack(THD *thd, size_t join_limit, uint iteration_limit)
{
DBUG_ENTER("Query_cache::pack");
@@ -2580,11 +2580,11 @@ void Query_cache::init()
}
-ulong Query_cache::init_cache()
+size_t Query_cache::init_cache()
{
- uint mem_bin_count, num, step;
- ulong mem_bin_size, prev_size, inc;
- ulong additional_data_size, max_mem_bin_size, approx_additional_data_size;
+ size_t mem_bin_count, num, step;
+ size_t mem_bin_size, prev_size, inc;
+ size_t additional_data_size, max_mem_bin_size, approx_additional_data_size;
int align;
DBUG_ENTER("Query_cache::init_cache");
@@ -2650,7 +2650,7 @@ ulong Query_cache::init_cache()
my_malloc_lock(query_cache_size+additional_data_size, MYF(0))))
goto err;
- DBUG_PRINT("qcache", ("cache length %lu, min unit %lu, %u bins",
+ DBUG_PRINT("qcache", ("cache length %zu, min unit %zu, %zu bins",
query_cache_size, min_allocation_unit, mem_bin_num));
steps = (Query_cache_memory_bin_step *) cache;
@@ -2674,9 +2674,9 @@ ulong Query_cache::init_cache()
mem_bin_size = max_mem_bin_size >> QUERY_CACHE_MEM_BIN_STEP_PWR2;
while (mem_bin_size > min_allocation_unit)
{
- ulong incr = (steps[step-1].size - mem_bin_size) / mem_bin_count;
- unsigned long size = mem_bin_size;
- for (uint i= mem_bin_count; i > 0; i--)
+ size_t incr = (steps[step-1].size - mem_bin_size) / mem_bin_count;
+ size_t size = mem_bin_size;
+ for (size_t i= mem_bin_count; i > 0; i--)
{
bins[num+i-1].init(size);
size += incr;
@@ -2699,9 +2699,9 @@ ulong Query_cache::init_cache()
steps[step].init(mem_bin_size, num + mem_bin_count - 1, inc);
{
- uint skiped = (min_allocation_unit - mem_bin_size)/inc;
- ulong size = mem_bin_size + inc*skiped;
- uint i = mem_bin_count - skiped;
+ size_t skiped = (min_allocation_unit - mem_bin_size)/inc;
+ size_t size = mem_bin_size + inc*skiped;
+ size_t i = mem_bin_count - skiped;
while (i-- > 0)
{
bins[num+i].init(size);
@@ -2902,7 +2902,7 @@ my_bool Query_cache::free_old_query()
void Query_cache::free_query_internal(Query_cache_block *query_block)
{
DBUG_ENTER("Query_cache::free_query_internal");
- DBUG_PRINT("qcache", ("free query %p %lu bytes result",
+ DBUG_PRINT("qcache", ("free query %p %zu bytes result",
query_block,
query_block->query()->length() ));
@@ -2972,7 +2972,7 @@ void Query_cache::free_query_internal(Query_cache_block *query_block)
void Query_cache::free_query(Query_cache_block *query_block)
{
DBUG_ENTER("Query_cache::free_query");
- DBUG_PRINT("qcache", ("free query %p %lu bytes result",
+ DBUG_PRINT("qcache", ("free query %p %zu bytes result",
query_block,
query_block->query()->length() ));
@@ -2987,18 +2987,18 @@ void Query_cache::free_query(Query_cache_block *query_block)
*****************************************************************************/
Query_cache_block *
-Query_cache::write_block_data(ulong data_len, uchar* data,
- ulong header_len,
+Query_cache::write_block_data(size_t data_len, uchar* data,
+ size_t header_len,
Query_cache_block::block_type type,
TABLE_COUNTER_TYPE ntab)
{
- ulong all_headers_len = (ALIGN_SIZE(sizeof(Query_cache_block)) +
+ size_t all_headers_len = (ALIGN_SIZE(sizeof(Query_cache_block)) +
ALIGN_SIZE(ntab*sizeof(Query_cache_block_table)) +
header_len);
- ulong len = data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
+ size_t len = data_len + all_headers_len;
+ size_t align_len= ALIGN_SIZE(len);
DBUG_ENTER("Query_cache::write_block_data");
- DBUG_PRINT("qcache", ("data: %ld, header: %ld, all header: %ld",
+ DBUG_PRINT("qcache", ("data: %zd, header: %zd, all header: %zd",
data_len, header_len, all_headers_len));
Query_cache_block *block= allocate_block(MY_MAX(align_len,
min_allocation_unit),1, 0);
@@ -3016,33 +3016,33 @@ Query_cache::write_block_data(ulong data_len, uchar* data,
my_bool
Query_cache::append_result_data(Query_cache_block **current_block,
- ulong data_len, uchar* data,
+ size_t data_len, uchar* data,
Query_cache_block *query_block)
{
DBUG_ENTER("Query_cache::append_result_data");
- DBUG_PRINT("qcache", ("append %lu bytes to %p query",
+ DBUG_PRINT("qcache", ("append %zu bytes to %p query",
data_len, query_block));
if (query_block->query()->add(data_len) > query_cache_limit)
{
- DBUG_PRINT("qcache", ("size limit reached %lu > %lu",
+ DBUG_PRINT("qcache", ("size limit reached %zu > %zu",
query_block->query()->length(),
query_cache_limit));
DBUG_RETURN(0);
}
if (*current_block == 0)
{
- DBUG_PRINT("qcache", ("allocated first result data block %lu", data_len));
+ DBUG_PRINT("qcache", ("allocated first result data block %zu", data_len));
DBUG_RETURN(write_result_data(current_block, data_len, data, query_block,
Query_cache_block::RES_BEG));
}
Query_cache_block *last_block = (*current_block)->prev;
- DBUG_PRINT("qcache", ("lastblock %p len %lu used %lu",
+ DBUG_PRINT("qcache", ("lastblock %p len %zu used %zu",
last_block, last_block->length,
last_block->used));
my_bool success = 1;
- ulong last_block_free_space= last_block->length - last_block->used;
+ size_t last_block_free_space= last_block->length - last_block->used;
/*
We will first allocate and write the 'tail' of data, that doesn't fit
@@ -3051,8 +3051,8 @@ Query_cache::append_result_data(Query_cache_block **current_block,
*/
// Try join blocks if physically next block is free...
- ulong tail = data_len - last_block_free_space;
- ulong append_min = get_min_append_result_data_size();
+ size_t tail = data_len - last_block_free_space;
+ size_t append_min = get_min_append_result_data_size();
if (last_block_free_space < data_len &&
append_next_free_block(last_block,
MY_MAX(tail, append_min)))
@@ -3060,7 +3060,7 @@ Query_cache::append_result_data(Query_cache_block **current_block,
// If no space in last block (even after join) allocate new block
if (last_block_free_space < data_len)
{
- DBUG_PRINT("qcache", ("allocate new block for %lu bytes",
+ DBUG_PRINT("qcache", ("allocate new block for %zu bytes",
data_len-last_block_free_space));
Query_cache_block *new_block = 0;
success = write_result_data(&new_block, data_len-last_block_free_space,
@@ -3083,8 +3083,8 @@ Query_cache::append_result_data(Query_cache_block **current_block,
// Now finally write data to the last block
if (success && last_block_free_space > 0)
{
- ulong to_copy = MY_MIN(data_len,last_block_free_space);
- DBUG_PRINT("qcache", ("use free space %lub at block %p to copy %lub",
+ size_t to_copy = MY_MIN(data_len,last_block_free_space);
+ DBUG_PRINT("qcache", ("use free space %zub at block %p to copy %zub",
last_block_free_space,last_block, to_copy));
memcpy((uchar*) last_block + last_block->used, data, to_copy);
last_block->used+=to_copy;
@@ -3094,12 +3094,12 @@ Query_cache::append_result_data(Query_cache_block **current_block,
my_bool Query_cache::write_result_data(Query_cache_block **result_block,
- ulong data_len, uchar* data,
+ size_t data_len, uchar* data,
Query_cache_block *query_block,
Query_cache_block::block_type type)
{
DBUG_ENTER("Query_cache::write_result_data");
- DBUG_PRINT("qcache", ("data_len %lu",data_len));
+ DBUG_PRINT("qcache", ("data_len %zu",data_len));
/*
Reserve block(s) for filling
@@ -3125,8 +3125,8 @@ my_bool Query_cache::write_result_data(Query_cache_block **result_block,
do
{
block->type = type;
- ulong length = block->used - headers_len;
- DBUG_PRINT("qcache", ("write %lu byte in block %p",length,
+ size_t length = block->used - headers_len;
+ DBUG_PRINT("qcache", ("write %zu byte in block %p",length,
block));
memcpy((uchar*) block+headers_len, rest, length);
rest += length;
@@ -3166,16 +3166,16 @@ my_bool Query_cache::write_result_data(Query_cache_block **result_block,
DBUG_RETURN(success);
}
-inline ulong Query_cache::get_min_first_result_data_size()
+inline size_t Query_cache::get_min_first_result_data_size()
{
if (queries_in_cache < QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER)
return min_result_data_size;
- ulong avg_result = (query_cache_size - free_memory) / queries_in_cache;
+ size_t avg_result = (query_cache_size - free_memory) / queries_in_cache;
avg_result = MY_MIN(avg_result, query_cache_limit);
return MY_MAX(min_result_data_size, avg_result);
}
-inline ulong Query_cache::get_min_append_result_data_size()
+inline size_t Query_cache::get_min_append_result_data_size()
{
return min_result_data_size;
}
@@ -3184,25 +3184,25 @@ inline ulong Query_cache::get_min_append_result_data_size()
Allocate one or more blocks to hold data
*/
my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
- ulong data_len,
+ size_t data_len,
Query_cache_block *query_block,
my_bool first_block_arg)
{
- ulong all_headers_len = (ALIGN_SIZE(sizeof(Query_cache_block)) +
+ size_t all_headers_len = (ALIGN_SIZE(sizeof(Query_cache_block)) +
ALIGN_SIZE(sizeof(Query_cache_result)));
- ulong min_size = (first_block_arg ?
+ size_t min_size = (first_block_arg ?
get_min_first_result_data_size():
get_min_append_result_data_size());
Query_cache_block *prev_block= NULL;
Query_cache_block *new_block;
DBUG_ENTER("Query_cache::allocate_data_chain");
- DBUG_PRINT("qcache", ("data_len %lu, all_headers_len %lu",
+ DBUG_PRINT("qcache", ("data_len %zu, all_headers_len %zu",
data_len, all_headers_len));
do
{
- ulong len= data_len + all_headers_len;
- ulong align_len= ALIGN_SIZE(len);
+ size_t len= data_len + all_headers_len;
+ size_t align_len= ALIGN_SIZE(len);
if (!(new_block= allocate_block(MY_MAX(min_size, align_len),
min_result_data_size == 0,
@@ -3219,7 +3219,7 @@ my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
Query_cache_result *header = new_block->result();
header->parent(query_block);
- DBUG_PRINT("qcache", ("Block len %lu used %lu",
+ DBUG_PRINT("qcache", ("Block len %zu used %zu",
new_block->length, new_block->used));
if (prev_block)
@@ -3269,7 +3269,7 @@ void Query_cache::invalidate_table(THD *thd, TABLE *table)
table->s->table_cache_key.length);
}
-void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length)
+void Query_cache::invalidate_table(THD *thd, uchar * key, size_t key_length)
{
DEBUG_SYNC(thd, "wait_in_query_cache_invalidate1");
@@ -3297,7 +3297,7 @@ void Query_cache::invalidate_table(THD *thd, uchar * key, uint32 key_length)
*/
void
-Query_cache::invalidate_table_internal(THD *thd, uchar *key, uint32 key_length)
+Query_cache::invalidate_table_internal(THD *thd, uchar *key, size_t key_length)
{
Query_cache_block *table_block=
(Query_cache_block*)my_hash_search(&tables, key, key_length);
@@ -3463,16 +3463,15 @@ my_bool Query_cache::register_all_tables(THD *thd,
*/
my_bool
-Query_cache::insert_table(THD *thd, uint key_len, const char *key,
- Query_cache_block_table *node,
- uint32 db_length, uint8 suffix_length_arg,
+Query_cache::insert_table(THD *thd, size_t key_len, const char *key,
+ Query_cache_block_table *node, size_t db_length, uint8 suffix_length_arg,
uint8 cache_type,
qc_engine_callback callback,
ulonglong engine_data,
my_bool hash)
{
DBUG_ENTER("Query_cache::insert_table");
- DBUG_PRINT("qcache", ("insert table node %p, len %d",
+ DBUG_PRINT("qcache", ("insert table node %p, len %zu",
node, key_len));
Query_cache_block *table_block=
@@ -3538,7 +3537,7 @@ Query_cache::insert_table(THD *thd, uint key_len, const char *key,
}
char *db= header->db();
header->table(db + db_length + 1);
- header->key_length(key_len);
+ header->key_length((uint32)key_len);
header->suffix_length(suffix_length_arg);
header->type(cache_type);
header->callback(callback);
@@ -3610,15 +3609,15 @@ void Query_cache::unlink_table(Query_cache_block_table *node)
*****************************************************************************/
Query_cache_block *
-Query_cache::allocate_block(ulong len, my_bool not_less, ulong min)
+Query_cache::allocate_block(size_t len, my_bool not_less, size_t min)
{
DBUG_ENTER("Query_cache::allocate_block");
- DBUG_PRINT("qcache", ("len %lu, not less %d, min %lu",
+ DBUG_PRINT("qcache", ("len %zu, not less %d, min %zu",
len, not_less,min));
if (len >= MY_MIN(query_cache_size, query_cache_limit))
{
- DBUG_PRINT("qcache", ("Query cache hase only %lu memory and limit %lu",
+ DBUG_PRINT("qcache", ("Query cache hase only %zu memory and limit %zu",
query_cache_size, query_cache_limit));
DBUG_RETURN(0); // in any case we don't have such piece of memory
}
@@ -3642,11 +3641,11 @@ Query_cache::allocate_block(ulong len, my_bool not_less, ulong min)
Query_cache_block *
-Query_cache::get_free_block(ulong len, my_bool not_less, ulong min)
+Query_cache::get_free_block(size_t len, my_bool not_less, size_t min)
{
Query_cache_block *block = 0, *first = 0;
DBUG_ENTER("Query_cache::get_free_block");
- DBUG_PRINT("qcache",("length %lu, not_less %d, min %lu", len,
+ DBUG_PRINT("qcache",("length %zu, not_less %d, min %zu", len,
(int)not_less, min));
/* Find block with minimal size > len */
@@ -3737,7 +3736,7 @@ void Query_cache::free_memory_block(Query_cache_block *block)
}
-void Query_cache::split_block(Query_cache_block *block, ulong len)
+void Query_cache::split_block(Query_cache_block *block, size_t len)
{
DBUG_ENTER("Query_cache::split_block");
Query_cache_block *new_block = (Query_cache_block*)(((uchar*) block)+len);
@@ -3758,7 +3757,7 @@ void Query_cache::split_block(Query_cache_block *block, ulong len)
else
free_memory_block(new_block);
- DBUG_PRINT("qcache", ("split %p (%lu) new %p",
+ DBUG_PRINT("qcache", ("split %p (%zu) new %p",
block, len, new_block));
DBUG_VOID_RETURN;
}
@@ -3791,16 +3790,16 @@ Query_cache::join_free_blocks(Query_cache_block *first_block_arg,
my_bool Query_cache::append_next_free_block(Query_cache_block *block,
- ulong add_size)
+ size_t add_size)
{
Query_cache_block *next_block = block->pnext;
DBUG_ENTER("Query_cache::append_next_free_block");
- DBUG_PRINT("enter", ("block %p, add_size %lu", block,
+ DBUG_PRINT("enter", ("block %p, add_size %zu", block,
add_size));
if (next_block != first_block && next_block->is_free())
{
- ulong old_len = block->length;
+ size_t old_len = block->length;
exclude_from_free_memory_list(next_block);
next_block->destroy();
total_blocks--;
@@ -3850,14 +3849,14 @@ void Query_cache::insert_into_free_memory_list(Query_cache_block *free_block)
DBUG_VOID_RETURN;
}
-uint Query_cache::find_bin(ulong size)
+uint Query_cache::find_bin(size_t size)
{
DBUG_ENTER("Query_cache::find_bin");
// Binary search
- int left = 0, right = mem_bin_steps;
+ size_t left = 0, right = mem_bin_steps;
do
{
- int middle = (left + right) / 2;
+ size_t middle = (left + right) / 2;
if (steps[middle].size > size)
left = middle+1;
else
@@ -3866,15 +3865,15 @@ uint Query_cache::find_bin(ulong size)
if (left == 0)
{
// first bin not subordinate of common rules
- DBUG_PRINT("qcache", ("first bin (# 0), size %lu",size));
+ DBUG_PRINT("qcache", ("first bin (# 0), size %zu",size));
DBUG_RETURN(0);
}
- uint bin = steps[left].idx -
- (uint)((size - steps[left].size)/steps[left].increment);
+ size_t bin = steps[left].idx -
+ ((size - steps[left].size)/steps[left].increment);
- DBUG_PRINT("qcache", ("bin %u step %u, size %lu step size %lu",
+ DBUG_PRINT("qcache", ("bin %zu step %zu, size %zu step size %zu",
bin, left, size, steps[left].size));
- DBUG_RETURN(bin);
+ DBUG_RETURN((uint)bin);
}
@@ -4172,7 +4171,7 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
handler= table->file;
if (!handler->register_query_cache_table(thd,
table->s->normalized_path.str,
- table->s->normalized_path.length,
+ (uint)table->s->normalized_path.length,
&tables_used->callback_func,
&tables_used->engine_data))
{
@@ -4198,7 +4197,7 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
/**
Rearrange all memory blocks so that free memory joins at the
'bottom' of the allocated memory block containing all cache data.
- @see Query_cache::pack(ulong join_limit, uint iteration_limit)
+ @see Query_cache::pack(size_t join_limit, uint iteration_limit)
*/
void Query_cache::pack_cache()
@@ -4209,7 +4208,7 @@ void Query_cache::pack_cache()
uchar *border = 0;
Query_cache_block *before = 0;
- ulong gap = 0;
+ size_t gap = 0;
my_bool ok = 1;
Query_cache_block *block = first_block;
DUMP(this);
@@ -4243,7 +4242,7 @@ void Query_cache::pack_cache()
my_bool Query_cache::move_by_type(uchar **border,
- Query_cache_block **before, ulong *gap,
+ Query_cache_block **before, size_t *gap,
Query_cache_block *block)
{
DBUG_ENTER("Query_cache::move_by_type");
@@ -4265,7 +4264,7 @@ my_bool Query_cache::move_by_type(uchar **border,
block->pnext->pprev=block->pprev;
block->destroy();
total_blocks--;
- DBUG_PRINT("qcache", ("added to gap (%lu)", *gap));
+ DBUG_PRINT("qcache", ("added to gap (%zu)", *gap));
break;
}
case Query_cache_block::TABLE:
@@ -4274,7 +4273,7 @@ my_bool Query_cache::move_by_type(uchar **border,
DBUG_PRINT("qcache", ("block %p TABLE", block));
if (*border == 0)
break;
- ulong len = block->length, used = block->used;
+ size_t len = block->length, used = block->used;
Query_cache_block_table *list_root = block->table(0);
Query_cache_block_table *tprev = list_root->prev,
*tnext = list_root->next;
@@ -4324,7 +4323,7 @@ my_bool Query_cache::move_by_type(uchar **border,
/* Fix hash to point at moved block */
my_hash_replace(&tables, &record_idx, (uchar*) new_block);
- DBUG_PRINT("qcache", ("moved %lu bytes to %p, new gap at %p",
+ DBUG_PRINT("qcache", ("moved %zu bytes to %p, new gap at %p",
len, new_block, *border));
break;
}
@@ -4335,7 +4334,7 @@ my_bool Query_cache::move_by_type(uchar **border,
if (*border == 0)
break;
BLOCK_LOCK_WR(block);
- ulong len = block->length, used = block->used;
+ size_t len = block->length, used = block->used;
TABLE_COUNTER_TYPE n_tables = block->n_tables;
Query_cache_block *prev = block->prev,
*next = block->next,
@@ -4417,7 +4416,7 @@ my_bool Query_cache::move_by_type(uchar **border,
}
/* Fix hash to point at moved block */
my_hash_replace(&queries, &record_idx, (uchar*) new_block);
- DBUG_PRINT("qcache", ("moved %lu bytes to %p, new gap at %p",
+ DBUG_PRINT("qcache", ("moved %zu bytes to %p, new gap at %p",
len, new_block, *border));
break;
}
@@ -4434,7 +4433,7 @@ my_bool Query_cache::move_by_type(uchar **border,
BLOCK_LOCK_WR(query_block);
Query_cache_block *next= block->next, *prev= block->prev;
Query_cache_block::block_type type= block->type;
- ulong len = block->length, used = block->used;
+ size_t len = block->length, used = block->used;
Query_cache_block *pprev = block->pprev,
*pnext = block->pnext,
*new_block =(Query_cache_block*) *border;
@@ -4452,7 +4451,7 @@ my_bool Query_cache::move_by_type(uchar **border,
*border += len;
*before = new_block;
/* If result writing complete && we have free space in block */
- ulong free_space= new_block->length - new_block->used;
+ size_t free_space= new_block->length - new_block->used;
free_space-= free_space % ALIGN_SIZE(1);
if (query->result()->type == Query_cache_block::RESULT &&
new_block->length > new_block->used &&
@@ -4462,11 +4461,11 @@ my_bool Query_cache::move_by_type(uchar **border,
*border-= free_space;
*gap+= free_space;
DBUG_PRINT("qcache",
- ("rest of result free space added to gap (%lu)", *gap));
+ ("rest of result free space added to gap (%zu)", *gap));
new_block->length -= free_space;
}
BLOCK_UNLOCK_WR(query_block);
- DBUG_PRINT("qcache", ("moved %lu bytes to %p, new gap at %p",
+ DBUG_PRINT("qcache", ("moved %zu bytes to %p, new gap at %p",
len, new_block, *border));
break;
}
@@ -4506,7 +4505,7 @@ void Query_cache::relink(Query_cache_block *oblock,
}
-my_bool Query_cache::join_results(ulong join_limit)
+my_bool Query_cache::join_results(size_t join_limit)
{
my_bool has_moving = 0;
DBUG_ENTER("Query_cache::join_results");
@@ -4530,7 +4529,7 @@ my_bool Query_cache::join_results(ulong join_limit)
{
has_moving = 1;
Query_cache_block *first_result = header->result();
- ulong new_len = (header->length() +
+ size_t new_len = (header->length() +
ALIGN_SIZE(sizeof(Query_cache_block)) +
ALIGN_SIZE(sizeof(Query_cache_result)));
if (new_result_block->length >
@@ -4543,7 +4542,7 @@ my_bool Query_cache::join_results(ulong join_limit)
new_result_block->used = new_len;
new_result_block->next = new_result_block->prev = new_result_block;
- DBUG_PRINT("qcache", ("new block %lu/%lu (%lu)",
+ DBUG_PRINT("qcache", ("new block %zu/%zu (%zu)",
new_result_block->length,
new_result_block->used,
header->length()));
@@ -4554,9 +4553,9 @@ my_bool Query_cache::join_results(ulong join_limit)
Query_cache_block *result_block = first_result;
do
{
- ulong len = (result_block->used - result_block->headers_len() -
+ size_t len = (result_block->used - result_block->headers_len() -
ALIGN_SIZE(sizeof(Query_cache_result)));
- DBUG_PRINT("loop", ("add block %lu/%lu (%lu)",
+ DBUG_PRINT("loop", ("add block %zu/%zu (%zu)",
result_block->length,
result_block->used,
len));
@@ -4658,14 +4657,14 @@ void Query_cache::bins_dump()
return;
}
- DBUG_PRINT("qcache", ("mem_bin_num=%u, mem_bin_steps=%u",
+ DBUG_PRINT("qcache", ("mem_bin_num=%zu, mem_bin_steps=%zu",
mem_bin_num, mem_bin_steps));
DBUG_PRINT("qcache", ("-------------------------"));
DBUG_PRINT("qcache", (" size idx step"));
DBUG_PRINT("qcache", ("-------------------------"));
for (i=0; i < mem_bin_steps; i++)
{
- DBUG_PRINT("qcache", ("%10lu %3d %10lu", steps[i].size, steps[i].idx,
+ DBUG_PRINT("qcache", ("%10zu %3zd %10zu", steps[i].size, steps[i].idx,
steps[i].increment));
}
DBUG_PRINT("qcache", ("-------------------------"));
@@ -4673,13 +4672,13 @@ void Query_cache::bins_dump()
DBUG_PRINT("qcache", ("-------------------------"));
for (i=0; i < mem_bin_num; i++)
{
- DBUG_PRINT("qcache", ("%10lu %3d %p", bins[i].size, bins[i].number,
+ DBUG_PRINT("qcache", ("%10zu %3d %p", bins[i].size, bins[i].number,
&(bins[i])));
if (bins[i].free_blocks)
{
Query_cache_block *block = bins[i].free_blocks;
do{
- DBUG_PRINT("qcache", ("\\-- %lu %p %p %p %p %p",
+ DBUG_PRINT("qcache", ("\\-- %zu %p %p %p %p %p",
block->length,block,
block->next,block->prev,
block->pnext,block->pprev));
@@ -4706,7 +4705,7 @@ void Query_cache::cache_dump()
do
{
DBUG_PRINT("qcache",
- ("%10lu %10lu %1d %2d %p %p %p %p %p",
+ ("%10zu %10zu %1d %2d %p %p %p %p %p",
i->length, i->used, (int)i->type,
i->n_tables,i,
i->next,i->prev,i->pnext,
@@ -4762,7 +4761,7 @@ void Query_cache::queries_dump()
Query_cache_block *result_beg = result_block;
do
{
- DBUG_PRINT("qcache", ("-r- %u %lu/%lu %p %p %p %p %p",
+ DBUG_PRINT("qcache", ("-r- %u %zu/%zu %p %p %p %p %p",
(uint) result_block->type,
result_block->length, result_block->used,
result_block,
@@ -4840,7 +4839,7 @@ my_bool Query_cache::check_integrity(bool locked)
}
DBUG_PRINT("qcache", ("physical address check ..."));
- ulong free=0, used=0;
+ size_t free=0, used=0;
Query_cache_block * block = first_block;
do
{
@@ -4905,7 +4904,7 @@ my_bool Query_cache::check_integrity(bool locked)
}
else
{
- int idx = (((uchar*)bin) - ((uchar*)bins)) /
+ size_t idx = (((uchar*)bin) - ((uchar*)bins)) /
sizeof(Query_cache_memory_bin);
if (in_list(bins[idx].free_blocks, block, "free memory"))
result = 1;
@@ -4978,7 +4977,7 @@ my_bool Query_cache::check_integrity(bool locked)
if (used + free != query_cache_size)
{
DBUG_PRINT("error",
- ("used memory (%lu) + free memory (%lu) != query_cache_size (%lu)",
+ ("used memory (%zu) + free memory (%zu) != query_cache_size (%zu)",
used, free, query_cache_size));
result = 1;
}
@@ -4986,7 +4985,7 @@ my_bool Query_cache::check_integrity(bool locked)
if (free != free_memory)
{
DBUG_PRINT("error",
- ("free memory (%lu) != free_memory (%lu)",
+ ("free memory (%zu) != free_memory (%zu)",
free, free_memory));
result = 1;
}