summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc178
1 files changed, 78 insertions, 100 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 018425099bb..9dbc79344a9 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -71,11 +71,11 @@ template class List_iterator<Alter_column>;
** User variables
****************************************************************************/
-extern "C" byte *get_var_key(user_var_entry *entry, uint *length,
- my_bool not_used __attribute__((unused)))
+extern "C" uchar *get_var_key(user_var_entry *entry, size_t *length,
+ my_bool not_used __attribute__((unused)))
{
- *length=(uint) entry->name.length;
- return (byte*) entry->name.str;
+ *length= entry->name.length;
+ return (uchar*) entry->name.str;
}
extern "C" void free_user_var(user_var_entry *entry)
@@ -679,7 +679,7 @@ THD::~THD()
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
{
- ulong *end= (ulong*) ((byte*) to_var +
+ ulong *end= (ulong*) ((uchar*) to_var +
offsetof(STATUS_VAR, last_system_status_var) +
sizeof(ulong));
ulong *to= (ulong*) to_var, *from= (ulong*) from_var;
@@ -704,7 +704,7 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
STATUS_VAR *dec_var)
{
- ulong *end= (ulong*) ((byte*) to_var + offsetof(STATUS_VAR,
+ ulong *end= (ulong*) ((uchar*) to_var + offsetof(STATUS_VAR,
last_system_status_var) +
sizeof(ulong));
ulong *to= (ulong*) to_var, *from= (ulong*) from_var, *dec= (ulong*) dec_var;
@@ -875,9 +875,9 @@ bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
CHARSET_INFO *from_cs)
{
DBUG_ENTER("convert_string");
- size_s new_length= to_cs->mbmaxlen * from_length;
+ size_t new_length= to_cs->mbmaxlen * from_length;
uint dummy_errors;
- if (!(to->str= alloc(new_length+1)))
+ if (!(to->str= (char*) alloc(new_length+1)))
{
to->length= 0; // Safety fix
DBUG_RETURN(1); // EOM
@@ -961,7 +961,7 @@ void THD::add_changed_table(TABLE *table)
DBUG_ASSERT((options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
table->file->has_transactions());
add_changed_table(table->s->table_cache_key.str,
- table->s->table_cache_key.length);
+ (long) table->s->table_cache_key.length);
DBUG_VOID_RETURN;
}
@@ -1021,8 +1021,7 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length)
return 0;
}
- new_table->key = (char *) (((byte*)new_table)+
- ALIGN_SIZE(sizeof(CHANGED_TABLE_LIST)));
+ new_table->key= ((char*)new_table)+ ALIGN_SIZE(sizeof(CHANGED_TABLE_LIST));
new_table->next = 0;
new_table->key_length = key_length;
::memcpy(new_table->key, key, key_length);
@@ -1476,7 +1475,7 @@ bool select_export::send_data(List<Item> &items)
uint used_length=0,items_left=items.elements;
List_iterator_fast<Item> li(items);
- if (my_b_write(&cache,(byte*) exchange->line_start->ptr(),
+ if (my_b_write(&cache,(uchar*) exchange->line_start->ptr(),
exchange->line_start->length()))
goto err;
while ((item=li++))
@@ -1485,7 +1484,7 @@ bool select_export::send_data(List<Item> &items)
res=item->str_result(&tmp);
if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT))
{
- if (my_b_write(&cache,(byte*) exchange->enclosed->ptr(),
+ if (my_b_write(&cache,(uchar*) exchange->enclosed->ptr(),
exchange->enclosed->length()))
goto err;
}
@@ -1497,10 +1496,10 @@ bool select_export::send_data(List<Item> &items)
{
null_buff[0]=escape_char;
null_buff[1]='N';
- if (my_b_write(&cache,(byte*) null_buff,2))
+ if (my_b_write(&cache,(uchar*) null_buff,2))
goto err;
}
- else if (my_b_write(&cache,(byte*) "NULL",4))
+ else if (my_b_write(&cache,(uchar*) "NULL",4))
goto err;
}
else
@@ -1540,16 +1539,16 @@ bool select_export::send_data(List<Item> &items)
char tmp_buff[2];
tmp_buff[0]= escape_char;
tmp_buff[1]= *pos ? *pos : '0';
- if (my_b_write(&cache,(byte*) start,(uint) (pos-start)) ||
- my_b_write(&cache,(byte*) tmp_buff,2))
+ if (my_b_write(&cache,(uchar*) start,(uint) (pos-start)) ||
+ my_b_write(&cache,(uchar*) tmp_buff,2))
goto err;
start=pos+1;
}
}
- if (my_b_write(&cache,(byte*) start,(uint) (pos-start)))
+ if (my_b_write(&cache,(uchar*) start,(uint) (pos-start)))
goto err;
}
- else if (my_b_write(&cache,(byte*) res->ptr(),used_length))
+ else if (my_b_write(&cache,(uchar*) res->ptr(),used_length))
goto err;
}
if (fixed_row_size)
@@ -1565,27 +1564,27 @@ bool select_export::send_data(List<Item> &items)
uint length=item->max_length-used_length;
for (; length > sizeof(space) ; length-=sizeof(space))
{
- if (my_b_write(&cache,(byte*) space,sizeof(space)))
+ if (my_b_write(&cache,(uchar*) space,sizeof(space)))
goto err;
}
- if (my_b_write(&cache,(byte*) space,length))
+ if (my_b_write(&cache,(uchar*) space,length))
goto err;
}
}
if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT))
{
- if (my_b_write(&cache, (byte*) exchange->enclosed->ptr(),
+ if (my_b_write(&cache, (uchar*) exchange->enclosed->ptr(),
exchange->enclosed->length()))
goto err;
}
if (--items_left)
{
- if (my_b_write(&cache, (byte*) exchange->field_term->ptr(),
+ if (my_b_write(&cache, (uchar*) exchange->field_term->ptr(),
field_term_length))
goto err;
}
}
- if (my_b_write(&cache,(byte*) exchange->line_term->ptr(),
+ if (my_b_write(&cache,(uchar*) exchange->line_term->ptr(),
exchange->line_term->length()))
goto err;
DBUG_RETURN(0);
@@ -1632,10 +1631,10 @@ bool select_dump::send_data(List<Item> &items)
res=item->str_result(&tmp);
if (!res) // If NULL
{
- if (my_b_write(&cache,(byte*) "",1))
+ if (my_b_write(&cache,(uchar*) "",1))
goto err;
}
- else if (my_b_write(&cache,(byte*) res->ptr(),res->length()))
+ else if (my_b_write(&cache,(uchar*) res->ptr(),res->length()))
{
my_error(ER_ERROR_ON_WRITE, MYF(0), path, my_errno);
goto err;
@@ -1970,13 +1969,13 @@ Statement::~Statement()
C_MODE_START
-static byte *
-get_statement_id_as_hash_key(const byte *record, uint *key_length,
+static uchar *
+get_statement_id_as_hash_key(const uchar *record, size_t *key_length,
my_bool not_used __attribute__((unused)))
{
const Statement *statement= (const Statement *) record;
*key_length= sizeof(statement->id);
- return (byte *) &((const Statement *) statement)->id;
+ return (uchar *) &((const Statement *) statement)->id;
}
static void delete_statement_as_hash_key(void *key)
@@ -1984,11 +1983,11 @@ static void delete_statement_as_hash_key(void *key)
delete (Statement *) key;
}
-static byte *get_stmt_name_hash_key(Statement *entry, uint *length,
+static uchar *get_stmt_name_hash_key(Statement *entry, size_t *length,
my_bool not_used __attribute__((unused)))
{
- *length=(uint) entry->name.length;
- return (byte*) entry->name.str;
+ *length= entry->name.length;
+ return (uchar*) entry->name.str;
}
C_MODE_END
@@ -2033,7 +2032,7 @@ Statement_map::Statement_map() :
int Statement_map::insert(THD *thd, Statement *statement)
{
- if (my_hash_insert(&st_hash, (byte*) statement))
+ if (my_hash_insert(&st_hash, (uchar*) statement))
{
/*
Delete is needed only in case of an insert failure. In all other
@@ -2043,7 +2042,7 @@ int Statement_map::insert(THD *thd, Statement *statement)
my_error(ER_OUT_OF_RESOURCES, MYF(0));
goto err_st_hash;
}
- if (statement->name.str && my_hash_insert(&names_hash, (byte*) statement))
+ if (statement->name.str && my_hash_insert(&names_hash, (uchar*) statement))
{
my_error(ER_OUT_OF_RESOURCES, MYF(0));
goto err_names_hash;
@@ -2071,9 +2070,9 @@ int Statement_map::insert(THD *thd, Statement *statement)
err_max:
if (statement->name.str)
- hash_delete(&names_hash, (byte*) statement);
+ hash_delete(&names_hash, (uchar*) statement);
err_names_hash:
- hash_delete(&st_hash, (byte*) statement);
+ hash_delete(&st_hash, (uchar*) statement);
err_st_hash:
return 1;
}
@@ -2094,9 +2093,9 @@ void Statement_map::erase(Statement *statement)
if (statement == last_found_statement)
last_found_statement= 0;
if (statement->name.str)
- hash_delete(&names_hash, (byte *) statement);
+ hash_delete(&names_hash, (uchar *) statement);
- hash_delete(&st_hash, (byte *) statement);
+ hash_delete(&st_hash, (uchar *) statement);
pthread_mutex_lock(&LOCK_prepared_stmt_count);
DBUG_ASSERT(prepared_stmt_count > 0);
prepared_stmt_count--;
@@ -2511,7 +2510,7 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup)
pthread_mutex_t LOCK_xid_cache;
HASH xid_cache;
-static byte *xid_get_hash_key(const byte *ptr,uint *length,
+static uchar *xid_get_hash_key(const uchar *ptr, size_t *length,
my_bool not_used __attribute__((unused)))
{
*length=((XID_STATE*)ptr)->xid.key_length();
@@ -2521,7 +2520,7 @@ static byte *xid_get_hash_key(const byte *ptr,uint *length,
static void xid_free_hash (void *ptr)
{
if (!((XID_STATE*)ptr)->in_thd)
- my_free((gptr)ptr, MYF(0));
+ my_free((uchar*)ptr, MYF(0));
}
bool xid_cache_init()
@@ -2563,7 +2562,7 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state)
xs->xa_state=xa_state;
xs->xid.set(xid);
xs->in_thd=0;
- res=my_hash_insert(&xid_cache, (byte*)xs);
+ res=my_hash_insert(&xid_cache, (uchar*)xs);
}
pthread_mutex_unlock(&LOCK_xid_cache);
return res;
@@ -2575,7 +2574,7 @@ bool xid_cache_insert(XID_STATE *xid_state)
pthread_mutex_lock(&LOCK_xid_cache);
DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(),
xid_state->xid.key_length())==0);
- my_bool res=my_hash_insert(&xid_cache, (byte*)xid_state);
+ my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state);
pthread_mutex_unlock(&LOCK_xid_cache);
return res;
}
@@ -2584,7 +2583,7 @@ bool xid_cache_insert(XID_STATE *xid_state)
void xid_cache_delete(XID_STATE *xid_state)
{
pthread_mutex_lock(&LOCK_xid_cache);
- hash_delete(&xid_cache, (byte *)xid_state);
+ hash_delete(&xid_cache, (uchar *)xid_state);
pthread_mutex_unlock(&LOCK_xid_cache);
}
@@ -2620,8 +2619,8 @@ void xid_cache_delete(XID_STATE *xid_state)
template <class RowsEventT> Rows_log_event*
THD::binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id,
MY_BITMAP const* cols,
- my_size_t colcnt,
- my_size_t needed,
+ size_t colcnt,
+ size_t needed,
bool is_transactional,
RowsEventT *hint __attribute__((unused)))
{
@@ -2691,17 +2690,17 @@ THD::binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id,
*/
template Rows_log_event*
THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*,
- my_size_t, my_size_t, bool,
+ size_t, size_t, bool,
Write_rows_log_event*);
template Rows_log_event*
THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*,
- my_size_t colcnt, my_size_t, bool,
+ size_t colcnt, size_t, bool,
Delete_rows_log_event *);
template Rows_log_event*
THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*,
- my_size_t colcnt, my_size_t, bool,
+ size_t colcnt, size_t, bool,
Update_rows_log_event *);
#endif
@@ -2770,27 +2769,6 @@ field_type_name(enum_field_types type)
#endif
-my_size_t THD::max_row_length_blob(TABLE *table, const byte *data) const
-{
- my_size_t length= 0;
- TABLE_SHARE *table_s= table->s;
- uint* const beg= table_s->blob_field;
- uint* const end= beg + table_s->blob_fields;
-
- for (uint *ptr= beg ; ptr != end ; ++ptr)
- {
- Field_blob* const blob= (Field_blob*) table->field[*ptr];
- length+= blob->get_length((const char*) (data +
- blob->offset(table->record[0]))) +
- HA_KEY_BLOB_LENGTH;
- }
-
- return length;
-}
-
-
-
-
namespace {
/**
Class to handle temporary allocation of memory for row data.
@@ -2819,7 +2797,7 @@ namespace {
@param length
Length of data that is needed, if the record contain blobs.
*/
- Row_data_memory(TABLE *table, my_size_t const len1)
+ Row_data_memory(TABLE *table, size_t const len1)
: m_memory(0)
{
#ifndef DBUG_OFF
@@ -2830,7 +2808,7 @@ namespace {
m_ptr[1]= 0;
}
- Row_data_memory(TABLE *table, my_size_t const len1, my_size_t const len2)
+ Row_data_memory(TABLE *table, size_t const len1, size_t const len2)
: m_memory(0)
{
#ifndef DBUG_OFF
@@ -2844,7 +2822,7 @@ namespace {
~Row_data_memory()
{
if (m_memory != 0 && m_release_memory_on_destruction)
- my_free((gptr) m_memory, MYF(MY_WME));
+ my_free((uchar*) m_memory, MYF(MY_WME));
}
/**
@@ -2860,7 +2838,7 @@ namespace {
return m_memory != 0;
}
- byte *slot(uint s)
+ uchar *slot(uint s)
{
DBUG_ASSERT(s < sizeof(m_ptr)/sizeof(*m_ptr));
DBUG_ASSERT(m_ptr[s] != 0);
@@ -2869,7 +2847,7 @@ namespace {
}
private:
- void allocate_memory(TABLE *const table, my_size_t const total_length)
+ void allocate_memory(TABLE *const table, size_t const total_length)
{
if (table->s->blob_fields == 0)
{
@@ -2883,7 +2861,7 @@ namespace {
to add two bytes for each field, which can potentially be
added to hold the length of a packed field.
*/
- my_size_t const maxlen= table->s->reclength + 2 * table->s->fields;
+ size_t const maxlen= table->s->reclength + 2 * table->s->fields;
/*
Allocate memory for two records if memory hasn't been
@@ -2892,13 +2870,13 @@ namespace {
*/
if (table->write_row_record == 0)
table->write_row_record=
- (byte *) alloc_root(&table->mem_root, 2 * maxlen);
+ (uchar *) alloc_root(&table->mem_root, 2 * maxlen);
m_memory= table->write_row_record;
m_release_memory_on_destruction= FALSE;
}
else
{
- m_memory= (byte *) my_malloc(total_length, MYF(MY_WME));
+ m_memory= (uchar *) my_malloc(total_length, MYF(MY_WME));
m_release_memory_on_destruction= TRUE;
}
}
@@ -2907,15 +2885,15 @@ namespace {
mutable bool m_alloc_checked;
#endif
bool m_release_memory_on_destruction;
- byte *m_memory;
- byte *m_ptr[2];
+ uchar *m_memory;
+ uchar *m_ptr[2];
};
}
int THD::binlog_write_row(TABLE* table, bool is_trans,
- MY_BITMAP const* cols, my_size_t colcnt,
- byte const *record)
+ MY_BITMAP const* cols, size_t colcnt,
+ uchar const *record)
{
DBUG_ASSERT(current_stmt_binlog_row_based && mysql_bin_log.is_open());
@@ -2927,9 +2905,9 @@ int THD::binlog_write_row(TABLE* table, bool is_trans,
if (!memory.has_memory())
return HA_ERR_OUT_OF_MEM;
- byte *row_data= memory.slot(0);
+ uchar *row_data= memory.slot(0);
- my_size_t const len= pack_row(table, cols, row_data, record);
+ size_t const len= pack_row(table, cols, row_data, record);
Rows_log_event* const ev=
binlog_prepare_pending_rows_event(table, server_id, cols, colcnt,
@@ -2943,25 +2921,25 @@ int THD::binlog_write_row(TABLE* table, bool is_trans,
}
int THD::binlog_update_row(TABLE* table, bool is_trans,
- MY_BITMAP const* cols, my_size_t colcnt,
- const byte *before_record,
- const byte *after_record)
+ MY_BITMAP const* cols, size_t colcnt,
+ const uchar *before_record,
+ const uchar *after_record)
{
DBUG_ASSERT(current_stmt_binlog_row_based && mysql_bin_log.is_open());
- my_size_t const before_maxlen = max_row_length(table, before_record);
- my_size_t const after_maxlen = max_row_length(table, after_record);
+ size_t const before_maxlen = max_row_length(table, before_record);
+ size_t const after_maxlen = max_row_length(table, after_record);
Row_data_memory row_data(table, before_maxlen, after_maxlen);
if (!row_data.has_memory())
return HA_ERR_OUT_OF_MEM;
- byte *before_row= row_data.slot(0);
- byte *after_row= row_data.slot(1);
+ uchar *before_row= row_data.slot(0);
+ uchar *after_row= row_data.slot(1);
- my_size_t const before_size= pack_row(table, cols, before_row,
+ size_t const before_size= pack_row(table, cols, before_row,
before_record);
- my_size_t const after_size= pack_row(table, cols, after_row,
+ size_t const after_size= pack_row(table, cols, after_row,
after_record);
/*
@@ -2969,10 +2947,10 @@ int THD::binlog_update_row(TABLE* table, bool is_trans,
trigger false warnings.
*/
#ifndef HAVE_purify
- DBUG_DUMP("before_record", (const char *)before_record, table->s->reclength);
- DBUG_DUMP("after_record", (const char *)after_record, table->s->reclength);
- DBUG_DUMP("before_row", (const char *)before_row, before_size);
- DBUG_DUMP("after_row", (const char *)after_row, after_size);
+ DBUG_DUMP("before_record", before_record, table->s->reclength);
+ DBUG_DUMP("after_record", after_record, table->s->reclength);
+ DBUG_DUMP("before_row", before_row, before_size);
+ DBUG_DUMP("after_row", after_row, after_size);
#endif
Rows_log_event* const ev=
@@ -2989,8 +2967,8 @@ int THD::binlog_update_row(TABLE* table, bool is_trans,
}
int THD::binlog_delete_row(TABLE* table, bool is_trans,
- MY_BITMAP const* cols, my_size_t colcnt,
- byte const *record)
+ MY_BITMAP const* cols, size_t colcnt,
+ uchar const *record)
{
DBUG_ASSERT(current_stmt_binlog_row_based && mysql_bin_log.is_open());
@@ -3002,9 +2980,9 @@ int THD::binlog_delete_row(TABLE* table, bool is_trans,
if (unlikely(!memory.has_memory()))
return HA_ERR_OUT_OF_MEM;
- byte *row_data= memory.slot(0);
+ uchar *row_data= memory.slot(0);
- my_size_t const len= pack_row(table, cols, row_data, record);
+ size_t const len= pack_row(table, cols, row_data, record);
Rows_log_event* const ev=
binlog_prepare_pending_rows_event(table, server_id, cols, colcnt,