Commit 24d9664a authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

In table cache code, fix casts from longlong to long for

'version' variables.

The warnings occur on Windows build, yet they are also are valid
on 32bit Unix.

Fix is to consistently use 64bit integer on all platforms.
parent 8e8a7f85
......@@ -7871,9 +7871,9 @@ static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff,
static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
{
var->type= SHOW_LONG;
var->type= SHOW_LONGLONG;
var->value= buff;
*((long *) buff)= (long) tdc_refresh_version();
*((longlong *) buff)= (longlong)tdc_refresh_version();
return 0;
}
......
......@@ -325,7 +325,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
struct close_cached_tables_arg
{
ulong refresh_version;
tdc_version_t refresh_version;
TDC_element *element;
};
......@@ -351,7 +351,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
{
bool result= FALSE;
struct timespec abstime;
ulong refresh_version;
tdc_version_t refresh_version;
DBUG_ENTER("close_cached_tables");
DBUG_ASSERT(thd || (!wait_for_refresh && !tables));
......@@ -1192,7 +1192,7 @@ bool wait_while_table_is_used(THD *thd, TABLE *table,
{
DBUG_ENTER("wait_while_table_is_used");
DBUG_ASSERT(!table->s->tmp_table);
DBUG_PRINT("enter", ("table: '%s' share: %p db_stat: %u version: %lu",
DBUG_PRINT("enter", ("table: '%s' share: %p db_stat: %u version: %lld",
table->s->table_name.str, table->s,
table->db_stat, table->s->tdc->version));
......@@ -1808,7 +1808,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
{
if (share->tdc->flushed)
{
DBUG_PRINT("info", ("Found old share version: %lu current: %lu",
DBUG_PRINT("info", ("Found old share version: %lld current: %lld",
share->tdc->version, tdc_refresh_version()));
/*
We already have an MDL lock. But we have encountered an old
......
......@@ -2173,7 +2173,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
length= my_snprintf(buff, buff_len - 1,
"Uptime: %lu Threads: %d Questions: %lu "
"Slow queries: %lu Opens: %lu Flush tables: %lu "
"Slow queries: %lu Opens: %lu Flush tables: %lld "
"Open tables: %u Queries per second avg: %u.%03u",
uptime,
(int) thread_count, (ulong) thd->query_id,
......
......@@ -68,7 +68,7 @@ I_P_List <TDC_element,
I_P_List_null_counter,
I_P_List_fast_push_back<TDC_element> > unused_shares;
static int64 tdc_version; /* Increments on each reload */
static tdc_version_t tdc_version; /* Increments on each reload */
static bool tdc_inited;
......@@ -945,7 +945,7 @@ void tdc_release_share(TABLE_SHARE *share)
mysql_mutex_lock(&share->tdc->LOCK_table_share);
DBUG_PRINT("enter",
("share: %p table: %s.%s ref_count: %u version: %lu",
("share: %p table: %s.%s ref_count: %u version: %lld",
share, share->db.str, share->table_name.str,
share->tdc->ref_count, share->tdc->version));
DBUG_ASSERT(share->tdc->ref_count);
......@@ -1181,8 +1181,7 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
*/
int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name,
ulong wait_timeout, uint deadlock_weight,
ulong refresh_version)
ulong wait_timeout, uint deadlock_weight, tdc_version_t refresh_version)
{
TDC_element *element;
......@@ -1201,16 +1200,16 @@ int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name,
}
ulong tdc_refresh_version(void)
tdc_version_t tdc_refresh_version(void)
{
return (ulong)my_atomic_load64_explicit(&tdc_version, MY_MEMORY_ORDER_RELAXED);
return (tdc_version_t)my_atomic_load64_explicit(&tdc_version, MY_MEMORY_ORDER_RELAXED);
}
ulong tdc_increment_refresh_version(void)
tdc_version_t tdc_increment_refresh_version(void)
{
ulong v= (ulong)my_atomic_add64_explicit(&tdc_version, 1, MY_MEMORY_ORDER_RELAXED);
DBUG_PRINT("tcache", ("incremented global refresh_version to: %lu", v));
tdc_version_t v= (tdc_version_t)my_atomic_add64_explicit(&tdc_version, 1, MY_MEMORY_ORDER_RELAXED);
DBUG_PRINT("tcache", ("incremented global refresh_version to: %lld", v));
return v + 1;
}
......
......@@ -26,12 +26,14 @@ struct Share_free_tables
char pad[CPU_LEVEL1_DCACHE_LINESIZE];
};
typedef int64 tdc_version_t;
#define TDC_VERSION_MAX INT_MAX64
struct TDC_element
{
uchar m_key[NAME_LEN + 1 + NAME_LEN + 1];
uint m_key_length;
ulong version;
tdc_version_t version;
bool flushed;
TABLE_SHARE *share;
......@@ -84,12 +86,14 @@ extern void tdc_release_share(TABLE_SHARE *share);
extern bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
const char *db, const char *table_name,
bool kill_delayed_threads);
extern int tdc_wait_for_old_version(THD *thd, const char *db,
const char *table_name,
ulong wait_timeout, uint deadlock_weight,
ulong refresh_version= ULONG_MAX);
extern ulong tdc_refresh_version(void);
extern ulong tdc_increment_refresh_version(void);
tdc_version_t refresh_version= TDC_VERSION_MAX);
extern tdc_version_t tdc_refresh_version(void);
extern tdc_version_t tdc_increment_refresh_version(void);
extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
bool no_dups= false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment