Eliminate warnings noticed by VC7. This includes fixing my_mmap() on

Windows to call CreateFileMapping() with correct arguments, and
propogating the introduction of query_id_t to everywhere query ids are
passed around. (Bug #8826)


libmysql/libmysql.c:
  Make implicit cast explicit
myisam/mi_open.c:
  Make cast of value to smaller data size explicit
myisam/mi_packrec.c:
  Cast file size (my_off_t) to size_t for mmap
mysys/my_mmap.c:
  Fix Windows version of my_mmap() to use the right parameters
  for call to CreateFileMapping()
sql/field.cc:
  Use temporary value of correct type
sql/field.h:
  Use query_id_t for query_id value
sql/ha_berkeley.cc:
  Fix flag check
sql/ha_innodb.h:
  Use query_id_t for query_id value
sql/handler.cc:
  Explain opt_using_transactions calculation, and add cast
sql/handler.h:
  Fix forward declaration of COND
sql/item.cc:
  Fix val_bool() tests of val_int() to avoid implicit cast
sql/item_cmpfunc.cc:
  Fix typo in switch label
sql/item_func.cc:
  Make implicit cast explicit
sql/item_strfunc.cc:
  Now that query_id is a query_id_t, need to cast it to a ulong here
sql/item_subselect.cc:
  Fix test of value
sql/log.cc:
  Cast my_off_t used for file size to size_t for memory allocation
  Also cast my_off_t when using it to calculate the number of pages for TC log
  Cast total_ha_2pc to uchar when saving it
sql/mysql_priv.h:
  Move up query_id definition so it can be used more widely
sql/opt_range.cc:
  Add unused delete operator to prevent compiler warning
sql/set_var.cc:
  Cast value for max_user_connections
sql/sql_cache.cc:
  Remove unused label
sql/sql_class.h:
  Fix query id values to be of type query_id_t
sql/sql_db.cc:
  Move variable only used inside #ifdef within the #ifdef
sql/sql_help.cc:
  Remove unused label
sql/sql_insert.cc:
  Use query_id_t for query id values
sql/sql_lex.h:
  Add unused delete operator to prevent compiler warning
sql/sql_select.cc:
  Remove unused variable
  Make cast of value explicit
sql/sql_select.h:
  Use query_id_t for query id values
sql/sql_table.cc:
  Make comparison to function pointer explicit
sql/sql_update.cc:
  Use query_id_t for query id values
sql/table.h:
  Use query_id_t for query id values
strings/ctype-simple.c:
  Add cast of long value to (char) in expression
strings/ctype-ucs2.c:
  Add cast of long value to (char) in expression
strings/ctype-utf8.c:
  Make cast to smaller size explicit
This commit is contained in:
unknown 2005-03-18 16:12:25 -08:00
parent 1cc46f6786
commit 892a6138ff
33 changed files with 66 additions and 56 deletions

View File

@ -3608,7 +3608,7 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
if (is_unsigned)
data= ulonglong2double(value);
else
data= value;
data= (double)value;
doublestore(buffer, data);
*param->error= is_unsigned ?
((ulonglong) value) != ((ulonglong) (*(double*) buffer)) :

View File

@ -1090,10 +1090,10 @@ char *mi_keyseg_read(char *ptr, HA_KEYSEG *keyseg)
keyseg->null_pos = mi_uint4korr(ptr); ptr +=4;
keyseg->charset=0; /* Will be filled in later */
if (keyseg->null_bit)
keyseg->bit_pos= keyseg->null_pos + (keyseg->null_bit == 7);
keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == 7));
else
{
keyseg->bit_pos= keyseg->null_pos;
keyseg->bit_pos= (uint16)keyseg->null_pos;
keyseg->null_pos= 0;
}
return ptr;

View File

@ -1212,7 +1212,7 @@ my_bool _mi_memmap_file(MI_INFO *info)
DBUG_RETURN(0);
}
file_map=(byte*)
my_mmap(0,share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN,PROT_READ,
my_mmap(0,(size_t)(share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN),PROT_READ,
MAP_SHARED | MAP_NORESERVE,info->dfile,0L);
if (file_map == (byte*) MAP_FAILED)
{

View File

@ -46,11 +46,14 @@ void *my_mmap(void *addr, size_t len, int prot,
DWORD flProtect=0;
HANDLE hFileMap;
LPVOID ptr;
HANDLE hFile= (HANDLE)_get_osfhandle(fd);
if (hFile == INVALID_HANDLE_VALUE)
return MAP_FAILED;
flProtect|=SEC_COMMIT;
hFileMap=CreateFileMapping(fd, NULL, &mmap_security_attributes,
PAGE_READWRITE, 0, len, 0);
hFileMap=CreateFileMapping(hFile, &mmap_security_attributes,
PAGE_READWRITE, 0, len, NULL);
if (hFileMap == 0)
return MAP_FAILED;

View File

@ -2451,14 +2451,15 @@ static bool test_if_minus(CHARSET_INFO *cs,
int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{
ulong tmp_scan;
longlong tmp;
long store_tmp;
int error;
char *end;
tmp= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES);
len-= tmp;
from+= tmp;
tmp_scan= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES);
len-= tmp_scan;
from+= tmp_scan;
end= (char*) from+len;
tmp= cs->cset->my_strtoll10(cs, from, &end, &error);

View File

@ -49,7 +49,7 @@ public:
struct st_table *orig_table; // Pointer to original table
const char **table_name, *field_name;
LEX_STRING comment;
ulong query_id; // For quick test of used fields
query_id_t query_id; // For quick test of used fields
/* Field is part of the following keys */
key_map key_start,part_of_key,part_of_sortkey;
/*

View File

@ -1548,7 +1548,7 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
do_prev= 1;
}
if (key_len == key_info->key_length &&
!table->key_info[active_index].flags & HA_END_SPACE_KEY)
!(table->key_info[active_index].flags & HA_END_SPACE_KEY))
{
if (find_flag == HA_READ_AFTER_KEY)
key_info->handler.bdb_return_if_eq= 1;
@ -1646,7 +1646,7 @@ int ha_berkeley::index_next_same(byte * buf, const byte *key, uint keylen)
&LOCK_status);
bzero((char*) &row,sizeof(row));
if (keylen == table->key_info[active_index].key_length &&
!table->key_info[active_index].flags & HA_END_SPACE_KEY)
!(table->key_info[active_index].flags & HA_END_SPACE_KEY))
error=read_row(cursor->c_get(cursor, &last_key, &row, DB_NEXT_DUP),
(char*) buf, active_index, &row, &last_key, 1);
else

View File

@ -47,7 +47,7 @@ class ha_innobase: public handler
THD* user_thd; /* the thread handle of the user
currently using the handle; this is
set in external_lock function */
ulong last_query_id; /* the latest query id where the
query_id_t last_query_id; /* the latest query id where the
handle was used */
THR_LOCK_DATA lock;
INNOBASE_SHARE *share;

View File

@ -416,7 +416,12 @@ int ha_init()
}
#endif
DBUG_ASSERT(total_ha < MAX_HA);
opt_using_transactions= total_ha>opt_bin_log;
/*
Check if there is a transaction-capable storage engine besides the
binary log (which is considered a transaction-capable storage engine in
counting total_ha)
*/
opt_using_transactions= total_ha>(ulong)opt_bin_log;
savepoint_alloc_size+= sizeof(SAVEPOINT);
return error;
}

View File

@ -379,7 +379,7 @@ typedef struct st_savepoint SAVEPOINT;
extern ulong savepoint_alloc_size;
/* Forward declaration for condition pushdown to storage engine */
typedef struct Item COND;
typedef class Item COND;
typedef struct st_ha_check_opt
{

View File

@ -178,7 +178,7 @@ bool Item::val_bool()
{
switch(result_type()) {
case INT_RESULT:
return val_int();
return val_int() != 0;
case DECIMAL_RESULT:
{
my_decimal decimal_value;
@ -1217,7 +1217,7 @@ bool Item_field::val_bool_result()
return FALSE;
switch (result_field->result_type()) {
case INT_RESULT:
return result_field->val_int();
return result_field->val_int() != 0;
case DECIMAL_RESULT:
{
my_decimal decimal_value;
@ -3946,7 +3946,7 @@ bool Item_ref::val_bool_result()
return 0;
switch (result_field->result_type()) {
case INT_RESULT:
return result_field->val_int();
return result_field->val_int() != 0;
case DECIMAL_RESULT:
{
my_decimal decimal_value;

View File

@ -1720,7 +1720,7 @@ void Item_func_coalesce::fix_length_and_dec()
decimals= 0;
break;
case ROW_RESULT:
defaullt:
default:
DBUG_ASSERT(0);
}
}

View File

@ -882,7 +882,7 @@ my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value)
}
case REAL_RESULT:
{
double result= int_op();
double result= (double)int_op();
double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
break;
}

View File

@ -2888,7 +2888,7 @@ String *Item_func_uuid::val_str(String *str)
with a clock_seq value (initialized random below), we use a separate
randominit() here
*/
randominit(&uuid_rand, tmp + (ulong) thd, tmp + query_id);
randominit(&uuid_rand, tmp + (ulong) thd, tmp + (ulong)query_id);
for (i=0; i < (int)sizeof(mac); i++)
mac[i]=(uchar)(my_rnd(&uuid_rand)*255);
}

View File

@ -675,7 +675,7 @@ bool Item_exists_subselect::val_bool()
reset();
return 0;
}
return value;
return value != 0;
}

View File

@ -2505,7 +2505,7 @@ int TC_LOG_MMAP::open(const char *opt_name)
goto err;
}
data= (uchar *)my_mmap(0, file_length, PROT_READ|PROT_WRITE,
data= (uchar *)my_mmap(0, (size_t)file_length, PROT_READ|PROT_WRITE,
MAP_NOSYNC|MAP_SHARED, fd, 0);
if (data == MAP_FAILED)
{
@ -2514,7 +2514,7 @@ int TC_LOG_MMAP::open(const char *opt_name)
}
inited=2;
npages=file_length/tc_log_page_size;
npages=(uint)file_length/tc_log_page_size;
DBUG_ASSERT(npages >= 3); // to guarantee non-empty pool
if (!(pages=(PAGE *)my_malloc(npages*sizeof(PAGE), MYF(MY_WME|MY_ZEROFILL))))
goto err;
@ -2540,7 +2540,7 @@ int TC_LOG_MMAP::open(const char *opt_name)
goto err;
memcpy(data, tc_log_magic, sizeof(tc_log_magic));
data[sizeof(tc_log_magic)]= total_ha_2pc;
data[sizeof(tc_log_magic)]= (uchar)total_ha_2pc;
my_msync(fd, data, tc_log_page_size, MS_SYNC);
inited=5;
@ -2794,7 +2794,7 @@ void TC_LOG_MMAP::close()
case 3:
my_free((gptr)pages, MYF(0));
case 2:
my_munmap(data, file_length);
my_munmap(data, (size_t)file_length);
case 1:
my_close(fd, MYF(0));
}
@ -2842,7 +2842,7 @@ int TC_LOG_MMAP::recover()
goto err2;
hash_free(&xids);
bzero(data, file_length);
bzero(data, (size_t)file_length);
return 0;
err2:

View File

@ -44,6 +44,13 @@ typedef ulonglong table_map; /* Used for table bits in join */
typedef Bitmap<64> key_map; /* Used for finding keys */
typedef ulong key_part_map; /* Used for finding key parts */
/* query_id */
typedef ulonglong query_id_t;
extern query_id_t query_id;
/* increment query_id and return it. */
inline query_id_t next_query_id() { return query_id++; }
/* useful constants */
extern const key_map key_map_empty;
extern const key_map key_map_full;
@ -1300,14 +1307,6 @@ SQL_CRYPT *get_crypt_for_frm(void);
#include "sql_view.h"
/* query_id */
typedef ulonglong query_id_t;
extern query_id_t query_id;
/* increment query_id and return it. */
inline query_id_t next_query_id() { return query_id++; }
/* Some inline functions for more speed */
inline bool add_item_to_list(THD *thd, Item *item)

View File

@ -1407,6 +1407,7 @@ public:
static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); }
static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* Never called */ }
};
class TRP_ROR_INTERSECT;

View File

@ -2652,7 +2652,7 @@ bool sys_var_max_user_conn::update(THD *thd, set_var *var)
{
DBUG_ASSERT(var->type == OPT_GLOBAL);
pthread_mutex_lock(&LOCK_global_system_variables);
max_user_connections= var->save_result.ulonglong_value;
max_user_connections= (uint)var->save_result.ulonglong_value;
pthread_mutex_unlock(&LOCK_global_system_variables);
return 0;
}

View File

@ -2225,7 +2225,6 @@ my_bool Query_cache::register_all_tables(Query_cache_block *block,
n= register_tables_from_list(tables_used, 0, block_table);
err:
if (n)
{
DBUG_PRINT("qcache", ("failed at table %d", (int) n));

View File

@ -1168,8 +1168,8 @@ public:
from table are necessary for this select, to check if it's necessary to
update auto-updatable fields (like auto_increment and timestamp).
*/
ulong query_id;
ulong warn_id, version, options, thread_id, col_access;
query_id_t query_id, warn_id;
ulong version, options, thread_id, col_access;
/* Statement id is thread-wide. This counter is used to generate ids */
ulong statement_id_counter;
@ -1797,7 +1797,8 @@ class user_var_entry
public:
LEX_STRING name;
char *value;
ulong length, update_query_id, used_query_id;
ulong length;
query_id_t update_query_id, used_query_id;
Item_result type;
double val_real(my_bool *null_value);

View File

@ -875,12 +875,13 @@ err:
static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error)
{
char tmp_path[FN_REFLEN], tmp2_path[FN_REFLEN], *pos;
char tmp_path[FN_REFLEN], *pos;
char *path= tmp_path;
DBUG_ENTER("rm_dir_w_symlink");
unpack_filename(tmp_path, org_path);
#ifdef HAVE_READLINK
int error;
char tmp2_path[FN_REFLEN];
/* Remove end FN_LIBCHAR as this causes problem on Linux in readlink */
pos= strend(path);

View File

@ -763,7 +763,6 @@ bool mysqld_help(THD *thd, const char *mask)
}
send_eof(thd);
end:
DBUG_RETURN(FALSE);
error:
DBUG_RETURN(TRUE);

View File

@ -31,7 +31,7 @@ static void end_delayed_insert(THD *thd);
extern "C" pthread_handler_decl(handle_delayed_insert,arg);
static void unlink_blobs(register TABLE *table);
#endif
static bool check_view_insertability(TABLE_LIST *view, ulong query_id);
static bool check_view_insertability(TABLE_LIST *view, query_id_t query_id);
/* Define to force use of my_malloc() if the allocated memory block is big */
@ -538,7 +538,7 @@ abort:
TRUE - can't be used for insert
*/
static bool check_view_insertability(TABLE_LIST *view, ulong query_id)
static bool check_view_insertability(TABLE_LIST *view, query_id_t query_id)
{
uint num= view->view->select_lex.item_list.elements;
TABLE *table= view->table;
@ -546,7 +546,7 @@ static bool check_view_insertability(TABLE_LIST *view, ulong query_id)
*trans_end= trans_start + num;
Field_translator *trans;
Field **field_ptr= table->field;
ulong other_query_id= query_id - 1;
query_id_t other_query_id= query_id - 1;
DBUG_ENTER("check_key_in_view");
DBUG_ASSERT(view->table != 0 && view->field_translation != 0);

View File

@ -892,6 +892,8 @@ struct st_lex_local: public st_lex
}
static void operator delete(void *ptr,size_t size)
{ TRASH(ptr, size); }
static void operator delete(void *ptr, MEM_ROOT *mem_root)
{ /* Never called */ }
};
void lex_init(void);

