Commit 3846dff8 authored by unknown's avatar unknown

some casts and simple fixes to fix compile errors in Visual 2005


sql/log_event.cc:
  some casts to make Visual 2005 happy
sql/log_event.h:
  actually return a bool expression instead of assuming a pointer 
  expression is boolean
sql/sql_class.cc:
  some casts to make Visual 2005 happy
sql/handler.cc:
  actually return 0 as the function docs say
parent 565e729e
......@@ -1178,6 +1178,7 @@ int ha_release_temporary_latches(THD *thd)
#ifdef WITH_INNOBASE_STORAGE_ENGINE
innobase_release_temporary_latches(thd);
#endif
return 0;
}
......
......@@ -5039,7 +5039,8 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
m_table(tbl_arg),
m_table_id(tid),
m_width(tbl_arg->s->fields),
m_rows_buf(my_malloc(opt_binlog_rows_event_max_size * sizeof(*m_rows_buf), MYF(MY_WME))),
m_rows_buf((byte*)my_malloc(opt_binlog_rows_event_max_size *
sizeof(*m_rows_buf), MYF(MY_WME))),
m_rows_cur(m_rows_buf),
m_rows_end(m_rows_buf + opt_binlog_rows_event_max_size),
m_flags(0)
......@@ -5096,18 +5097,20 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
m_flags= uint2korr(post_start);
byte const *const var_start= buf + common_header_len + post_header_len;
byte const *const var_start= (const byte *const)(buf + common_header_len +
post_header_len);
byte const *const ptr_width= var_start;
byte const *const ptr_after_width= my_vle_decode(&m_width, ptr_width);
const uint byte_count= (m_width + 7) / 8;
const char* const ptr_rows_data= var_start + byte_count + 1;
const char* const ptr_rows_data=
(const char* const)var_start + byte_count + 1;
my_size_t const data_size= event_len - (ptr_rows_data - buf);
DBUG_PRINT("info",("m_table_id=%lu, m_flags=%d, m_width=%u, data_size=%lu",
m_table_id, m_flags, m_width, data_size));
m_rows_buf= my_malloc(data_size, MYF(MY_WME));
m_rows_buf= (byte*)my_malloc(data_size, MYF(MY_WME));
if (likely((bool)m_rows_buf))
{
/* if bitmap_init fails, catched in is_valid() */
......@@ -5131,7 +5134,7 @@ Rows_log_event::~Rows_log_event()
if (m_cols.bitmap == m_bitbuf) // no my_malloc happened
m_cols.bitmap= 0; // so no my_free in bitmap_free
bitmap_free(&m_cols); // To pair with bitmap_init().
my_free(m_rows_buf, MYF(MY_ALLOW_ZERO_PTR));
my_free((gptr)m_rows_buf, MYF(MY_ALLOW_ZERO_PTR));
}
#ifndef MYSQL_CLIENT
......@@ -5145,7 +5148,7 @@ int Rows_log_event::do_add_row_data(byte *const row_data,
*/
DBUG_ENTER("Rows_log_event::do_add_row_data(byte *data, my_size_t length)");
DBUG_PRINT("enter", ("row_data= %p, length= %lu", row_data, length));
DBUG_DUMP("row_data", row_data, min(length, 32));
DBUG_DUMP("row_data", (const char*)row_data, min(length, 32));
DBUG_ASSERT(m_rows_buf <= m_rows_cur);
DBUG_ASSERT(m_rows_buf < m_rows_end);
......@@ -5160,7 +5163,8 @@ int Rows_log_event::do_add_row_data(byte *const row_data,
old_alloc + block_size * (length / block_size + block_size - 1);
my_ptrdiff_t const cur_size= m_rows_cur - m_rows_buf;
byte* const new_buf= my_realloc(m_rows_buf, new_alloc, MYF(MY_WME));
byte* const new_buf=
(byte*)my_realloc((gptr)m_rows_buf, new_alloc, MYF(MY_WME));
if (unlikely(!new_buf))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
......@@ -5199,7 +5203,7 @@ static char const *unpack_row(TABLE *table,
MY_BITMAP *write_set= table->file->write_set;
my_size_t const n_null_bytes= table->s->null_bytes;
my_ptrdiff_t const offset= record - (byte*) table->record[0];
my_ptrdiff_t const offset= (byte*)record - (byte*) table->record[0];
memcpy(record, row, n_null_bytes);
char const *ptr= row + n_null_bytes;
......@@ -5226,7 +5230,7 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
DBUG_ENTER("Rows_log_event::exec_event(st_relay_log_info*)");
DBUG_ASSERT(m_table_id != ULONG_MAX);
int error= 0;
char const *row_start= m_rows_buf;
char const *row_start= (char const *)m_rows_buf;
TABLE* table= rli->m_table_map.get_table(m_table_id);
/*
......@@ -5364,10 +5368,10 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
DBUG_ASSERT(sizeof(thd->options) == sizeof(OPTION_RELAXED_UNIQUE_CHECKS));
error= do_before_row_operations(table);
while (error == 0 && row_start < m_rows_end) {
while (error == 0 && row_start < (const char*)m_rows_end) {
char const *row_end= do_prepare_row(thd, table, row_start);
DBUG_ASSERT(row_end != NULL); // cannot happen
DBUG_ASSERT(row_end <= m_rows_end);
DBUG_ASSERT(row_end <= (const char*)m_rows_end);
/* in_use can have been set to NULL in close_tables_for_reopen */
THD* old_thd= table->in_use;
......@@ -5563,10 +5567,10 @@ bool Rows_log_event::write_data_body(IO_CACHE*file)
byte sbuf[my_vle_sizeof(m_width)];
my_ptrdiff_t const data_size= m_rows_cur - m_rows_buf;
char *const sbuf_end= my_vle_encode(sbuf, sizeof(sbuf), m_width);
DBUG_ASSERT(static_cast<my_size_t>(sbuf_end - sbuf) <= sizeof(sbuf));
char *const sbuf_end= (char *const)my_vle_encode(sbuf, sizeof(sbuf), m_width);
DBUG_ASSERT(static_cast<my_size_t>(sbuf_end - (char *const)sbuf) <= sizeof(sbuf));
return (my_b_safe_write(file, sbuf, sbuf_end - sbuf) ||
return (my_b_safe_write(file, sbuf, sbuf_end - (char *const)sbuf) ||
my_b_safe_write(file, reinterpret_cast<byte*>(m_cols.bitmap),
no_bytes_in_map(&m_cols)) ||
my_b_safe_write(file, m_rows_buf, data_size));
......@@ -5684,7 +5688,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
const char *const vpart= buf + common_header_len + post_header_len;
/* Extract the length of the various parts from the buffer */
byte const* const ptr_dblen= vpart + 0;
byte const* const ptr_dblen= (byte const* const)vpart + 0;
m_dblen= *(unsigned char*) ptr_dblen;
/* Length of database name + counter + terminating null */
......@@ -5696,8 +5700,9 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
byte const* const ptr_after_colcnt= my_vle_decode(&m_colcnt, ptr_colcnt);
DBUG_PRINT("info",("m_dblen=%d off=%d m_tbllen=%d off=%d m_colcnt=%d off=%d",
m_dblen, ptr_dblen-vpart, m_tbllen, ptr_tbllen-vpart,
m_colcnt, ptr_colcnt-vpart));
m_dblen, ptr_dblen-(const byte* const)vpart,
m_tbllen, ptr_tbllen-(const byte* const)vpart,
m_colcnt, ptr_colcnt-(const byte* const)vpart));
/* Allocate mem for all fields in one go. If fails, catched in is_valid() */
m_memory= my_multi_malloc(MYF(MY_WME),
......@@ -5709,8 +5714,8 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
if (m_memory)
{
/* Copy the different parts into their memory */
strncpy(const_cast<char*>(m_dbnam), ptr_dblen + 1, m_dblen + 1);
strncpy(const_cast<char*>(m_tblnam), ptr_tbllen + 1, m_tbllen + 1);
strncpy(const_cast<char*>(m_dbnam), (const char*)ptr_dblen + 1, m_dblen + 1);
strncpy(const_cast<char*>(m_tblnam), (const char*)ptr_tbllen + 1, m_tbllen + 1);
memcpy(m_coltype, ptr_after_colcnt, m_colcnt);
}
......@@ -6008,12 +6013,12 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file)
byte *const cbuf_end= my_vle_encode(cbuf, sizeof(cbuf), m_colcnt);
DBUG_ASSERT(static_cast<my_size_t>(cbuf_end - cbuf) <= sizeof(cbuf));
return (my_b_safe_write(file, dbuf, sizeof(dbuf)) ||
return (my_b_safe_write(file, (const byte*)dbuf, sizeof(dbuf)) ||
my_b_safe_write(file, m_dbnam, m_dblen+1) ||
my_b_safe_write(file, tbuf, sizeof(tbuf)) ||
my_b_safe_write(file, m_tblnam, m_tbllen+1) ||
my_b_safe_write(file, (const byte*)m_tblnam, m_tbllen+1) ||
my_b_safe_write(file, cbuf, cbuf_end - cbuf) ||
my_b_safe_write(file, reinterpret_cast<char*>(m_coltype), m_colcnt));
my_b_safe_write(file, reinterpret_cast<const byte*>(m_coltype), m_colcnt));
}
#endif
......@@ -6141,7 +6146,7 @@ char const *Write_rows_log_event::do_prepare_row(THD *thd, TABLE *table,
*/
DBUG_ASSERT(table->s->fields >= m_width);
DBUG_ASSERT(ptr);
ptr= unpack_row(table, table->record[0], ptr, &m_cols);
ptr= unpack_row(table, (char*)table->record[0], ptr, &m_cols);
return ptr;
}
......@@ -6248,8 +6253,9 @@ replace_record(THD *thd, TABLE *table)
return ENOMEM;
}
key_copy(key.get(), table->record[0], table->key_info + keynum, 0);
error= table->file->index_read_idx(table->record[1], keynum, key.get(),
key_copy((byte*)key.get(), table->record[0], table->key_info + keynum, 0);
error= table->file->index_read_idx(table->record[1], keynum,
(const byte*)key.get(),
table->key_info[keynum].key_length,
HA_READ_KEY_EXACT);
if (error)
......@@ -6322,7 +6328,8 @@ static int record_compare(TABLE *table, byte const *a, byte const *b)
for (my_size_t i= 0 ; i < table->s->fields ; ++i)
{
uint const off= table->field[i]->offset();
uint const res= table->field[i]->cmp_binary(a + off, b + off);
uint const res= table->field[i]->cmp_binary((const char*)a + off,
(const char*)b + off);
if (res != 0) {
return res;
}
......@@ -6496,7 +6503,8 @@ int Delete_rows_log_event::do_before_row_operations(TABLE *table)
}
else
{
m_memory= m_search_record= my_malloc(table->s->reclength, MYF(MY_WME));
m_search_record= (byte*)my_malloc(table->s->reclength, MYF(MY_WME));
m_memory= (gptr)m_search_record;
m_key= NULL;
}
if (!m_memory)
......@@ -6522,7 +6530,9 @@ int Delete_rows_log_event::do_after_row_operations(TABLE *table, int error)
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
table->file->ha_index_or_rnd_end();
my_free(m_memory, MYF(MY_ALLOW_ZERO_PTR)); // Free for multi_malloc
m_memory= m_search_record= m_key= NULL;
m_memory= NULL;
m_search_record= NULL;
m_key= NULL;
return error;
}
......@@ -6539,7 +6549,7 @@ char const *Delete_rows_log_event::do_prepare_row(THD *thd, TABLE *table,
DBUG_ASSERT(table->s->fields >= m_width);
DBUG_ASSERT(ptr != NULL);
ptr= unpack_row(table, table->record[0], ptr, &m_cols);
ptr= unpack_row(table, (char*)table->record[0], ptr, &m_cols);
/*
If we will access rows using the random access method, m_key will
......@@ -6653,7 +6663,8 @@ int Update_rows_log_event::do_before_row_operations(TABLE *table)
}
else
{
m_memory= m_search_record= my_malloc(table->s->reclength, MYF(MY_WME));
m_search_record= (byte*)my_malloc(table->s->reclength, MYF(MY_WME));
m_memory= (gptr)m_search_record;
m_key= NULL;
}
if (!m_memory)
......@@ -6680,7 +6691,9 @@ int Update_rows_log_event::do_after_row_operations(TABLE *table, int error)
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/
table->file->ha_index_or_rnd_end();
my_free(m_memory, MYF(MY_ALLOW_ZERO_PTR));
m_memory= m_search_record= m_key= NULL;
m_memory= NULL;
m_search_record= NULL;
m_key= NULL;
return error;
}
......@@ -6697,10 +6710,10 @@ char const *Update_rows_log_event::do_prepare_row(THD *thd, TABLE *table,
DBUG_ASSERT(table->s->fields >= m_width);
/* record[0] is the before image for the update */
ptr= unpack_row(table, table->record[0], ptr, &m_cols);
ptr= unpack_row(table, (char*)table->record[0], ptr, &m_cols);
DBUG_ASSERT(ptr != NULL);
/* record[1] is the after image for the update */
ptr= unpack_row(table, table->record[1], ptr, &m_cols);
ptr= unpack_row(table, (char*)table->record[1], ptr, &m_cols);
/*
If we will access rows using the random access method, m_key will
......
......@@ -1701,7 +1701,7 @@ public:
~Table_map_log_event();
virtual Log_event_type get_type_code() { return TABLE_MAP_EVENT; }
virtual bool is_valid() const { return m_memory; /* we check malloc */ }
virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
virtual int get_data_size() { return m_data_size; }
#ifndef MYSQL_CLIENT
......
......@@ -2322,7 +2322,7 @@ my_size_t THD::pack_row(TABLE *table, MY_BITMAP const* cols, byte *row_data,
for (int i= 0 ; field ; i++, p_field++, field= *p_field)
{
if (bitmap_is_set(cols,i))
ptr= field->pack(ptr, field->ptr + offset);
ptr= (byte*)field->pack(ptr, field->ptr + offset);
}
/*
......@@ -2398,7 +2398,7 @@ int THD::binlog_update_row(TABLE* table, bool is_trans,
}
else
{
if (unlikely(!(row_data= my_multi_malloc(MYF(MY_WME),
if (unlikely(!(row_data= (byte*)my_multi_malloc(MYF(MY_WME),
&before_row, before_maxlen,
&after_row, after_maxlen,
NULL))))
......@@ -2420,7 +2420,7 @@ int THD::binlog_update_row(TABLE* table, bool is_trans,
if (!table->write_row_record)
{
/* add_row_data copies row_data to internal buffer */
my_free(row_data, MYF(MY_WME));
my_free((gptr)row_data, MYF(MY_WME));
}
return error;
......@@ -2439,7 +2439,7 @@ int THD::binlog_delete_row(TABLE* table, bool is_trans,
bool error= 0;
my_size_t const max_len= max_row_length(table, record);
byte *row_data= table->write_row_record;
if (!row_data && unlikely(!(row_data= my_malloc(max_len, MYF(MY_WME)))))
if (!row_data && unlikely(!(row_data= (byte*)my_malloc(max_len, MYF(MY_WME)))))
return HA_ERR_OUT_OF_MEM;
my_size_t const len= pack_row(table, cols, row_data, record);
......@@ -2451,7 +2451,7 @@ int THD::binlog_delete_row(TABLE* table, bool is_trans,
/* add_row_data copies row_data */
if (table->write_row_record == 0)
my_free(row_data, MYF(MY_WME));
my_free((gptr)row_data, MYF(MY_WME));
return error;
}
......
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