View File

@ -6646,7 +6646,6 @@ static COND *build_equal_items(THD *thd, COND *cond,
{
if (table->on_expr)
{
Item *expr;
List<TABLE_LIST> *join_list= table->nested_join ?
&table->nested_join->join_list : NULL;
/*
@ -8545,7 +8544,7 @@ static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
seg->type=
((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ?
HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2);
seg->bit_start= field->pack_length() - table->s->blob_ptr_size;
seg->bit_start= (uint8)(field->pack_length() - table->s->blob_ptr_size);
seg->flag= HA_BLOB_PART;
seg->length=0; // Whole blob in unique constraint
}

View File

@ -351,7 +351,7 @@ class Cursor: public Sql_alloc, public Item_arena
MYSQL_LOCK *lock;
TABLE *derived_tables;
/* List of items created during execution */
ulong query_id;
query_id_t query_id;
public:
select_send result;

View File

@ -2052,7 +2052,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->no_warnings_for_error= 0;
table->next_global= next_global_table;
/* if view are unsupported */
if (table->view && !view_operator_func)
if (table->view && view_operator_func == NULL)
{
result_code= HA_ADMIN_NOT_IMPLEMENTED;
goto send_result;

View File

@ -29,7 +29,7 @@ static bool safe_update_on_fly(JOIN_TAB *join_tab, List<Item> *fields);
/* Return 0 if row hasn't changed */
static bool compare_record(TABLE *table, ulong query_id)
static bool compare_record(TABLE *table, query_id_t query_id)
{
if (table->s->blob_fields + table->s->varchar_fields == 0)
return cmp_record(table,record[1]);
@ -125,7 +125,7 @@ int mysql_update(THD *thd,
uint want_privilege;
#endif
uint table_count= 0;
ulong query_id=thd->query_id, timestamp_query_id;
query_id_t query_id=thd->query_id, timestamp_query_id;
ha_rows updated, found;
key_map old_used_keys;
TABLE *table;

View File

@ -188,7 +188,7 @@ struct st_table {
ORDER *group;
const char *alias; /* alias or table name */
uchar *null_flags;
ulong query_id;
query_id_t query_id;
ha_rows quick_rows[MAX_KEY];
key_part_map const_key_parts[MAX_KEY];

View File

@ -894,7 +894,7 @@ int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)),
while (long_val != 0)
{
long quo= long_val/10;
*--p = '0' + (long_val - quo*10);
*--p = '0' + (char)(long_val - quo*10);
long_val= quo;
}

View File

@ -1049,7 +1049,7 @@ int my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)),
while (long_val != 0)
{
long quo= long_val/10;
*--p = '0' + (long_val - quo*10);
*--p = '0' + (char)(long_val - quo*10);
long_val= quo;
}

View File

@ -2264,8 +2264,8 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs,
plane=(wc>>8) & 0xFF;
wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc;
*dst++= wc >> 8;
*dst++= wc & 0xFF;
*dst++= (uchar)(wc >> 8);
*dst++= (uchar)(wc & 0xFF);
}