summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/CMakeLists.txt1
-rw-r--r--sql/create_options.cc4
-rw-r--r--sql/debug_sync.cc8
-rw-r--r--sql/discover.cc2
-rw-r--r--sql/event_data_objects.cc6
-rw-r--r--sql/event_db_repository.cc4
-rw-r--r--sql/event_parse_data.cc12
-rw-r--r--sql/event_queue.cc14
-rw-r--r--sql/event_scheduler.cc10
-rw-r--r--sql/events.cc2
-rw-r--r--sql/field.cc34
-rw-r--r--sql/field.h7
-rw-r--r--sql/filesort.cc5
-rw-r--r--sql/gen_lex_token.cc2
-rw-r--r--sql/ha_partition.cc12
-rw-r--r--sql/handler.cc20
-rw-r--r--sql/handler.h6
-rw-r--r--sql/item.cc61
-rw-r--r--sql/item.h21
-rw-r--r--sql/item_cmpfunc.cc14
-rw-r--r--sql/item_cmpfunc.h17
-rw-r--r--sql/item_create.cc2
-rw-r--r--sql/item_func.cc52
-rw-r--r--sql/item_func.h100
-rw-r--r--sql/item_inetfunc.cc26
-rw-r--r--sql/item_inetfunc.h2
-rw-r--r--sql/item_jsonfunc.cc20
-rw-r--r--sql/item_jsonfunc.h8
-rw-r--r--sql/item_strfunc.cc12
-rw-r--r--sql/item_strfunc.h7
-rw-r--r--sql/item_subselect.cc10
-rw-r--r--sql/item_sum.cc4
-rw-r--r--sql/item_sum.h2
-rw-r--r--sql/item_timefunc.cc8
-rw-r--r--sql/item_timefunc.h106
-rw-r--r--sql/key.cc2
-rw-r--r--sql/lock.cc2
-rw-r--r--sql/log.cc16
-rw-r--r--sql/log_event.cc54
-rw-r--r--sql/log_event.h2
-rw-r--r--sql/log_event_old.cc24
-rw-r--r--sql/mf_iocache_encr.cc10
-rw-r--r--sql/mysqld.cc17
-rw-r--r--sql/opt_range.cc30
-rw-r--r--sql/parse_file.cc6
-rw-r--r--sql/rpl_filter.cc2
-rw-r--r--sql/rpl_parallel.cc2
-rw-r--r--sql/rpl_record.cc18
-rw-r--r--sql/rpl_rli.cc8
-rw-r--r--sql/rpl_tblmap.cc12
-rw-r--r--sql/session_tracker.cc8
-rw-r--r--sql/slave.cc12
-rw-r--r--sql/sp.cc14
-rw-r--r--sql/sp_head.cc36
-rw-r--r--sql/sp_pcontext.h8
-rw-r--r--sql/sp_rcontext.cc14
-rw-r--r--sql/sp_rcontext.h3
-rw-r--r--sql/sql_acl.cc27
-rw-r--r--sql/sql_admin.cc2
-rw-r--r--sql/sql_audit.h87
-rw-r--r--sql/sql_base.cc32
-rw-r--r--sql/sql_binlog.cc4
-rw-r--r--sql/sql_bootstrap.cc4
-rw-r--r--sql/sql_cache.cc426
-rw-r--r--sql/sql_cache.h4
-rw-r--r--sql/sql_class.cc24
-rw-r--r--sql/sql_class.h4
-rw-r--r--sql/sql_delete.cc2
-rw-r--r--sql/sql_derived.cc2
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_join_cache.cc6
-rw-r--r--sql/sql_lex.cc24
-rw-r--r--sql/sql_manager.cc2
-rw-r--r--sql/sql_parse.cc27
-rw-r--r--sql/sql_partition.cc2
-rw-r--r--sql/sql_plugin.cc20
-rw-r--r--sql/sql_prepare.cc15
-rw-r--r--sql/sql_select.cc23
-rw-r--r--sql/sql_select.h7
-rw-r--r--sql/sql_servers.cc16
-rw-r--r--sql/sql_show.cc8
-rw-r--r--sql/sql_statistics.cc5
-rw-r--r--sql/sql_string.cc37
-rw-r--r--sql/sql_string.h27
-rw-r--r--sql/sql_table.cc12
-rw-r--r--sql/sql_test.cc2
-rw-r--r--sql/sql_time.h2
-rw-r--r--sql/sql_type.h14
-rw-r--r--sql/sql_update.cc28
-rw-r--r--sql/sql_view.cc2
-rw-r--r--sql/sql_window.cc2
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--sql/sql_yacc_ora.yy2
-rw-r--r--sql/strfunc.cc2
-rw-r--r--sql/sys_vars.cc6
-rw-r--r--sql/sys_vars.ic12
-rw-r--r--sql/table.cc8
-rw-r--r--sql/table_cache.cc23
-rw-r--r--sql/table_cache.h12
-rw-r--r--sql/temporary_tables.cc8
-rw-r--r--sql/threadpool_generic.cc13
-rw-r--r--sql/udf_example.c2
-rw-r--r--sql/uniques.cc6
-rw-r--r--sql/uniques.h12
-rw-r--r--sql/unireg.cc8
105 files changed, 1128 insertions, 812 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 329682fb8b4..8a03692598d 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -247,6 +247,7 @@ IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
SET(CMAKE_CONFIGURABLE_FILE_CONTENT "
IF ((mysqld_lib.def IS_NEWER_THAN mysqld_lib.lib) OR
(mysqld_lib.def IS_NEWER_THAN mysqld_lib.exp))
+ FILE(REMOVE mysqld_lib.lib mysqld_lib.exp)
SET(ENV{VS_UNICODE_OUTPUT})
EXECUTE_PROCESS (
COMMAND \"${CMAKE_LINKER}\" /lib /NAME:mysqld.exe \"/DEF:${MYSQLD_DEF}\" /MACHINE:${_PLATFORM}
diff --git a/sql/create_options.cc b/sql/create_options.cc
index ca3ace5a5b9..d010b73c222 100644
--- a/sql/create_options.cc
+++ b/sql/create_options.cc
@@ -125,8 +125,8 @@ static bool set_one_value(ha_create_table_option *opt,
MEM_ROOT *root)
{
DBUG_ENTER("set_one_value");
- DBUG_PRINT("enter", ("opt: 0x%lx type: %u name '%s' value: '%s'",
- (ulong) opt,
+ DBUG_PRINT("enter", ("opt: %p type: %u name '%s' value: '%s'",
+ opt,
opt->type, opt->name,
(value->str ? value->str : "<DEFAULT>")));
switch (opt->type)
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc
index 99d39e31994..d44b313ec24 100644
--- a/sql/debug_sync.cc
+++ b/sql/debug_sync.cc
@@ -549,7 +549,7 @@ static void debug_sync_reset(THD *thd)
static void debug_sync_remove_action(st_debug_sync_control *ds_control,
st_debug_sync_action *action)
{
- uint dsp_idx= action - ds_control->ds_action;
+ uint dsp_idx= (uint)(action - ds_control->ds_action);
DBUG_ENTER("debug_sync_remove_action");
DBUG_ASSERT(ds_control);
DBUG_ASSERT(ds_control == current_thd->debug_sync_control);
@@ -681,8 +681,8 @@ static st_debug_sync_action *debug_sync_get_action(THD *thd,
}
DBUG_ASSERT(action >= ds_control->ds_action);
DBUG_ASSERT(action < ds_control->ds_action + ds_control->ds_active);
- DBUG_PRINT("debug_sync", ("action: 0x%lx array: 0x%lx count: %u",
- (long) action, (long) ds_control->ds_action,
+ DBUG_PRINT("debug_sync", ("action: %p array: %p count: %u",
+ action, ds_control->ds_action,
ds_control->ds_active));
DBUG_RETURN(action);
@@ -871,7 +871,7 @@ static char *debug_sync_token(char **token_p, uint *token_length_p,
ptr, ptrend, MY_SEQ_NONSPACES);
/* Get token length. */
- *token_length_p= ptr - *token_p;
+ *token_length_p= (uint)(ptr - *token_p);
/* If necessary, terminate token. */
if (*ptr)
diff --git a/sql/discover.cc b/sql/discover.cc
index 8785845d6e5..a683166fb7f 100644
--- a/sql/discover.cc
+++ b/sql/discover.cc
@@ -229,7 +229,7 @@ int extension_based_table_discovery(MY_DIR *dirp, const char *ext_meta,
cur++;
}
advance(from, to, cur, skip);
- dirp->number_of_files= to - dirp->dir_entry;
+ dirp->number_of_files= (uint)(to - dirp->dir_entry);
return 0;
}
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 02ac5633d65..69d17725bea 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -561,7 +561,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
}
if ((ptr= get_field(&mem_root, table->field[ET_FIELD_ORIGINATOR])) == NullS)
DBUG_RETURN(TRUE);
- originator = table->field[ET_FIELD_ORIGINATOR]->val_int();
+ originator = (uint32) table->field[ET_FIELD_ORIGINATOR]->val_int();
/* ToDo : Andrey . Find a way not to allocate ptr on event_mem_root */
if ((ptr= get_field(&mem_root,
@@ -911,9 +911,9 @@ Event_queue_element::compute_next_execution_time()
{
my_time_t time_now;
DBUG_ENTER("Event_queue_element::compute_next_execution_time");
- DBUG_PRINT("enter", ("starts: %lu ends: %lu last_executed: %lu this: 0x%lx",
+ DBUG_PRINT("enter", ("starts: %lu ends: %lu last_executed: %lu this: %p",
(long) starts, (long) ends, (long) last_executed,
- (long) this));
+ this));
if (status != Event_parse_data::ENABLED)
{
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index a14d3c1eef4..9d899cb637e 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -1063,7 +1063,7 @@ Event_db_repository::load_named_event(THD *thd, const LEX_CSTRING *dbname,
TABLE_LIST event_table;
DBUG_ENTER("Event_db_repository::load_named_event");
- DBUG_PRINT("enter",("thd: 0x%lx name: %*s", (long) thd,
+ DBUG_PRINT("enter",("thd: %p name: %*s", thd,
(int) name->length, name->str));
event_table.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
@@ -1186,7 +1186,7 @@ Event_db_repository::check_system_tables(THD *thd)
const unsigned int event_priv_column_position= 29;
DBUG_ENTER("Event_db_repository::check_system_tables");
- DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
+ DBUG_PRINT("enter", ("thd: %p", thd));
/* Check mysql.db */
tables.init_one_table("mysql", 5, "db", 2, "db", TL_READ);
diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc
index c598c8a15ee..b2ff80626db 100644
--- a/sql/event_parse_data.cc
+++ b/sql/event_parse_data.cc
@@ -494,9 +494,9 @@ Event_parse_data::check_parse_data(THD *thd)
{
bool ret;
DBUG_ENTER("Event_parse_data::check_parse_data");
- DBUG_PRINT("info", ("execute_at: 0x%lx expr=0x%lx starts=0x%lx ends=0x%lx",
- (long) item_execute_at, (long) item_expression,
- (long) item_starts, (long) item_ends));
+ DBUG_PRINT("info", ("execute_at: %p expr=%p starts=%p ends=%p",
+ item_execute_at, item_expression,
+ item_starts, item_ends));
init_name(thd, identifier);
@@ -529,9 +529,9 @@ Event_parse_data::init_definer(THD *thd)
size_t definer_user_len= thd->lex->definer->user.length;
size_t definer_host_len= thd->lex->definer->host.length;
char *tmp;
- DBUG_PRINT("info",("init definer_user thd->mem_root: 0x%lx "
- "definer_user: 0x%lx", (long) thd->mem_root,
- (long) definer_user));
+ DBUG_PRINT("info",("init definer_user thd->mem_root: %p "
+ "definer_user: %p", thd->mem_root,
+ definer_user));
/* + 1 for @ */
DBUG_PRINT("info",("init definer as whole"));
diff --git a/sql/event_queue.cc b/sql/event_queue.cc
index a8ddff81110..e46326afe18 100644
--- a/sql/event_queue.cc
+++ b/sql/event_queue.cc
@@ -135,7 +135,7 @@ bool
Event_queue::init_queue(THD *thd)
{
DBUG_ENTER("Event_queue::init_queue");
- DBUG_PRINT("enter", ("this: 0x%lx", (long) this));
+ DBUG_PRINT("enter", ("this: %p", this));
LOCK_QUEUE_DATA();
@@ -201,7 +201,7 @@ Event_queue::create_event(THD *thd, Event_queue_element *new_element,
bool *created)
{
DBUG_ENTER("Event_queue::create_event");
- DBUG_PRINT("enter", ("thd: 0x%lx et=%s.%s", (long) thd,
+ DBUG_PRINT("enter", ("thd: %p et=%s.%s", thd,
new_element->dbname.str, new_element->name.str));
/* Will do nothing if the event is disabled */
@@ -213,7 +213,7 @@ Event_queue::create_event(THD *thd, Event_queue_element *new_element,
DBUG_RETURN(FALSE);
}
- DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element));
+ DBUG_PRINT("info", ("new event in the queue: %p", new_element));
LOCK_QUEUE_DATA();
*created= (queue_insert_safe(&queue, (uchar *) new_element) == FALSE);
@@ -266,7 +266,7 @@ Event_queue::update_event(THD *thd, const LEX_CSTRING *dbname,
/* If not disabled event */
if (new_element)
{
- DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element));
+ DBUG_PRINT("info", ("new event in the queue: %p", new_element));
queue_insert_safe(&queue, (uchar *) new_element);
mysql_cond_broadcast(&COND_queue_state);
}
@@ -549,7 +549,7 @@ Event_queue::dbug_dump_queue(my_time_t when)
i++)
{
et= ((Event_queue_element*)queue_element(&queue, i));
- DBUG_PRINT("info", ("et: 0x%lx name: %s.%s", (long) et,
+ DBUG_PRINT("info", ("et: %p name: %s.%s", et,
et->dbname.str, et->name.str));
DBUG_PRINT("info", ("exec_at: %lu starts: %lu ends: %lu execs_so_far: %u "
"expr: %ld et.exec_at: %ld now: %ld "
@@ -677,8 +677,8 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
end:
UNLOCK_QUEUE_DATA();
- DBUG_PRINT("info", ("returning %d et_new: 0x%lx ",
- ret, (long) *event_name));
+ DBUG_PRINT("info", ("returning %d et_new: %p ",
+ ret, *event_name));
if (*event_name)
{
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index e8b586801d6..d9db7afe1ab 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -295,7 +295,7 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
res= post_init_event_thread(thd);
DBUG_ENTER("Event_worker_thread::run");
- DBUG_PRINT("info", ("Time is %ld, THD: 0x%lx", (long) my_time(0), (long) thd));
+ DBUG_PRINT("info", ("Time is %u, THD: %p", (uint)my_time(0), thd));
inc_thread_running();
if (res)
@@ -420,7 +420,7 @@ Event_scheduler::start(int *err_no)
scheduler_thd= new_thd;
DBUG_PRINT("info", ("Setting state go RUNNING"));
state= RUNNING;
- DBUG_PRINT("info", ("Forking new thread for scheduler. THD: 0x%lx", (long) new_thd));
+ DBUG_PRINT("info", ("Forking new thread for scheduler. THD: %p", new_thd));
if ((*err_no= mysql_thread_create(key_thread_event_scheduler,
&th, &connection_attrib,
event_scheduler_thread,
@@ -485,7 +485,7 @@ Event_scheduler::run(THD *thd)
}
DBUG_PRINT("info", ("get_top_for_execution_if_time returned "
- "event_name=0x%lx", (long) event_name));
+ "event_name=%p", event_name));
if (event_name)
{
if ((res= execute_top(event_name)))
@@ -566,7 +566,7 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
started_events++;
executed_events++; // For SHOW STATUS
- DBUG_PRINT("info", ("Event is in THD: 0x%lx", (long) new_thd));
+ DBUG_PRINT("info", ("Event is in THD: %p", new_thd));
DBUG_RETURN(FALSE);
error:
@@ -617,7 +617,7 @@ Event_scheduler::stop()
{
THD *thd= current_thd;
DBUG_ENTER("Event_scheduler::stop");
- DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
+ DBUG_PRINT("enter", ("thd: %p", thd));
LOCK_DATA();
DBUG_PRINT("info", ("state before action %s", scheduler_states_names[state].str));
diff --git a/sql/events.cc b/sql/events.cc
index 9ecc55fbdf0..069fa97aa36 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1121,7 +1121,7 @@ Events::load_events_from_db(THD *thd)
uint count= 0;
ulong saved_master_access;
DBUG_ENTER("Events::load_events_from_db");
- DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
+ DBUG_PRINT("enter", ("thd: %p", thd));
/*
NOTE: even if we run in read-only mode, we should be able to lock the
diff --git a/sql/field.cc b/sql/field.cc
index 363c3bbf73b..e10c82347d5 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5404,7 +5404,7 @@ int Field_temporal_with_date::store(double nr)
ErrConvDouble str(nr);
longlong tmp= double_to_datetime(nr, &ltime,
- sql_mode_for_dates(thd), &error);
+ (uint) sql_mode_for_dates(thd), &error);
return store_TIME_with_warning(&ltime, &str, error, tmp != -1);
}
@@ -7983,7 +7983,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
DBUG_ASSERT(length <= max_data_length());
new_length= length;
- copy_length= table->in_use->variables.group_concat_max_len;
+ copy_length= (uint)MY_MIN(UINT_MAX,table->in_use->variables.group_concat_max_len);
if (new_length > copy_length)
{
new_length= Well_formed_prefix(cs,
@@ -8394,8 +8394,8 @@ const uchar *Field_blob::unpack(uchar *to, const uchar *from,
const uchar *from_end, uint param_data)
{
DBUG_ENTER("Field_blob::unpack");
- DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx; param_data: %u",
- (ulong) to, (ulong) from, param_data));
+ DBUG_PRINT("enter", ("to: %p; from: %p; param_data: %u",
+ to, from, param_data));
uint const master_packlength=
param_data > 0 ? param_data & 0xFF : packlength;
if (from + master_packlength > from_end)
@@ -8584,7 +8584,7 @@ uint gis_field_options_read(const uchar *buf, uint buf_len,
}
end_of_record:
- return cbuf - buf;
+ return (uint)(cbuf - buf);
}
@@ -9315,8 +9315,8 @@ Field_bit::do_last_null_byte() const
bits. On systems with CHAR_BIT > 8 (not very common), the storage
will lose the extra bits.
*/
- DBUG_PRINT("test", ("bit_ofs: %d, bit_len: %d bit_ptr: 0x%lx",
- bit_ofs, bit_len, (long) bit_ptr));
+ DBUG_PRINT("test", ("bit_ofs: %d, bit_len: %d bit_ptr: %p",
+ bit_ofs, bit_len, bit_ptr));
uchar *result;
if (bit_len == 0)
result= null_ptr;
@@ -10000,7 +10000,7 @@ void Column_definition::create_length_to_internal_length_bit()
}
else
{
- pack_length= length / 8;
+ pack_length= (uint) length / 8;
/* We need one extra byte to store the bits we save among the null bits */
key_length= pack_length + MY_TEST(length & 7);
}
@@ -10010,7 +10010,7 @@ void Column_definition::create_length_to_internal_length_bit()
void Column_definition::create_length_to_internal_length_newdecimal()
{
key_length= pack_length=
- my_decimal_get_binary_size(my_decimal_length_to_precision(length,
+ my_decimal_get_binary_size(my_decimal_length_to_precision((uint) length,
decimals,
flags &
UNSIGNED_FLAG),
@@ -10117,9 +10117,9 @@ bool Column_definition::fix_attributes_decimal()
my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name.str);
return true;
}
- length= my_decimal_precision_to_length(length, decimals,
+ length= my_decimal_precision_to_length((uint) length, decimals,
flags & UNSIGNED_FLAG);
- pack_length= my_decimal_get_binary_size(length, decimals);
+ pack_length= my_decimal_get_binary_size((uint) length, decimals);
return false;
}
@@ -10128,7 +10128,7 @@ bool Column_definition::fix_attributes_bit()
{
if (!length)
length= 1;
- pack_length= (length + 7) / 8;
+ pack_length= ((uint) length + 7) / 8;
return check_length(ER_TOO_BIG_DISPLAYWIDTH, MAX_BIT_FIELD_LENGTH);
}
@@ -10226,7 +10226,7 @@ bool Column_definition::check(THD *thd)
DBUG_RETURN(true);
/* Remember the value of length */
- char_length= length;
+ char_length= (uint)length;
/*
Set NO_DEFAULT_VALUE_FLAG if this field doesn't have a default value and
@@ -10651,7 +10651,7 @@ Column_definition::Column_definition(THD *thd, Field *old_field,
interval_list.empty(); // prepare_interval_field() needs this
- char_length= length;
+ char_length= (uint)length;
/*
Copy the default (constant/function) from the column object orig_field, if
@@ -10994,7 +10994,7 @@ bool Field::save_in_field_default_value(bool view_error_processing)
{
my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
ER_THD(thd, ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
- return -1;
+ return true;
}
if (view_error_processing)
@@ -11013,13 +11013,13 @@ bool Field::save_in_field_default_value(bool view_error_processing)
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
field_name.str);
}
- return 1;
+ return true;
}
set_default();
return
!is_null() &&
validate_value_in_record_with_warn(thd, table->record[0]) &&
- thd->is_error() ? -1 : 0;
+ thd->is_error();
}
diff --git a/sql/field.h b/sql/field.h
index 061232ea1ef..bf115b38816 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -4071,15 +4071,16 @@ public:
}
void create_length_to_internal_length_simple()
{
- key_length= pack_length= type_handler()->calc_pack_length(length);
+ key_length= pack_length= type_handler()->calc_pack_length((uint32) length);
}
void create_length_to_internal_length_string()
{
length*= charset->mbmaxlen;
if (real_field_type() == MYSQL_TYPE_VARCHAR && compression_method())
length++;
- key_length= length;
- pack_length= type_handler()->calc_pack_length(length);
+ DBUG_ASSERT(length <= UINT_MAX32);
+ key_length= (uint) length;
+ pack_length= type_handler()->calc_pack_length((uint32) length);
}
void create_length_to_internal_length_typelib()
{
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 04431a2bccc..d2e167ce7bf 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -140,7 +140,8 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort,
table_map first_table_bit)
{
int error;
- size_t memory_available= thd->variables.sortbuff_size;
+ DBUG_ASSERT(thd->variables.sortbuff_size <= SIZE_T_MAX);
+ size_t memory_available= (size_t)thd->variables.sortbuff_size;
uint maxbuffer;
BUFFPEK *buffpek;
ha_rows num_rows= HA_POS_ERROR;
@@ -1805,7 +1806,7 @@ int merge_buffers(Sort_param *param, IO_CACHE *from_file,
if (flag == 0)
{
if (my_b_write(to_file, (uchar*) buffpek->key,
- (rec_length*buffpek->mem_count)))
+ (size_t)(rec_length*buffpek->mem_count)))
{
error= 1; goto err; /* purecov: inspected */
}
diff --git a/sql/gen_lex_token.cc b/sql/gen_lex_token.cc
index 91b91f49e37..ebd966d9301 100644
--- a/sql/gen_lex_token.cc
+++ b/sql/gen_lex_token.cc
@@ -77,7 +77,7 @@ void set_token(int tok, const char *str)
}
compiled_token_array[tok].m_token_string= str;
- compiled_token_array[tok].m_token_length= strlen(str);
+ compiled_token_array[tok].m_token_length= (int)strlen(str);
compiled_token_array[tok].m_append_space= true;
compiled_token_array[tok].m_start_expr= false;
}
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 810df2f0ac1..effabc3a3c0 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -2506,7 +2506,7 @@ register_query_cache_dependant_tables(THD *thd,
part= i * num_subparts + j;
/* we store the end \0 as part of the key */
end= strmov(engine_pos, sub_elem->partition_name);
- length= end - engine_key;
+ length= (uint)(end - engine_key);
/* Copy the suffix also to query cache key */
memcpy(query_cache_key_end, engine_key_end, (end - engine_key_end));
if (reg_query_cache_dependant_table(thd, engine_key, length,
@@ -2522,7 +2522,7 @@ register_query_cache_dependant_tables(THD *thd,
else
{
char *end= engine_pos+1; // copy end \0
- uint length= end - engine_key;
+ uint length= (uint)(end - engine_key);
/* Copy the suffix also to query cache key */
memcpy(query_cache_key_end, engine_key_end, (end - engine_key_end));
if (reg_query_cache_dependant_table(thd, engine_key, length,
@@ -4802,8 +4802,8 @@ int ha_partition::rnd_init(bool scan)
}
/* Now we see what the index of our first important partition is */
- DBUG_PRINT("info", ("m_part_info->read_partitions: 0x%lx",
- (long) m_part_info->read_partitions.bitmap));
+ DBUG_PRINT("info", ("m_part_info->read_partitions: %p",
+ m_part_info->read_partitions.bitmap));
part_id= bitmap_get_first_set(&(m_part_info->read_partitions));
DBUG_PRINT("info", ("m_part_spec.start_part %d", part_id));
@@ -6737,7 +6737,7 @@ int ha_partition::info(uint flag)
/* Get variables if not already done */
if (!(flag & HA_STATUS_VARIABLE) ||
!bitmap_is_set(&(m_part_info->read_partitions),
- (file_array - m_file)))
+ (uint)(file_array - m_file)))
file->info(HA_STATUS_VARIABLE | no_lock_flag | extra_var_flag);
if (file->stats.records > max_records)
{
@@ -7704,7 +7704,7 @@ ha_rows ha_partition::estimate_rows_upper_bound()
do
{
- if (bitmap_is_set(&(m_part_info->read_partitions), (file - m_file)))
+ if (bitmap_is_set(&(m_part_info->read_partitions), (uint)(file - m_file)))
{
rows= (*file)->estimate_rows_upper_bound();
if (rows == HA_POS_ERROR)
diff --git a/sql/handler.cc b/sql/handler.cc
index bcb68ca0695..7609ed047a0 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -259,7 +259,7 @@ handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
{
handler *file;
DBUG_ENTER("get_new_handler");
- DBUG_PRINT("enter", ("alloc: 0x%lx", (long) alloc));
+ DBUG_PRINT("enter", ("alloc: %p", alloc));
if (db_type && db_type->state == SHOW_OPTION_YES && db_type->create)
{
@@ -1376,7 +1376,7 @@ int ha_commit_trans(THD *thd, bool all)
uint rw_ha_count= ha_check_and_coalesce_trx_read_only(thd, ha_info, all);
/* rw_trans is TRUE when we in a transaction changing data */
bool rw_trans= is_real_trans &&
- (rw_ha_count > !thd->is_current_stmt_binlog_disabled());
+ (rw_ha_count > (thd->is_current_stmt_binlog_disabled()?0U:1U));
MDL_request mdl_request;
DBUG_PRINT("info", ("is_real_trans: %d rw_trans: %d rw_ha_count: %d",
is_real_trans, rw_trans, rw_ha_count));
@@ -3209,8 +3209,8 @@ void handler::column_bitmaps_signal()
{
DBUG_ENTER("column_bitmaps_signal");
if (table)
- DBUG_PRINT("info", ("read_set: 0x%lx write_set: 0x%lx",
- (long) table->read_set, (long) table->write_set));
+ DBUG_PRINT("info", ("read_set: %p write_set: %p",
+ table->read_set, table->write_set));
DBUG_VOID_RETURN;
}
@@ -5586,9 +5586,9 @@ TYPELIB *ha_known_exts(void)
}
-static bool stat_print(THD *thd, const char *type, uint type_len,
- const char *file, uint file_len,
- const char *status, uint status_len)
+static bool stat_print(THD *thd, const char *type, size_t type_len,
+ const char *file, size_t file_len,
+ const char *status, size_t status_len)
{
Protocol *protocol= thd->protocol;
protocol->prepare_for_resend();
@@ -5770,9 +5770,9 @@ bool handler::check_table_binlog_row_based_internal(bool binlog_row)
static int write_locked_table_maps(THD *thd)
{
DBUG_ENTER("write_locked_table_maps");
- DBUG_PRINT("enter", ("thd: 0x%lx thd->lock: 0x%lx "
- "thd->extra_lock: 0x%lx",
- (long) thd, (long) thd->lock, (long) thd->extra_lock));
+ DBUG_PRINT("enter", ("thd:%p thd->lock:%p "
+ "thd->extra_lock: %p",
+ thd, thd->lock, thd->extra_lock));
DBUG_PRINT("debug", ("get_binlog_table_maps(): %d", thd->get_binlog_table_maps()));
diff --git a/sql/handler.h b/sql/handler.h
index 5e0adfca072..f681040db39 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -789,9 +789,9 @@ struct TABLE_SHARE;
struct HA_CREATE_INFO;
struct st_foreign_key_info;
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
-typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
- const char *file, uint file_len,
- const char *status, uint status_len);
+typedef bool (stat_print_fn)(THD *thd, const char *type, size_t type_len,
+ const char *file, size_t file_len,
+ const char *status, size_t status_len);
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
extern st_plugin_int *hton2plugin[MAX_HA];
diff --git a/sql/item.cc b/sql/item.cc
index 54426c761c8..ad17cd5811c 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1069,6 +1069,17 @@ bool Item::check_type_can_return_int(const char *opname) const
}
+bool Item::check_type_can_return_decimal(const char *opname) const
+{
+ const Type_handler *handler= type_handler();
+ if (handler->can_return_decimal())
+ return false;
+ my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
+ handler->name().ptr(), opname);
+ return true;
+}
+
+
bool Item::check_type_can_return_real(const char *opname) const
{
const Type_handler *handler= type_handler();
@@ -1080,6 +1091,50 @@ bool Item::check_type_can_return_real(const char *opname) const
}
+bool Item::check_type_can_return_date(const char *opname) const
+{
+ const Type_handler *handler= type_handler();
+ if (handler->can_return_date())
+ return false;
+ my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
+ handler->name().ptr(), opname);
+ return true;
+}
+
+
+bool Item::check_type_can_return_time(const char *opname) const
+{
+ const Type_handler *handler= type_handler();
+ if (handler->can_return_time())
+ return false;
+ my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
+ handler->name().ptr(), opname);
+ return true;
+}
+
+
+bool Item::check_type_can_return_str(const char *opname) const
+{
+ const Type_handler *handler= type_handler();
+ if (handler->can_return_str())
+ return false;
+ my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
+ handler->name().ptr(), opname);
+ return true;
+}
+
+
+bool Item::check_type_can_return_text(const char *opname) const
+{
+ const Type_handler *handler= type_handler();
+ if (handler->can_return_text())
+ return false;
+ my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
+ handler->name().ptr(), opname);
+ return true;
+}
+
+
bool Item::check_type_scalar(const char *opname) const
{
const Type_handler *handler= type_handler();
@@ -1109,7 +1164,7 @@ void Item::set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs)
if (!cs->ctype || cs->mbminlen > 1)
{
str+= cs->cset->scan(cs, str, str + length, MY_SEQ_SPACES);
- length-= str - str_start;
+ length-= (uint)(str - str_start);
}
else
{
@@ -6398,8 +6453,8 @@ void Item_field::save_org_in_field(Field *to,
fast_field_copier fast_field_copier_func)
{
DBUG_ENTER("Item_field::save_org_in_field");
- DBUG_PRINT("enter", ("setup: 0x%lx data: 0x%lx",
- (ulong) to, (ulong) fast_field_copier_func));
+ DBUG_PRINT("enter", ("setup: %p data: %p",
+ to, fast_field_copier_func));
if (fast_field_copier_func)
{
if (field->is_null())
diff --git a/sql/item.h b/sql/item.h
index ddaf44770ab..0e7db0d6575 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -89,6 +89,7 @@ public:
const char *dbug_print_item(Item *item);
+class Virtual_tmp_table;
class sp_head;
class Protocol;
struct TABLE_LIST;
@@ -659,7 +660,8 @@ protected:
return value;
}
bool get_date_with_conversion_from_item(Item *item,
- MYSQL_TIME *ltime, uint fuzzydate)
+ MYSQL_TIME *ltime,
+ ulonglong fuzzydate)
{
DBUG_ASSERT(fixed == 1);
return (null_value= item->get_date_with_conversion(ltime, fuzzydate));
@@ -1385,14 +1387,14 @@ public:
virtual longlong val_datetime_packed()
{
MYSQL_TIME ltime;
- uint fuzzydate= TIME_FUZZY_DATES | TIME_INVALID_DATES;
+ ulonglong fuzzydate= TIME_FUZZY_DATES | TIME_INVALID_DATES;
return get_date_with_conversion(&ltime, fuzzydate) ? 0 : pack_time(&ltime);
}
// Get a TIME value in numeric packed format for comparison
virtual longlong val_time_packed()
{
MYSQL_TIME ltime;
- uint fuzzydate= TIME_FUZZY_DATES | TIME_INVALID_DATES | TIME_TIME_ONLY;
+ ulonglong fuzzydate= TIME_FUZZY_DATES | TIME_INVALID_DATES | TIME_TIME_ONLY;
return get_date(&ltime, fuzzydate) ? 0 : pack_time(&ltime);
}
// Get a temporal value in packed DATE/DATETIME or TIME format
@@ -1710,7 +1712,12 @@ public:
bool check_type_or_binary(const char *opname, const Type_handler *handler) const;
bool check_type_general_purpose_string(const char *opname) const;
bool check_type_can_return_int(const char *opname) const;
+ bool check_type_can_return_decimal(const char *opname) const;
bool check_type_can_return_real(const char *opname) const;
+ bool check_type_can_return_str(const char *opname) const;
+ bool check_type_can_return_text(const char *opname) const;
+ bool check_type_can_return_date(const char *opname) const;
+ bool check_type_can_return_time(const char *opname) const;
// It is not row => null inside is impossible
virtual bool null_inside() { return 0; }
// used in row subselects to get value of elements
@@ -2088,16 +2095,12 @@ public:
class Item_spvar_args: public Item_args
{
- TABLE *m_table;
+ Virtual_tmp_table *m_table;
public:
Item_spvar_args():Item_args(), m_table(NULL) { }
~Item_spvar_args();
bool row_create_items(THD *thd, List<Spvar_definition> *list);
- Field *get_row_field(uint i) const
- {
- DBUG_ASSERT(m_table);
- return m_table->field[i];
- }
+ Field *get_row_field(uint i) const;
};
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 3ec382b0541..0d57066c2d2 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2325,7 +2325,7 @@ Item_func_ifnull::str_op(String *str)
}
-bool Item_func_ifnull::date_op(MYSQL_TIME *ltime, uint fuzzydate)
+bool Item_func_ifnull::date_op(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
DBUG_ASSERT(fixed == 1);
if (!args[0]->get_date_with_conversion(ltime, fuzzydate & ~TIME_FUZZY_DATES))
@@ -2798,7 +2798,7 @@ Item_func_nullif::decimal_op(my_decimal * decimal_value)
bool
-Item_func_nullif::date_op(MYSQL_TIME *ltime, uint fuzzydate)
+Item_func_nullif::date_op(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
DBUG_ASSERT(fixed == 1);
if (!compare())
@@ -2938,7 +2938,7 @@ my_decimal *Item_func_case::decimal_op(my_decimal *decimal_value)
}
-bool Item_func_case::date_op(MYSQL_TIME *ltime, uint fuzzydate)
+bool Item_func_case::date_op(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
DBUG_ASSERT(fixed == 1);
Item *item= find_item();
@@ -3349,7 +3349,7 @@ double Item_func_coalesce::real_op()
}
-bool Item_func_coalesce::date_op(MYSQL_TIME *ltime,uint fuzzydate)
+bool Item_func_coalesce::date_op(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
DBUG_ASSERT(fixed == 1);
for (uint i= 0; i < arg_count; i++)
@@ -3601,7 +3601,7 @@ uchar *in_row::get_value(Item *item)
void in_row::set(uint pos, Item *item)
{
DBUG_ENTER("in_row::set");
- DBUG_PRINT("enter", ("pos: %u item: 0x%lx", pos, (ulong) item));
+ DBUG_PRINT("enter", ("pos: %u item: %p", pos,item));
((cmp_item_row*) base)[pos].store_value_by_template(current_thd, &tmp, item);
DBUG_VOID_RETURN;
}
@@ -3842,7 +3842,7 @@ cmp_item* cmp_item_row::make_same()
cmp_item_row::~cmp_item_row()
{
DBUG_ENTER("~cmp_item_row");
- DBUG_PRINT("enter",("this: 0x%lx", (long) this));
+ DBUG_PRINT("enter",("this: %p", this));
if (comparators)
{
for (uint i= 0; i < n; i++)
@@ -5374,7 +5374,7 @@ void Regexp_processor_pcre::set_recursion_limit(THD *thd)
DBUG_ASSERT(thd == current_thd);
stack_used= available_stack_size(thd->thread_stack, &stack_used);
m_pcre_extra.match_limit_recursion=
- (my_thread_stack_size - STACK_MIN_SIZE - stack_used)/my_pcre_frame_size;
+ (ulong)((my_thread_stack_size - STACK_MIN_SIZE - stack_used)/my_pcre_frame_size);
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 0756899f47c..f0862608463 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -930,6 +930,8 @@ public:
class Item_func_strcmp :public Item_long_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_str(0, 2); }
String value1, value2;
DTCollation cmp_collation;
public:
@@ -993,7 +995,7 @@ public:
longlong int_op();
String *str_op(String *);
my_decimal *decimal_op(my_decimal *);
- bool date_op(MYSQL_TIME *ltime,uint fuzzydate);
+ bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate);
void fix_length_and_dec()
{
if (!aggregate_for_result(func_name(), args, arg_count, true))
@@ -1065,7 +1067,7 @@ public:
longlong int_op();
String *str_op(String *str);
my_decimal *decimal_op(my_decimal *);
- bool date_op(MYSQL_TIME *ltime,uint fuzzydate);
+ bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate);
void fix_length_and_dec()
{
Item_func_case_abbreviation2::fix_length_and_dec2(args);
@@ -1097,7 +1099,7 @@ public:
:Item_func_case_abbreviation2(thd, a, b, c)
{ }
- bool date_op(MYSQL_TIME *ltime, uint fuzzydate)
+ bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
return get_date_with_conversion_from_item(find_item(), ltime, fuzzydate);
}
@@ -1210,7 +1212,7 @@ public:
Item_func_hybrid_field_type::cleanup();
arg_count= 2; // See the comment to the constructor
}
- bool date_op(MYSQL_TIME *ltime, uint fuzzydate);
+ bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate);
double real_op();
longlong int_op();
String *str_op(String *str);
@@ -2099,7 +2101,7 @@ public:
longlong int_op();
String *str_op(String *);
my_decimal *decimal_op(my_decimal *);
- bool date_op(MYSQL_TIME *ltime, uint fuzzydate);
+ bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate);
bool fix_fields(THD *thd, Item **ref);
table_map not_null_tables() const { return 0; }
const char *func_name() const { return "case"; }
@@ -2829,6 +2831,11 @@ public:
*/
class Item_func_regexp_instr :public Item_long_func
{
+ bool check_arguments() const
+ {
+ return args[0]->check_type_can_return_str(func_name()) ||
+ args[1]->check_type_can_return_text(func_name());
+ }
Regexp_processor_pcre re;
DTCollation cmp_collation;
public:
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 32f47ae5b23..6edeade0244 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -3302,7 +3302,7 @@ Create_udf_func Create_udf_func::s_singleton;
Item*
Create_udf_func::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list)
{
- udf_func *udf= find_udf(name->str, name->length);
+ udf_func *udf= find_udf(name->str, (uint) name->length);
DBUG_ASSERT(udf);
return create(thd, udf, item_list);
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 2af7338b3c6..28690ff2bee 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -218,6 +218,58 @@ bool Item_func::check_argument_types_can_return_real(uint start,
}
+bool Item_func::check_argument_types_can_return_text(uint start,
+ uint end) const
+{
+ for (uint i= start; i < end ; i++)
+ {
+ DBUG_ASSERT(i < arg_count);
+ if (args[i]->check_type_can_return_text(func_name()))
+ return true;
+ }
+ return false;
+}
+
+
+bool Item_func::check_argument_types_can_return_str(uint start,
+ uint end) const
+{
+ for (uint i= start; i < end ; i++)
+ {
+ DBUG_ASSERT(i < arg_count);
+ if (args[i]->check_type_can_return_str(func_name()))
+ return true;
+ }
+ return false;
+}
+
+
+bool Item_func::check_argument_types_can_return_date(uint start,
+ uint end) const
+{
+ for (uint i= start; i < end ; i++)
+ {
+ DBUG_ASSERT(i < arg_count);
+ if (args[i]->check_type_can_return_date(func_name()))
+ return true;
+ }
+ return false;
+}
+
+
+bool Item_func::check_argument_types_can_return_time(uint start,
+ uint end) const
+{
+ for (uint i= start; i < end ; i++)
+ {
+ DBUG_ASSERT(i < arg_count);
+ if (args[i]->check_type_can_return_time(func_name()))
+ return true;
+ }
+ return false;
+}
+
+
bool Item_func::check_argument_types_scalar(uint start, uint end) const
{
for (uint i= start; i < end; i++)
diff --git a/sql/item_func.h b/sql/item_func.h
index 04045eefafb..de213df0fc5 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -48,6 +48,10 @@ protected:
uint start, uint end) const;
bool check_argument_types_can_return_int(uint start, uint end) const;
bool check_argument_types_can_return_real(uint start, uint end) const;
+ bool check_argument_types_can_return_str(uint start, uint end) const;
+ bool check_argument_types_can_return_text(uint start, uint end) const;
+ bool check_argument_types_can_return_date(uint start, uint end) const;
+ bool check_argument_types_can_return_time(uint start, uint end) const;
public:
table_map not_null_tables_cache;
@@ -485,8 +489,8 @@ public:
bool get_date_from_date_op(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
return date_op(ltime,
- fuzzydate |
- (field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0));
+ (fuzzydate |
+ (field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0)));
}
// Value methods that involve conversion
@@ -606,7 +610,7 @@ public:
field type is a temporal type.
@return The result of the operation.
*/
- virtual bool date_op(MYSQL_TIME *res, uint fuzzy_date)= 0;
+ virtual bool date_op(MYSQL_TIME *res, ulonglong fuzzy_date)= 0;
};
@@ -665,7 +669,11 @@ public:
Item_func_hybrid_field_type(thd, list)
{ }
String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
- bool date_op(MYSQL_TIME *ltime, uint fuzzydate) { DBUG_ASSERT(0); return true; }
+ bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate)
+ {
+ DBUG_ASSERT(0);
+ return true;
+ }
};
@@ -1178,6 +1186,8 @@ public:
class Item_dec_func :public Item_real_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_real(0, arg_count); }
public:
Item_dec_func(THD *thd, Item *a): Item_real_func(thd, a) {}
Item_dec_func(THD *thd, Item *a, Item *b): Item_real_func(thd, a, b) {}
@@ -1403,6 +1413,8 @@ class Item_func_rand :public Item_real_func
{
struct my_rnd_struct *rand;
bool first_eval; // TRUE if val_real() is called 1st time
+ bool check_arguments() const
+ { return check_argument_types_can_return_int(0, arg_count); }
public:
Item_func_rand(THD *thd, Item *a):
Item_real_func(thd, a), rand(0), first_eval(TRUE) {}
@@ -1426,6 +1438,8 @@ private:
class Item_func_sign :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_real(func_name()); }
public:
Item_func_sign(THD *thd, Item *a): Item_long_func(thd, a) {}
const char *func_name() const { return "sign"; }
@@ -1441,6 +1455,8 @@ class Item_func_units :public Item_real_func
{
char *name;
double mul,add;
+ bool check_arguments() const
+ { return check_argument_types_can_return_real(0, arg_count); }
public:
Item_func_units(THD *thd, char *name_arg, Item *a, double mul_arg,
double add_arg):
@@ -1590,14 +1606,23 @@ public:
};
-class Item_func_octet_length :public Item_long_func
+class Item_long_func_length: public Item_long_func
+{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_str(func_name()); }
+public:
+ Item_long_func_length(THD *thd, Item *a): Item_long_func(thd, a) {}
+ void fix_length_and_dec() { max_length=10; }
+};
+
+
+class Item_func_octet_length :public Item_long_func_length
{
String value;
public:
- Item_func_octet_length(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_octet_length(THD *thd, Item *a): Item_long_func_length(thd, a) {}
longlong val_int();
const char *func_name() const { return "octet_length"; }
- void fix_length_and_dec() { max_length=10; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_octet_length>(thd, mem_root, this); }
};
@@ -1617,20 +1642,21 @@ public:
{ return get_item_copy<Item_func_bit_length>(thd, mem_root, this); }
};
-class Item_func_char_length :public Item_long_func
+class Item_func_char_length :public Item_long_func_length
{
String value;
public:
- Item_func_char_length(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_char_length(THD *thd, Item *a): Item_long_func_length(thd, a) {}
longlong val_int();
const char *func_name() const { return "char_length"; }
- void fix_length_and_dec() { max_length=10; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_char_length>(thd, mem_root, this); }
};
class Item_func_coercibility :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_str(func_name()); }
public:
Item_func_coercibility(THD *thd, Item *a): Item_long_func(thd, a) {}
longlong val_int();
@@ -1657,6 +1683,11 @@ public:
*/
class Item_func_locate :public Item_long_func
{
+ bool check_arguments() const
+ {
+ return check_argument_types_can_return_str(0, 2) ||
+ (arg_count > 2 && args[2]->check_type_can_return_int(func_name()));
+ }
String value1,value2;
DTCollation cmp_collation;
public:
@@ -1694,6 +1725,8 @@ public:
class Item_func_ascii :public Item_long_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_str(0, arg_count); }
String value;
public:
Item_func_ascii(THD *thd, Item *a): Item_long_func(thd, a) {}
@@ -1706,6 +1739,8 @@ public:
class Item_func_ord :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_str(func_name()); }
String value;
public:
Item_func_ord(THD *thd, Item *a): Item_long_func(thd, a) {}
@@ -1718,6 +1753,8 @@ public:
class Item_func_find_in_set :public Item_long_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_str(0, 2); }
String value,value2;
uint enum_value;
ulonglong enum_bit;
@@ -1736,6 +1773,8 @@ public:
class Item_func_bit: public Item_longlong_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_int(0, arg_count); }
public:
Item_func_bit(THD *thd, Item *a, Item *b): Item_longlong_func(thd, a, b) {}
Item_func_bit(THD *thd, Item *a): Item_longlong_func(thd, a) {}
@@ -1772,6 +1811,8 @@ public:
class Item_func_bit_count :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_int(func_name()); }
public:
Item_func_bit_count(THD *thd, Item *a): Item_long_func(thd, a) {}
longlong val_int();
@@ -1822,6 +1863,8 @@ public:
class Item_func_last_insert_id :public Item_longlong_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_int(0, arg_count); }
public:
Item_func_last_insert_id(THD *thd): Item_longlong_func(thd) {}
Item_func_last_insert_id(THD *thd, Item *a): Item_longlong_func(thd, a) {}
@@ -1845,6 +1888,11 @@ public:
class Item_func_benchmark :public Item_long_func
{
+ bool check_arguments() const
+ {
+ return args[0]->check_type_can_return_int(func_name()) ||
+ args[1]->check_type_scalar(func_name());
+ }
public:
Item_func_benchmark(THD *thd, Item *count_expr, Item *expr):
Item_long_func(thd, count_expr, expr)
@@ -1867,6 +1915,8 @@ void item_func_sleep_free(void);
class Item_func_sleep :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_real(func_name()); }
public:
Item_func_sleep(THD *thd, Item *a): Item_long_func(thd, a) {}
void fix_length_and_dec() { fix_char_length(1); }
@@ -2147,6 +2197,11 @@ void mysql_ull_set_explicit_lock_duration(THD *thd);
class Item_func_get_lock :public Item_long_func
{
+ bool check_arguments() const
+ {
+ return args[0]->check_type_general_purpose_string(func_name()) ||
+ args[1]->check_type_can_return_real(func_name());
+ }
String value;
public:
Item_func_get_lock(THD *thd, Item *a, Item *b) :Item_long_func(thd, a, b) {}
@@ -2169,6 +2224,8 @@ class Item_func_get_lock :public Item_long_func
class Item_func_release_lock :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_general_purpose_string(func_name()); }
String value;
public:
Item_func_release_lock(THD *thd, Item *a): Item_long_func(thd, a) {}
@@ -2193,6 +2250,14 @@ public:
class Item_master_pos_wait :public Item_longlong_func
{
+ bool check_arguments() const
+ {
+ return
+ args[0]->check_type_general_purpose_string(func_name()) ||
+ args[1]->check_type_can_return_int(func_name()) ||
+ (arg_count > 2 && args[2]->check_type_can_return_int(func_name())) ||
+ (arg_count > 3 && args[3]->check_type_general_purpose_string(func_name()));
+ }
String value;
public:
Item_master_pos_wait(THD *thd, Item *a, Item *b)
@@ -2215,6 +2280,11 @@ public:
class Item_master_gtid_wait :public Item_long_func
{
+ bool check_arguments() const
+ {
+ return args[0]->check_type_general_purpose_string(func_name()) ||
+ (arg_count > 1 && args[1]->check_type_can_return_real(func_name()));
+ }
String value;
public:
Item_master_gtid_wait(THD *thd, Item *a)
@@ -2319,12 +2389,6 @@ public:
bool update();
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
- table_map used_tables() const
- {
- return used_tables_cache | RAND_TABLE_BIT;
- }
- bool const_item() const { return 0; }
- bool is_expensive() { return 1; }
void print(String *str, enum_query_type query_type);
enum precedence precedence() const { return ASSIGN_PRECEDENCE; }
void print_as_stmt(String *str, enum_query_type query_type);
@@ -2578,6 +2642,8 @@ public:
class Item_func_is_free_lock :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_general_purpose_string(func_name()); }
String value;
public:
Item_func_is_free_lock(THD *thd, Item *a): Item_long_func(thd, a) {}
@@ -2594,6 +2660,8 @@ public:
class Item_func_is_used_lock :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_general_purpose_string(func_name()); }
String value;
public:
Item_func_is_used_lock(THD *thd, Item *a): Item_long_func(thd, a) {}
diff --git a/sql/item_inetfunc.cc b/sql/item_inetfunc.cc
index c4cb9b2bae2..c434953ad43 100644
--- a/sql/item_inetfunc.cc
+++ b/sql/item_inetfunc.cc
@@ -211,13 +211,13 @@ String *Item_func_inet_str_base::val_str_ascii(String *buffer)
IPv4-part differently on different platforms.
*/
-static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
+static bool str_to_ipv4(const char *str, size_t str_length, in_addr *ipv4_address)
{
if (str_length < 7)
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): "
"invalid IPv4 address: too short.",
- str_length, str));
+ (int) str_length, str));
return false;
}
@@ -225,7 +225,7 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): "
"invalid IPv4 address: too long.",
- str_length, str));
+ (int) str_length, str));
return false;
}
@@ -236,7 +236,7 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
int dot_count= 0;
char c= 0;
- while (((p - str) < str_length) && *p)
+ while (((p - str) < (int)str_length) && *p)
{
c= *p++;
@@ -248,7 +248,7 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): invalid IPv4 address: "
"too many characters in a group.",
- str_length, str));
+ (int) str_length, str));
return false;
}
@@ -258,7 +258,7 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): invalid IPv4 address: "
"invalid byte value.",
- str_length, str));
+ (int) str_length, str));
return false;
}
}
@@ -268,7 +268,7 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): invalid IPv4 address: "
"too few characters in a group.",
- str_length, str));
+ (int) str_length, str));
return false;
}
@@ -281,7 +281,7 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
if (dot_count > 3)
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): invalid IPv4 address: "
- "too many dots.", str_length, str));
+ "too many dots.", (int) str_length, str));
return false;
}
}
@@ -289,7 +289,7 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): invalid IPv4 address: "
"invalid character at pos %d.",
- str_length, str, (int) (p - str)));
+ (int) str_length, str, (int) (p - str)));
return false;
}
}
@@ -297,7 +297,7 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
if (c == '.')
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): invalid IPv4 address: "
- "ending at '.'.", str_length, str));
+ "ending at '.'.", (int) str_length, str));
return false;
}
@@ -305,14 +305,14 @@ static bool str_to_ipv4(const char *str, int str_length, in_addr *ipv4_address)
{
DBUG_PRINT("error", ("str_to_ipv4(%.*s): invalid IPv4 address: "
"too few groups.",
- str_length, str));
+ (int) str_length, str));
return false;
}
ipv4_bytes[3]= (unsigned char) byte_value;
DBUG_PRINT("info", ("str_to_ipv4(%.*s): valid IPv4 address: %d.%d.%d.%d",
- str_length, str,
+ (int) str_length, str,
ipv4_bytes[0], ipv4_bytes[1],
ipv4_bytes[2], ipv4_bytes[3]));
return true;
@@ -493,7 +493,7 @@ static bool str_to_ipv6(const char *str, int str_length, in6_addr *ipv6_address)
return false;
}
- int bytes_to_move= dst - gap_ptr;
+ int bytes_to_move= (int)(dst - gap_ptr);
for (int i= 1; i <= bytes_to_move; ++i)
{
diff --git a/sql/item_inetfunc.h b/sql/item_inetfunc.h
index 33586c29175..13ce003a374 100644
--- a/sql/item_inetfunc.h
+++ b/sql/item_inetfunc.h
@@ -26,6 +26,8 @@
class Item_func_inet_aton : public Item_longlong_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_text(0, arg_count); }
public:
Item_func_inet_aton(THD *thd, Item *a): Item_longlong_func(thd, a) {}
longlong val_int();
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 1542b42b1fb..f804f83f122 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -48,7 +48,7 @@ static bool eq_ascii_string(const CHARSET_INFO *cs,
}
-static bool append_simple(String *s, const char *a, uint a_len)
+static bool append_simple(String *s, const char *a, size_t a_len)
{
if (!s->realloc_with_extra_if_needed(s->length() + a_len))
{
@@ -60,7 +60,7 @@ static bool append_simple(String *s, const char *a, uint a_len)
}
-static inline bool append_simple(String *s, const uchar *a, uint a_len)
+static inline bool append_simple(String *s, const uchar *a, size_t a_len)
{
return append_simple(s, (const char *) a, a_len);
}
@@ -255,7 +255,7 @@ void report_json_error_ex(String *js, json_engine_t *je,
Sql_condition::enum_warning_level lv)
{
THD *thd= current_thd;
- int position= (const char *) je->s.c_str - js->ptr();
+ int position= (int)((const char *) je->s.c_str - js->ptr());
uint code;
n_param++;
@@ -312,7 +312,7 @@ static void report_path_error_ex(String *ps, json_path_t *p,
Sql_condition::enum_warning_level lv)
{
THD *thd= current_thd;
- int position= (const char *) p->s.c_str - ps->ptr() + 1;
+ int position= (int)((const char *) p->s.c_str - ps->ptr() + 1);
uint code;
n_param++;
@@ -539,7 +539,7 @@ bool Item_func_json_query::check_and_get_value(json_engine_t *je, String *res,
return true;
}
- res->set((const char *) je->value, je->s.c_str - value, je->s.cs);
+ res->set((const char *) je->value, (uint32)(je->s.c_str - value), je->s.cs);
return false;
}
@@ -742,7 +742,8 @@ String *Item_func_json_extract::read_json(String *str,
json_path_t p;
const uchar *value;
int not_first_value= 0;
- uint n_arg, v_len;
+ uint n_arg;
+ size_t v_len;
int possible_multiple_values;
if ((null_value= args[0]->null_value))
@@ -1530,7 +1531,8 @@ String *Item_func_json_array_append::val_str(String *str)
{
json_engine_t je;
String *js= args[0]->val_json(&tmp_js);
- uint n_arg, n_path, str_rest_len;
+ uint n_arg, n_path;
+ size_t str_rest_len;
const uchar *ar_end;
DBUG_ASSERT(fixed == 1);
@@ -2863,7 +2865,7 @@ skip_search:
} while (json_read_keyname_chr(&je) == 0);
if (je.s.error)
goto err_return;
- key_len= key_end - key_start;
+ key_len= (int)(key_end - key_start);
if (!check_key_in_list(str, key_start, key_len))
{
@@ -3137,7 +3139,7 @@ String *Item_func_json_format::val_str(String *str)
{
if (arg_count > 1)
{
- tab_size= args[1]->val_int();
+ tab_size= (int)args[1]->val_int();
if (args[1]->null_value)
{
null_value= 1;
diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h
index 7da72dc7f89..77e7588be25 100644
--- a/sql/item_jsonfunc.h
+++ b/sql/item_jsonfunc.h
@@ -295,6 +295,12 @@ public:
class Item_func_json_length: public Item_long_func
{
+ bool check_arguments() const
+ {
+ return args[0]->check_type_can_return_text(func_name()) ||
+ (arg_count > 1 &&
+ args[1]->check_type_general_purpose_string(func_name()));
+ }
protected:
json_path_with_flags path;
String tmp_js;
@@ -312,6 +318,8 @@ public:
class Item_func_json_depth: public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_text(func_name()); }
protected:
String tmp_js;
public:
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index cc3c421f185..d9b375e7be1 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -257,7 +257,7 @@ String *Item_func_sha2::val_str_ascii(String *str)
str->realloc((uint) digest_length*2 + 1); /* Each byte as two nybbles */
/* Convert the large number to a string-hex representation. */
- array_to_hex((char *) str->ptr(), digest_buf, digest_length);
+ array_to_hex((char *) str->ptr(), digest_buf, (uint)digest_length);
/* We poked raw bytes in. We must inform the the String of its length. */
str->length((uint) digest_length*2); /* Each byte as two nybbles */
@@ -272,7 +272,7 @@ void Item_func_sha2::fix_length_and_dec()
maybe_null= 1;
max_length = 0;
- int sha_variant= args[1]->const_item() ? args[1]->val_int() : 512;
+ int sha_variant= (int)(args[1]->const_item() ? args[1]->val_int() : 512);
switch (sha_variant) {
case 0: // SHA-256 is the default
@@ -3796,12 +3796,12 @@ String *Item_func_like_range::val_str(String *str)
if (!res || args[0]->null_value || args[1]->null_value ||
nbytes < 0 || nbytes > MAX_BLOB_WIDTH ||
- min_str.alloc(nbytes) || max_str.alloc(nbytes))
+ min_str.alloc((size_t)nbytes) || max_str.alloc((size_t)nbytes))
goto err;
null_value=0;
if (cs->coll->like_range(cs, res->ptr(), res->length(),
- '\\', '_', '%', nbytes,
+ '\\', '_', '%', (size_t)nbytes,
(char*) min_str.ptr(), (char*) max_str.ptr(),
&min_len, &max_len))
goto err;
@@ -3878,7 +3878,7 @@ String *Item_load_file::val_str(String *str)
if ((file= mysql_file_open(key_file_loadfile,
file_name->ptr(), O_RDONLY, MYF(0))) < 0)
goto err;
- if (mysql_file_read(file, (uchar*) tmp_value.ptr(), stat_info.st_size,
+ if (mysql_file_read(file, (uchar*) tmp_value.ptr(), (size_t)stat_info.st_size,
MYF(MY_NABP)))
{
mysql_file_close(file, MYF(0));
@@ -4104,7 +4104,7 @@ String *Item_func_quote::val_str(String *str)
if ((mblen= cs->cset->wc_mb(cs, '\'', (uchar *) to, to_end)) <= 0)
goto toolong;
to+= mblen;
- new_length= to - str->ptr();
+ new_length= (uint)(to - str->ptr());
goto ret;
}
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index d73bd0b76d7..1c35588f884 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -1451,6 +1451,8 @@ public:
class Item_func_crc32 :public Item_long_func
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_str(func_name()); }
String value;
public:
Item_func_crc32(THD *thd, Item *a): Item_long_func(thd, a)
@@ -1462,11 +1464,12 @@ public:
{ return get_item_copy<Item_func_crc32>(thd, mem_root, this); }
};
-class Item_func_uncompressed_length : public Item_long_func
+class Item_func_uncompressed_length : public Item_long_func_length
{
String value;
public:
- Item_func_uncompressed_length(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_uncompressed_length(THD *thd, Item *a)
+ :Item_long_func_length(thd, a) {}
const char *func_name() const{return "uncompressed_length";}
void fix_length_and_dec() { max_length=10; maybe_null= true; }
longlong val_int();
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 55196b451de..84e1aae1ad5 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -58,7 +58,7 @@ Item_subselect::Item_subselect(THD *thd_arg):
changed(0), is_correlated(FALSE), with_recursive_reference(0)
{
DBUG_ENTER("Item_subselect::Item_subselect");
- DBUG_PRINT("enter", ("this: 0x%lx", (ulong) this));
+ DBUG_PRINT("enter", ("this: %p", this));
sortbuffer.str= 0;
#ifndef DBUG_OFF
@@ -84,8 +84,8 @@ void Item_subselect::init(st_select_lex *select_lex,
*/
DBUG_ENTER("Item_subselect::init");
- DBUG_PRINT("enter", ("select_lex: 0x%lx this: 0x%lx",
- (ulong) select_lex, (ulong) this));
+ DBUG_PRINT("enter", ("select_lex: %p this: %p",
+ select_lex, this));
unit= select_lex->master_unit();
if (unit->item)
@@ -130,7 +130,7 @@ void Item_subselect::init(st_select_lex *select_lex,
/* The subquery is an expression cache candidate */
upper->expr_cache_may_be_used[upper->parsing_place]= TRUE;
}
- DBUG_PRINT("info", ("engine: 0x%lx", (ulong)engine));
+ DBUG_PRINT("info", ("engine: %p", engine));
DBUG_VOID_RETURN;
}
@@ -215,7 +215,7 @@ void Item_allany_subselect::cleanup()
Item_subselect::~Item_subselect()
{
DBUG_ENTER("Item_subselect::~Item_subselect");
- DBUG_PRINT("enter", ("this: 0x%lx", (ulong) this));
+ DBUG_PRINT("enter", ("this: %p", this));
if (own_engine)
delete engine;
else
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 755ed7d302b..d6e42efd11c 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -36,9 +36,9 @@
used in Item_sum_*
*/
-ulonglong Item_sum::ram_limitation(THD *thd)
+size_t Item_sum::ram_limitation(THD *thd)
{
- return MY_MIN(thd->variables.tmp_memory_table_size,
+ return (size_t)MY_MIN(thd->variables.tmp_memory_table_size,
thd->variables.max_heap_table_size);
}
diff --git a/sql/item_sum.h b/sql/item_sum.h
index a160d0ee522..7845ed3318f 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -382,7 +382,7 @@ protected:
*/
Item **orig_args, *tmp_orig_args[2];
- static ulonglong ram_limitation(THD *thd);
+ static size_t ram_limitation(THD *thd);
public:
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index f1f69d0723b..d00120018b8 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -715,7 +715,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs,
{
const char *end=str+length;
uint i;
- long msec_length= 0;
+ int msec_length= 0;
while (str != end && !my_isdigit(cs,*str))
str++;
@@ -726,7 +726,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs,
const char *start= str;
for (value= 0; str != end && my_isdigit(cs, *str); str++)
value= value*10 + *str - '0';
- msec_length= 6 - (str - start);
+ msec_length= 6 - (int)(str - start);
values[i]= value;
while (str != end && !my_isdigit(cs,*str))
str++;
@@ -1062,7 +1062,7 @@ longlong Item_func_week::val_int()
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE))
return 0;
if (arg_count > 1)
- week_format= args[1]->val_int();
+ week_format= (uint)args[1]->val_int();
else
week_format= current_thd->variables.default_week_format;
return (longlong) calc_week(&ltime, week_mode(week_format), &year);
@@ -2457,7 +2457,7 @@ String *Item_char_typecast::copy(String *str, CHARSET_INFO *strcs)
null_value= 1; // EOM
return 0;
}
- check_truncation_with_warn(str, copier.source_end_pos() - str->ptr());
+ check_truncation_with_warn(str, (uint)(copier.source_end_pos() - str->ptr()));
return &tmp_value;
}
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 20ecb4774b3..94794c6789d 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -33,8 +33,31 @@ enum date_time_format_types
bool get_interval_value(Item *args,interval_type int_type, INTERVAL *interval);
+
+class Item_long_func_date_field: public Item_long_func
+{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_date(func_name()); }
+public:
+ Item_long_func_date_field(THD *thd, Item *a)
+ :Item_long_func(thd, a) { }
+};
+
+
+class Item_long_func_time_field: public Item_long_func
+{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_time(func_name()); }
+public:
+ Item_long_func_time_field(THD *thd, Item *a)
+ :Item_long_func(thd, a) { }
+};
+
+
class Item_func_period_add :public Item_long_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_int(0, 2); }
public:
Item_func_period_add(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
longlong val_int();
@@ -50,6 +73,8 @@ public:
class Item_func_period_diff :public Item_long_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_int(0, 2); }
public:
Item_func_period_diff(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
longlong val_int();
@@ -64,10 +89,10 @@ public:
};
-class Item_func_to_days :public Item_long_func
+class Item_func_to_days :public Item_long_func_date_field
{
public:
- Item_func_to_days(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_to_days(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "to_days"; }
void fix_length_and_dec()
@@ -91,6 +116,8 @@ public:
class Item_func_to_seconds :public Item_longlong_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_date(0, arg_count); }
public:
Item_func_to_seconds(THD *thd, Item *a): Item_longlong_func(thd, a) {}
longlong val_int();
@@ -115,10 +142,10 @@ public:
};
-class Item_func_dayofmonth :public Item_long_func
+class Item_func_dayofmonth :public Item_long_func_date_field
{
public:
- Item_func_dayofmonth(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_dayofmonth(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "dayofmonth"; }
void fix_length_and_dec()
@@ -195,10 +222,10 @@ public:
};
-class Item_func_dayofyear :public Item_long_func
+class Item_func_dayofyear :public Item_long_func_date_field
{
public:
- Item_func_dayofyear(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_dayofyear(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "dayofyear"; }
void fix_length_and_dec()
@@ -218,10 +245,10 @@ public:
};
-class Item_func_hour :public Item_long_func
+class Item_func_hour :public Item_long_func_time_field
{
public:
- Item_func_hour(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_hour(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "hour"; }
void fix_length_and_dec()
@@ -241,10 +268,10 @@ public:
};
-class Item_func_minute :public Item_long_func
+class Item_func_minute :public Item_long_func_time_field
{
public:
- Item_func_minute(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_minute(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "minute"; }
void fix_length_and_dec()
@@ -264,10 +291,10 @@ public:
};
-class Item_func_quarter :public Item_long_func
+class Item_func_quarter :public Item_long_func_date_field
{
public:
- Item_func_quarter(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_quarter(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "quarter"; }
void fix_length_and_dec()
@@ -287,10 +314,10 @@ public:
};
-class Item_func_second :public Item_long_func
+class Item_func_second :public Item_long_func_time_field
{
public:
- Item_func_second(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_second(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "second"; }
void fix_length_and_dec()
@@ -312,6 +339,11 @@ public:
class Item_func_week :public Item_long_func
{
+ bool check_arguments() const
+ {
+ return args[0]->check_type_can_return_date(func_name()) ||
+ (arg_count > 1 && args[1]->check_type_can_return_int(func_name()));
+ }
public:
Item_func_week(THD *thd, Item *a): Item_long_func(thd, a) {}
Item_func_week(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
@@ -339,8 +371,14 @@ public:
class Item_func_yearweek :public Item_long_func
{
+ bool check_arguments() const
+ {
+ return args[0]->check_type_can_return_date(func_name()) ||
+ args[1]->check_type_can_return_int(func_name());
+ }
public:
- Item_func_yearweek(THD *thd, Item *a, Item *b): Item_long_func(thd, a, b) {}
+ Item_func_yearweek(THD *thd, Item *a, Item *b)
+ :Item_long_func(thd, a, b) {}
longlong val_int();
const char *func_name() const { return "yearweek"; }
void fix_length_and_dec()
@@ -360,10 +398,10 @@ public:
};
-class Item_func_year :public Item_long_func
+class Item_func_year :public Item_long_func_date_field
{
public:
- Item_func_year(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_year(THD *thd, Item *a): Item_long_func_date_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "year"; }
enum_monotonicity_info get_monotonicity_info() const;
@@ -455,7 +493,11 @@ public:
}
double real_op() { DBUG_ASSERT(0); return 0; }
String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
- bool date_op(MYSQL_TIME *ltime, uint fuzzydate) { DBUG_ASSERT(0); return true; }
+ bool date_op(MYSQL_TIME *ltime, ulonglong fuzzydate)
+ {
+ DBUG_ASSERT(0);
+ return true;
+ }
};
@@ -780,6 +822,8 @@ public:
class Item_func_from_days :public Item_datefunc
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_int(func_name()); }
public:
Item_func_from_days(THD *thd, Item *a): Item_datefunc(thd, a) {}
const char *func_name() const { return "from_days"; }
@@ -836,6 +880,8 @@ public:
class Item_func_from_unixtime :public Item_datetimefunc
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_decimal(func_name()); }
Time_zone *tz;
public:
Item_func_from_unixtime(THD *thd, Item *a): Item_datetimefunc(thd, a) {}
@@ -863,6 +909,11 @@ class Time_zone;
*/
class Item_func_convert_tz :public Item_datetimefunc
{
+ bool check_arguments() const
+ {
+ return args[0]->check_type_can_return_date(func_name()) ||
+ check_argument_types_can_return_text(1, arg_count);
+ }
/*
If time zone parameters are constants we are caching objects that
represent them (we use separate from_tz_cached/to_tz_cached members
@@ -889,6 +940,8 @@ class Item_func_convert_tz :public Item_datetimefunc
class Item_func_sec_to_time :public Item_timefunc
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_decimal(func_name()); }
public:
Item_func_sec_to_time(THD *thd, Item *item): Item_timefunc(thd, item) {}
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
@@ -1128,6 +1181,8 @@ public:
class Item_func_makedate :public Item_datefunc
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_int(0, arg_count); }
public:
Item_func_makedate(THD *thd, Item *a, Item *b):
Item_datefunc(thd, a, b) {}
@@ -1157,6 +1212,8 @@ public:
class Item_func_timediff :public Item_timefunc
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_time(0, arg_count); }
public:
Item_func_timediff(THD *thd, Item *a, Item *b): Item_timefunc(thd, a, b) {}
const char *func_name() const { return "timediff"; }
@@ -1173,6 +1230,11 @@ public:
class Item_func_maketime :public Item_timefunc
{
+ bool check_arguments() const
+ {
+ return check_argument_types_can_return_int(0, 2) ||
+ args[2]->check_type_can_return_decimal(func_name());
+ }
public:
Item_func_maketime(THD *thd, Item *a, Item *b, Item *c):
Item_timefunc(thd, a, b, c)
@@ -1189,10 +1251,10 @@ public:
};
-class Item_func_microsecond :public Item_long_func
+class Item_func_microsecond :public Item_long_func_time_field
{
public:
- Item_func_microsecond(THD *thd, Item *a): Item_long_func(thd, a) {}
+ Item_func_microsecond(THD *thd, Item *a): Item_long_func_time_field(thd, a) {}
longlong val_int();
const char *func_name() const { return "microsecond"; }
void fix_length_and_dec()
@@ -1214,6 +1276,8 @@ public:
class Item_func_timestamp_diff :public Item_longlong_func
{
+ bool check_arguments() const
+ { return check_argument_types_can_return_date(0, arg_count); }
const interval_type int_type;
public:
Item_func_timestamp_diff(THD *thd, Item *a, Item *b, interval_type type_arg):
@@ -1279,6 +1343,8 @@ public:
class Item_func_last_day :public Item_datefunc
{
+ bool check_arguments() const
+ { return args[0]->check_type_can_return_date(func_name()); }
public:
Item_func_last_day(THD *thd, Item *a): Item_datefunc(thd, a) {}
const char *func_name() const { return "last_day"; }
diff --git a/sql/key.cc b/sql/key.cc
index 9e44bc2e6b0..3ee083e560f 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -374,7 +374,7 @@ void field_unpack(String *to, Field *field, const uchar *rec, uint max_length,
{
const char *tmp_end= tmp.ptr() + tmp.length();
while (tmp_end > tmp.ptr() && !*--tmp_end) ;
- tmp.length(tmp_end - tmp.ptr() + 1);
+ tmp.length((uint32)(tmp_end - tmp.ptr() + 1));
}
if (cs->mbmaxlen > 1 && prefix_key)
{
diff --git a/sql/lock.cc b/sql/lock.cc
index a45b93a0260..6fa68786b93 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -827,7 +827,7 @@ MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, uint flags)
we may allocate too much, but better safe than memory overrun.
And in the FLUSH case, the memory is released quickly anyway.
*/
- sql_lock->lock_count= locks - locks_buf;
+ sql_lock->lock_count= (uint)(locks - locks_buf);
DBUG_ASSERT(sql_lock->lock_count <= lock_count);
DBUG_PRINT("info", ("sql_lock->table_count %d sql_lock->lock_count %d",
sql_lock->table_count, sql_lock->lock_count));
diff --git a/sql/log.cc b/sql/log.cc
index 948bd7844bd..450f677d363 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1328,7 +1328,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
}
/* fill in user_host value: the format is "%s[%s] @ %s [%s]" */
- user_host_len= (strxnmov(user_host_buff, MAX_USER_HOST_SIZE,
+ user_host_len= (uint)(strxnmov(user_host_buff, MAX_USER_HOST_SIZE,
sctx->priv_user, "[",
sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""), "] @ ",
sctx->host ? sctx->host : "", " [",
@@ -5310,7 +5310,7 @@ bool MYSQL_BIN_LOG::write_event_buffer(uchar* buf, uint len)
if (!ebuf)
goto err;
- crypto.set_iv(iv, my_b_append_tell(&log_file));
+ crypto.set_iv(iv, (uint32)my_b_append_tell(&log_file));
/*
we want to encrypt everything, excluding the event length:
@@ -5537,9 +5537,9 @@ binlog_cache_mngr *THD::binlog_setup_trx_data()
cache_mngr= (binlog_cache_mngr*) my_malloc(sizeof(binlog_cache_mngr), MYF(MY_ZEROFILL));
if (!cache_mngr ||
open_cached_file(&cache_mngr->stmt_cache.cache_log, mysql_tmpdir,
- LOG_PREFIX, binlog_stmt_cache_size, MYF(MY_WME)) ||
+ LOG_PREFIX, (size_t)binlog_stmt_cache_size, MYF(MY_WME)) ||
open_cached_file(&cache_mngr->trx_cache.cache_log, mysql_tmpdir,
- LOG_PREFIX, binlog_cache_size, MYF(MY_WME)))
+ LOG_PREFIX, (size_t)binlog_cache_size, MYF(MY_WME)))
{
my_free(cache_mngr);
DBUG_RETURN(0); // Didn't manage to set it up
@@ -5668,8 +5668,8 @@ int THD::binlog_write_table_map(TABLE *table, bool is_transactional,
{
int error;
DBUG_ENTER("THD::binlog_write_table_map");
- DBUG_PRINT("enter", ("table: 0x%lx (%s: #%lu)",
- (long) table, table->s->table_name.str,
+ DBUG_PRINT("enter", ("table: %p (%s: #%lu)",
+ table, table->s->table_name.str,
table->s->table_map_id));
/* Ensure that all events in a GTID group are in the same cache */
@@ -5818,7 +5818,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
{
DBUG_ENTER("MYSQL_BIN_LOG::flush_and_set_pending_rows_event(event)");
DBUG_ASSERT(WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open());
- DBUG_PRINT("enter", ("event: 0x%lx", (long) event));
+ DBUG_PRINT("enter", ("event: %p", event));
int error= 0;
binlog_cache_mngr *const cache_mngr=
@@ -5829,7 +5829,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
binlog_cache_data *cache_data=
cache_mngr->get_binlog_cache_data(use_trans_cache(thd, is_transactional));
- DBUG_PRINT("info", ("cache_mngr->pending(): 0x%lx", (long) cache_data->pending()));
+ DBUG_PRINT("info", ("cache_mngr->pending(): %p", cache_data->pending()));
if (Rows_log_event* pending= cache_data->pending())
{
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 73987a562fa..21cc26905a9 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -838,19 +838,19 @@ query_event_uncompress(const Format_description_log_event *description_event,
if (end <= tmp)
return 1;
- int32 comp_len = len - (tmp - src) -
- (contain_checksum ? BINLOG_CHECKSUM_LEN : 0);
+ int32 comp_len = (int32)(len - (tmp - src) -
+ (contain_checksum ? BINLOG_CHECKSUM_LEN : 0));
uint32 un_len = binlog_get_uncompress_len(tmp);
// bad event
if (comp_len < 0 || un_len == 0)
return 1;
- *newlen = (tmp - src) + un_len;
+ *newlen = (ulong)(tmp - src) + un_len;
if(contain_checksum)
*newlen += BINLOG_CHECKSUM_LEN;
- uint32 alloc_size = ALIGN_SIZE(*newlen);
+ uint32 alloc_size = (uint32)ALIGN_SIZE(*newlen);
char *new_dst = NULL;
@@ -963,17 +963,17 @@ row_log_event_uncompress(const Format_description_log_event *description_event,
if (un_len == 0)
return 1;
- long comp_len = len - (tmp - src) -
- (contain_checksum ? BINLOG_CHECKSUM_LEN : 0);
+ int32 comp_len = (int32)(len - (tmp - src) -
+ (contain_checksum ? BINLOG_CHECKSUM_LEN : 0));
//bad event
if (comp_len <=0)
return 1;
- *newlen = (tmp - src) + un_len;
+ *newlen = ulong(tmp - src) + un_len;
if(contain_checksum)
*newlen += BINLOG_CHECKSUM_LEN;
- uint32 alloc_size = ALIGN_SIZE(*newlen);
+ size_t alloc_size = ALIGN_SIZE(*newlen);
*is_malloc = false;
if (alloc_size <= buf_size)
@@ -1626,7 +1626,7 @@ int Log_event_writer::write_header(uchar *pos, size_t len)
if (ctx)
{
uchar iv[BINLOG_IV_LENGTH];
- crypto->set_iv(iv, my_b_safe_tell(file));
+ crypto->set_iv(iv, (uint32)my_b_safe_tell(file));
if (encryption_ctx_init(ctx, crypto->key, crypto->key_length,
iv, sizeof(iv), ENCRYPTION_FLAG_ENCRYPT | ENCRYPTION_FLAG_NOPAD,
ENCRYPTION_KEY_SYSTEM_DATA, crypto->key_version))
@@ -2427,9 +2427,9 @@ void Log_event::print_header(IO_CACHE* file,
if (checksum_alg != BINLOG_CHECKSUM_ALG_OFF &&
checksum_alg != BINLOG_CHECKSUM_ALG_UNDEF)
{
- char checksum_buf[BINLOG_CHECKSUM_LEN * 2 + 4]; // to fit to "0x%lx "
+ char checksum_buf[BINLOG_CHECKSUM_LEN * 2 + 4]; // to fit to "%p "
size_t const bytes_written=
- my_snprintf(checksum_buf, sizeof(checksum_buf), "0x%08lx ", (ulong) crc);
+ my_snprintf(checksum_buf, sizeof(checksum_buf), "0x%08x ", crc);
my_b_printf(file, "%s ", get_type(&binlog_checksum_typelib, checksum_alg));
my_b_printf(file, checksum_buf, bytes_written);
}
@@ -3968,7 +3968,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
db(thd_arg->db), q_len((uint32) query_length),
thread_id(thd_arg->thread_id),
/* save the original thread id; we already know the server id */
- slave_proxy_id(thd_arg->variables.pseudo_thread_id),
+ slave_proxy_id((ulong)thd_arg->variables.pseudo_thread_id),
flags2_inited(1), sql_mode_inited(1), charset_inited(1),
sql_mode(thd_arg->variables.sql_mode),
auto_increment_increment(thd_arg->variables.auto_increment_increment),
@@ -4172,7 +4172,7 @@ get_str_len_and_pointer(const Log_event::Byte **src,
if (length > 0)
{
if (*src + length >= end)
- return *src + length - end + 1; // Number of bytes missing
+ return (int)(*src + length - end + 1); // Number of bytes missing
*dst= (char *)*src + 1; // Will be copied later
}
*len= length;
@@ -4273,7 +4273,7 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
data_len = event_len - (common_header_len + post_header_len);
buf+= common_header_len;
- slave_proxy_id= thread_id = uint4korr(buf + Q_THREAD_ID_OFFSET);
+ thread_id = slave_proxy_id = uint4korr(buf + Q_THREAD_ID_OFFSET);
exec_time = uint4korr(buf + Q_EXEC_TIME_OFFSET);
db_len = (uchar)buf[Q_DB_LEN_OFFSET]; // TODO: add a check of all *_len vars
error_code = uint2korr(buf + Q_ERR_CODE_OFFSET);
@@ -4347,8 +4347,8 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
break;
}
case Q_CATALOG_NZ_CODE:
- DBUG_PRINT("info", ("case Q_CATALOG_NZ_CODE; pos: 0x%lx; end: 0x%lx",
- (ulong) pos, (ulong) end));
+ DBUG_PRINT("info", ("case Q_CATALOG_NZ_CODE; pos:%p; end:%p",
+ pos, end));
if (get_str_len_and_pointer(&pos, &catalog, &catalog_len, end))
{
DBUG_PRINT("info", ("query= 0"));
@@ -6490,7 +6490,7 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
thd_arg->thread_specific_used ? LOG_EVENT_THREAD_SPECIFIC_F : 0,
using_trans),
thread_id(thd_arg->thread_id),
- slave_proxy_id(thd_arg->variables.pseudo_thread_id),
+ slave_proxy_id((ulong)thd_arg->variables.pseudo_thread_id),
num_fields(0),fields(0),
field_lens(0),field_block_len(0),
table_name(table_name_arg ? table_name_arg : ""),
@@ -6614,7 +6614,7 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
char* buf_end = (char*)buf + event_len;
/* this is the beginning of the post-header */
const char* data_head = buf + description_event->common_header_len;
- slave_proxy_id= thread_id= uint4korr(data_head + L_THREAD_ID_OFFSET);
+ thread_id= slave_proxy_id= uint4korr(data_head + L_THREAD_ID_OFFSET);
exec_time = uint4korr(data_head + L_EXEC_TIME_OFFSET);
skip_lines = uint4korr(data_head + L_SKIP_LINES_OFFSET);
table_name_len = (uint)data_head[L_TBL_LEN_OFFSET];
@@ -8680,7 +8680,7 @@ User_var_log_event(const char* buf, uint event_len,
Old events will not have this extra byte, thence,
we keep the flags set to UNDEF_F.
*/
- uint bytes_read= ((val + val_len) - buf_start);
+ size_t bytes_read= ((val + val_len) - buf_start);
#ifdef DBUG_ASSERT_EXISTS
bool old_pre_checksum_fd= description_event->is_version_before_checksum(
&description_event->server_version_split);
@@ -10389,7 +10389,7 @@ void Rows_log_event::uncompress_buf()
if (new_buf)
{
if(!binlog_buf_uncompress((char *)m_rows_buf, (char *)new_buf,
- m_rows_cur - m_rows_buf, &un_len))
+ (uint32)(m_rows_cur - m_rows_buf), &un_len))
{
my_free(m_rows_buf);
m_rows_buf = new_buf;
@@ -10425,9 +10425,9 @@ int Rows_log_event::get_data_size()
uchar *end= net_store_length(buf, m_width);
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
- return 6 + no_bytes_in_map(&m_cols) + (end - buf) +
+ return (int)(6 + no_bytes_in_map(&m_cols) + (end - buf) +
(general_type_code == UPDATE_ROWS_EVENT ? no_bytes_in_map(&m_cols_ai) : 0) +
- (m_rows_cur - m_rows_buf););
+ m_rows_cur - m_rows_buf););
int data_size= 0;
Log_event_type type = get_type_code();
@@ -10463,7 +10463,7 @@ int Rows_log_event::do_add_row_data(uchar *row_data, size_t length)
would save binlog space. TODO
*/
DBUG_ENTER("Rows_log_event::do_add_row_data");
- DBUG_PRINT("enter", ("row_data: 0x%lx length: %lu", (ulong) row_data,
+ DBUG_PRINT("enter", ("row_data:%p length: %lu", row_data,
(ulong) length));
/*
@@ -10843,8 +10843,8 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
table= m_table= rgi->m_table_map.get_table(m_table_id);
- DBUG_PRINT("debug", ("m_table: 0x%lx, m_table_id: %lu%s",
- (ulong) m_table, m_table_id,
+ DBUG_PRINT("debug", ("m_table:%p, m_table_id: %lu%s",
+ m_table, m_table_id,
table && master_had_triggers ?
" (master had triggers)" : ""));
if (table)
@@ -10964,8 +10964,8 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
m_curr_row_end.
*/
- DBUG_PRINT("info", ("curr_row: 0x%lu; curr_row_end: 0x%lu; rows_end: 0x%lu",
- (ulong) m_curr_row, (ulong) m_curr_row_end, (ulong) m_rows_end));
+ DBUG_PRINT("info", ("curr_row: %p; curr_row_end: %p; rows_end:%p",
+ m_curr_row, m_curr_row_end, m_rows_end));
if (!m_curr_row_end && !error)
error= unpack_current_row(rgi);
diff --git a/sql/log_event.h b/sql/log_event.h
index dbacb18528d..c8f3241cb3d 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -5127,7 +5127,7 @@ static inline bool copy_event_cache_to_string_and_reinit(IO_CACHE *cache, LEX_ST
String tmp;
reinit_io_cache(cache, READ_CACHE, 0L, FALSE, FALSE);
- if (tmp.append(cache, cache->end_of_file))
+ if (tmp.append(cache, (uint32)cache->end_of_file))
goto err;
reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE);
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index a7f491671c1..2c079a34d56 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -364,10 +364,10 @@ copy_extra_record_fields(TABLE *table,
my_ptrdiff_t master_fields)
{
DBUG_ENTER("copy_extra_record_fields(table, master_reclen, master_fields)");
- DBUG_PRINT("info", ("Copying to 0x%lx "
+ DBUG_PRINT("info", ("Copying to %p "
"from field %lu at offset %lu "
"to field %d at offset %lu",
- (long) table->record[0],
+ table->record[0],
(ulong) master_fields, (ulong) master_reclength,
table->s->fields, table->s->reclength));
/*
@@ -625,8 +625,8 @@ replace_record(THD *thd, TABLE *table,
static int find_and_fetch_row(TABLE *table, uchar *key)
{
DBUG_ENTER("find_and_fetch_row(TABLE *table, uchar *key, uchar *record)");
- DBUG_PRINT("enter", ("table: 0x%lx, key: 0x%lx record: 0x%lx",
- (long) table, (long) key, (long) table->record[1]));
+ DBUG_PRINT("enter", ("table: %p, key: %p record: %p",
+ table, key, table->record[1]));
DBUG_ASSERT(table->in_use != NULL);
@@ -1254,8 +1254,8 @@ Old_rows_log_event::Old_rows_log_event(const char *buf, uint event_len,
const uchar* const ptr_rows_data= (const uchar*) ptr_after_width;
size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf);
- DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %lu",
- m_table_id, m_flags, m_width, (ulong) data_size));
+ DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %zu",
+ m_table_id, m_flags, m_width, data_size));
DBUG_DUMP("rows_data", (uchar*) ptr_rows_data, data_size);
m_rows_buf= (uchar*) my_malloc(data_size, MYF(MY_WME));
@@ -1290,8 +1290,8 @@ int Old_rows_log_event::get_data_size()
uchar *end= net_store_length(buf, (m_width + 7) / 8);
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
- return 6 + no_bytes_in_map(&m_cols) + (end - buf) +
- (m_rows_cur - m_rows_buf););
+ return (int)(6 + no_bytes_in_map(&m_cols) + (end - buf) +
+ m_rows_cur - m_rows_buf););
int data_size= ROWS_HEADER_LEN;
data_size+= no_bytes_in_map(&m_cols);
data_size+= (uint) (end - buf);
@@ -1310,8 +1310,8 @@ int Old_rows_log_event::do_add_row_data(uchar *row_data, size_t length)
would save binlog space. TODO
*/
DBUG_ENTER("Old_rows_log_event::do_add_row_data");
- DBUG_PRINT("enter", ("row_data: 0x%lx length: %lu", (ulong) row_data,
- (ulong) length));
+ DBUG_PRINT("enter", ("row_data: %p length: %zu",row_data,
+ length));
/*
Don't print debug messages when running valgrind since they can
trigger false warnings.
@@ -1599,8 +1599,8 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi)
*/
DBUG_PRINT("info", ("error: %d", error));
- DBUG_PRINT("info", ("curr_row: 0x%lu; curr_row_end: 0x%lu; rows_end: 0x%lu",
- (ulong) m_curr_row, (ulong) m_curr_row_end, (ulong) m_rows_end));
+ DBUG_PRINT("info", ("curr_row: %p; curr_row_end:%p; rows_end: %p",
+ m_curr_row, m_curr_row_end, m_rows_end));
if (!m_curr_row_end && !error)
unpack_current_row(rgi);
diff --git a/sql/mf_iocache_encr.cc b/sql/mf_iocache_encr.cc
index ae314d826a0..546e0fe03a0 100644
--- a/sql/mf_iocache_encr.cc
+++ b/sql/mf_iocache_encr.cc
@@ -57,7 +57,7 @@ static int my_b_encr_read(IO_CACHE *info, uchar *Buffer, size_t Count)
if (info->seek_not_done)
{
- size_t wpos;
+ my_off_t wpos;
pos_offset= pos_in_file % info->buffer_length;
pos_in_file-= pos_offset;
@@ -92,7 +92,7 @@ static int my_b_encr_read(IO_CACHE *info, uchar *Buffer, size_t Count)
DBUG_RETURN(1);
}
- elength= wlength - (ebuffer - wbuffer);
+ elength= wlength - (uint)(ebuffer - wbuffer);
set_iv(iv, pos_in_file, crypt_data->inbuf_counter);
if (encryption_crypt(ebuffer, elength, info->buffer, &length,
@@ -106,7 +106,7 @@ static int my_b_encr_read(IO_CACHE *info, uchar *Buffer, size_t Count)
DBUG_ASSERT(length <= info->buffer_length);
- copied= MY_MIN(Count, length - pos_offset);
+ copied= MY_MIN(Count, (size_t)(length - pos_offset));
memcpy(Buffer, info->buffer + pos_offset, copied);
Count-= copied;
@@ -120,7 +120,7 @@ static int my_b_encr_read(IO_CACHE *info, uchar *Buffer, size_t Count)
if (wlength < crypt_data->block_length && pos_in_file < info->end_of_file)
{
- info->error= pos_in_file - old_pos_in_file;
+ info->error= (int)(pos_in_file - old_pos_in_file);
DBUG_RETURN(1);
}
} while (Count);
@@ -184,7 +184,7 @@ static int my_b_encr_write(IO_CACHE *info, const uchar *Buffer, size_t Count)
my_errno= 1;
DBUG_RETURN(info->error= -1);
}
- wlength= elength + ebuffer - wbuffer;
+ wlength= elength + (uint)(ebuffer - wbuffer);
if (length == info->buffer_length)
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index e1cdee8298f..8f9a62de4c6 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1593,8 +1593,8 @@ static void close_connections(void)
/* kill connection thread */
#if !defined(__WIN__)
- DBUG_PRINT("quit", ("waiting for select thread: 0x%lx",
- (ulong) select_thread));
+ DBUG_PRINT("quit", ("waiting for select thread: %lu",
+ (ulong)select_thread));
mysql_mutex_lock(&LOCK_start_thread);
while (select_thread_in_use)
@@ -2897,7 +2897,7 @@ void signal_thd_deleted()
void unlink_thd(THD *thd)
{
DBUG_ENTER("unlink_thd");
- DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
+ DBUG_PRINT("enter", ("thd: %p", thd));
/*
Do not decrement when its wsrep system thread. wsrep_applier is set for
@@ -4880,7 +4880,7 @@ static void init_ssl()
opt_ssl_ca, opt_ssl_capath,
opt_ssl_cipher, &error,
opt_ssl_crl, opt_ssl_crlpath);
- DBUG_PRINT("info",("ssl_acceptor_fd: 0x%lx", (long) ssl_acceptor_fd));
+ DBUG_PRINT("info",("ssl_acceptor_fd: %p", ssl_acceptor_fd));
if (!ssl_acceptor_fd)
{
sql_print_warning("Failed to setup SSL");
@@ -5031,7 +5031,8 @@ static int init_server_components()
global_system_variables.query_cache_type= 1;
}
query_cache_init();
- query_cache_resize(query_cache_size);
+ DBUG_ASSERT(query_cache_size < ULONG_MAX);
+ query_cache_resize((ulong)query_cache_size);
my_rnd_init(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
setup_fpu();
init_thr_lock();
@@ -5878,7 +5879,7 @@ int mysqld_main(int argc, char **argv)
ulonglong new_thread_stack_size;
new_thread_stack_size= my_setstacksize(&connection_attrib,
- my_thread_stack_size);
+ (size_t)my_thread_stack_size);
if (new_thread_stack_size != my_thread_stack_size)
SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size);
@@ -7935,9 +7936,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;
}
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 01aff0a9e7d..404c5a1f6d3 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1321,7 +1321,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
file->ha_end_keyread();
if (free_file)
{
- DBUG_PRINT("info", ("Freeing separate handler 0x%lx (free: %d)", (long) file,
+ DBUG_PRINT("info", ("Freeing separate handler %p (free: %d)", file,
free_file));
file->ha_external_lock(current_thd, F_UNLCK);
file->ha_close();
@@ -1483,7 +1483,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler,
in_ror_merged_scan= 1;
if (reuse_handler)
{
- DBUG_PRINT("info", ("Reusing handler 0x%lx", (long) file));
+ DBUG_PRINT("info", ("Reusing handler %p", file));
if (init())
{
DBUG_RETURN(1);
@@ -2827,7 +2827,7 @@ double records_in_column_ranges(PARAM *param, uint idx,
/* Handle cases when we don't have a valid non-empty list of range */
if (!tree)
- return HA_POS_ERROR;
+ return DBL_MAX;
if (tree->type == SEL_ARG::IMPOSSIBLE)
return (0L);
@@ -2847,9 +2847,9 @@ double records_in_column_ranges(PARAM *param, uint idx,
max_endp= range.end_key.length? &range.end_key : NULL;
rows= get_column_range_cardinality(field, min_endp, max_endp,
range.range_flag);
- if (HA_POS_ERROR == rows)
+ if (DBL_MAX == rows)
{
- total_rows= HA_POS_ERROR;
+ total_rows= DBL_MAX;
break;
}
total_rows += rows;
@@ -3083,7 +3083,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
else
{
rows= records_in_column_ranges(&param, idx, key);
- if (rows != HA_POS_ERROR)
+ if (rows != DBL_MAX)
key->field->cond_selectivity= rows/table_records;
}
}
@@ -4756,7 +4756,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
unique_calc_buff_size=
Unique::get_cost_calc_buff_size((ulong)non_cpk_scan_records,
param->table->file->ref_length,
- param->thd->variables.sortbuff_size);
+ (size_t)param->thd->variables.sortbuff_size);
if (param->imerge_cost_buff_size < unique_calc_buff_size)
{
if (!(param->imerge_cost_buff= (uint*)alloc_root(param->mem_root,
@@ -4768,7 +4768,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
imerge_cost +=
Unique::get_use_cost(param->imerge_cost_buff, (uint)non_cpk_scan_records,
param->table->file->ref_length,
- param->thd->variables.sortbuff_size,
+ (size_t)param->thd->variables.sortbuff_size,
TIME_FOR_COMPARE_ROWID,
FALSE, NULL);
DBUG_PRINT("info",("index_merge total cost: %g (wanted: less then %g)",
@@ -5021,7 +5021,7 @@ typedef struct st_common_index_intersect_info
PARAM *param; /* context info for range optimizations */
uint key_size; /* size of a ROWID element stored in Unique object */
uint compare_factor; /* 1/compare - cost to compare two ROWIDs */
- ulonglong max_memory_size; /* maximum space allowed for Unique objects */
+ size_t max_memory_size; /* maximum space allowed for Unique objects */
ha_rows table_cardinality; /* estimate of the number of records in table */
double cutoff_cost; /* discard index intersects with greater costs */
INDEX_SCAN_INFO *cpk_scan; /* clustered primary key used in intersection */
@@ -5216,7 +5216,7 @@ bool prepare_search_best_index_intersect(PARAM *param,
common->param= param;
common->key_size= table->file->ref_length;
common->compare_factor= TIME_FOR_COMPARE_ROWID;
- common->max_memory_size= param->thd->variables.sortbuff_size;
+ common->max_memory_size= (size_t)param->thd->variables.sortbuff_size;
common->cutoff_cost= cutoff_cost;
common->cpk_scan= NULL;
common->table_cardinality=
@@ -5652,7 +5652,7 @@ bool check_index_intersect_extension(PARTIAL_INDEX_INTERSECT_INFO *curr,
uint *buff_elems= common_info->buff_elems;
uint key_size= common_info->key_size;
uint compare_factor= common_info->compare_factor;
- ulonglong max_memory_size= common_info->max_memory_size;
+ size_t max_memory_size= common_info->max_memory_size;
records_sent_to_unique+= ext_index_scan_records;
cost= Unique::get_use_cost(buff_elems, (size_t) records_sent_to_unique, key_size,
@@ -10239,7 +10239,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root)
ulong count=count_key_part_usage(root,pos->next_key_part);
if (count > pos->next_key_part->use_count)
{
- sql_print_information("Use_count: Wrong count for key at 0x%lx, %lu "
+ sql_print_information("Use_count: Wrong count for key at %p, %lu "
"should be %lu", (long unsigned int)pos,
pos->next_key_part->use_count, count);
return;
@@ -10248,7 +10248,7 @@ void SEL_ARG::test_use_count(SEL_ARG *root)
}
}
if (e_count != elements)
- sql_print_warning("Wrong use count: %u (should be %u) for tree at 0x%lx",
+ sql_print_warning("Wrong use count: %u (should be %u) for tree at %p",
e_count, elements, (long unsigned int) this);
}
#endif
@@ -10934,7 +10934,7 @@ int read_keys_and_merge_scans(THD *thd,
unique= new Unique(refpos_order_cmp, (void *)file,
file->ref_length,
- thd->variables.sortbuff_size,
+ (size_t)thd->variables.sortbuff_size,
intersection ? quick_selects.elements : 0);
if (!unique)
goto err;
@@ -14634,7 +14634,7 @@ static void print_sel_tree(PARAM *param, SEL_TREE *tree, key_map *tree_map,
if (!tmp.length())
tmp.append(STRING_WITH_LEN("(empty)"));
- DBUG_PRINT("info", ("SEL_TREE: 0x%lx (%s) scans: %s", (long) tree, msg,
+ DBUG_PRINT("info", ("SEL_TREE: %p (%s) scans: %s", tree, msg,
tmp.c_ptr_safe()));
DBUG_VOID_RETURN;
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index 1cc40e3e39b..ebb08a23009 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -258,9 +258,9 @@ sql_create_definition_file(const LEX_CSTRING *dir,
int path_end;
File_option *param;
DBUG_ENTER("sql_create_definition_file");
- DBUG_PRINT("enter", ("Dir: %s, file: %s, base 0x%lx",
+ DBUG_PRINT("enter", ("Dir: %s, file: %s, base %p",
dir ? dir->str : "",
- file_name->str, (ulong) base));
+ file_name->str, base));
if (dir)
{
@@ -437,7 +437,7 @@ sql_parse_prepare(const LEX_CSTRING *file_name, MEM_ROOT *mem_root,
DBUG_RETURN(0);
}
- if ((len= mysql_file_read(file, (uchar *)buff, stat_info.st_size,
+ if ((len= mysql_file_read(file, (uchar *)buff, (size_t)stat_info.st_size,
MYF(MY_WME))) == MY_FILE_ERROR)
{
mysql_file_close(file, MYF(MY_WME));
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index 8af919990d0..d09b7aee31c 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -239,7 +239,7 @@ Rpl_filter::db_ok_with_wild_table(const char *db)
int len;
end= strmov(hash_key, db);
*end++= '.';
- len= end - hash_key ;
+ len= (int)(end - hash_key);
if (wild_do_table_inited && find_wild(&wild_do_table, hash_key, len))
{
DBUG_PRINT("return",("1"));
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index 65044daecc8..4a6e813d73b 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -1698,7 +1698,7 @@ rpl_parallel_thread::get_qev_common(Log_event *ev, ulonglong event_size)
}
qev->typ= rpl_parallel_thread::queued_event::QUEUED_EVENT;
qev->ev= ev;
- qev->event_size= event_size;
+ qev->event_size= (size_t)event_size;
qev->next= NULL;
return qev;
}
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index 01d9da52d4e..9ff5004414c 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -105,10 +105,10 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
#endif
pack_ptr= field->pack(pack_ptr, field->ptr + offset,
field->max_data_length());
- DBUG_PRINT("debug", ("field: %s; real_type: %d, pack_ptr: 0x%lx;"
- " pack_ptr':0x%lx; bytes: %d",
+ DBUG_PRINT("debug", ("field: %s; real_type: %d, pack_ptr: %p;"
+ " pack_ptr':%p; bytes: %d",
field->field_name.str, field->real_type(),
- (ulong) old_pack_ptr, (ulong) pack_ptr,
+ old_pack_ptr,pack_ptr,
(int) (pack_ptr - old_pack_ptr)));
DBUG_DUMP("packed_data", old_pack_ptr, pack_ptr - old_pack_ptr);
}
@@ -322,9 +322,9 @@ unpack_row(rpl_group_info *rgi,
pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata);
DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;"
- " pack_ptr: 0x%lx; pack_ptr': 0x%lx; bytes: %d",
+ " pack_ptr: %p; pack_ptr': %p; bytes: %d",
f->field_name.str, metadata,
- (ulong) old_pack_ptr, (ulong) pack_ptr,
+ old_pack_ptr, pack_ptr,
(int) (pack_ptr - old_pack_ptr)));
if (!pack_ptr)
{
@@ -336,11 +336,11 @@ unpack_row(rpl_group_info *rgi,
Galera Node throws "Could not read field" error and drops out of cluster
*/
WSREP_WARN("ROW event unpack field: %s metadata: 0x%x;"
- " pack_ptr: 0x%lx; conv_table %p conv_field %p table %s"
- " row_end: 0x%lx",
+ " pack_ptr: %p; conv_table %p conv_field %p table %s"
+ " row_end: %p",
f->field_name.str, metadata,
- (ulong) old_pack_ptr, conv_table, conv_field,
- (table_found) ? "found" : "not found", (ulong)row_end
+ old_pack_ptr, conv_table, conv_field,
+ (table_found) ? "found" : "not found", row_end
);
}
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 8dff4146909..efb256fbe11 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -236,7 +236,7 @@ a file name for --relay-log-index option", opt_relaylog_index_name);
mysql_mutex_lock(log_lock);
if (relay_log.open_index_file(buf_relaylog_index_name, ln, TRUE) ||
relay_log.open(ln, LOG_BIN, 0, 0, SEQ_READ_APPEND,
- max_relay_log_size, 1, TRUE))
+ (ulong)max_relay_log_size, 1, TRUE))
{
mysql_mutex_unlock(log_lock);
mysql_mutex_unlock(&data_lock);
@@ -1177,7 +1177,7 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
}
mysql_mutex_lock(rli->relay_log.get_log_lock());
if (rli->relay_log.open(ln, LOG_BIN, 0, 0, SEQ_READ_APPEND,
- (rli->max_relay_log_size ? rli->max_relay_log_size :
+ (ulong)(rli->max_relay_log_size ? rli->max_relay_log_size :
max_binlog_size), 1, TRUE))
{
sql_print_error("Unable to purge relay log files. Failed to open relay "
@@ -1560,9 +1560,9 @@ scan_one_gtid_slave_pos_table(THD *thd, HASH *hash, DYNAMIC_ARRAY *array,
goto end;
}
}
- domain_id= (ulonglong)table->field[0]->val_int();
+ domain_id= (uint32)table->field[0]->val_int();
sub_id= (ulonglong)table->field[1]->val_int();
- server_id= (ulonglong)table->field[2]->val_int();
+ server_id= (uint32)table->field[2]->val_int();
seq_no= (ulonglong)table->field[3]->val_int();
DBUG_PRINT("info", ("Read slave state row: %u-%u-%lu sub_id=%lu\n",
(unsigned)domain_id, (unsigned)server_id,
diff --git a/sql/rpl_tblmap.cc b/sql/rpl_tblmap.cc
index 1f4aa45a101..80d093722f7 100644
--- a/sql/rpl_tblmap.cc
+++ b/sql/rpl_tblmap.cc
@@ -66,8 +66,8 @@ TABLE* table_mapping::get_table(ulong table_id)
entry *e= find_entry(table_id);
if (e)
{
- DBUG_PRINT("info", ("tid %lu -> table 0x%lx (%s)",
- table_id, (long) e->table,
+ DBUG_PRINT("info", ("tid %lu -> table %p (%s)",
+ table_id, e->table,
MAYBE_TABLE_NAME(e->table)));
DBUG_RETURN(e->table);
}
@@ -105,9 +105,9 @@ int table_mapping::expand()
int table_mapping::set_table(ulong table_id, TABLE* table)
{
DBUG_ENTER("table_mapping::set_table(ulong,TABLE*)");
- DBUG_PRINT("enter", ("table_id: %lu table: 0x%lx (%s)",
+ DBUG_PRINT("enter", ("table_id: %lu table: %p (%s)",
table_id,
- (long) table, MAYBE_TABLE_NAME(table)));
+ table, MAYBE_TABLE_NAME(table)));
entry *e= find_entry(table_id);
if (e == 0)
{
@@ -133,8 +133,8 @@ int table_mapping::set_table(ulong table_id, TABLE* table)
DBUG_RETURN(ERR_MEMORY_ALLOCATION);
}
- DBUG_PRINT("info", ("tid %lu -> table 0x%lx (%s)",
- table_id, (long) e->table,
+ DBUG_PRINT("info", ("tid %lu -> table %p (%s)",
+ table_id, e->table,
MAYBE_TABLE_NAME(e->table)));
DBUG_RETURN(0); // All OK
}
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc
index 8d64fb29332..ff9780a9531 100644
--- a/sql/session_tracker.cc
+++ b/sql/session_tracker.cc
@@ -967,7 +967,7 @@ bool Current_schema_tracker::update(THD *thd, set_var *)
bool Current_schema_tracker::store(THD *thd, String *buf)
{
- ulonglong db_length, length;
+ size_t db_length, length;
/*
Protocol made (by unknown reasons) redundant:
@@ -1320,16 +1320,16 @@ bool Transaction_state_tracker::store(THD *thd, String *buf)
}
{
- ulonglong length= buf->length() - start;
+ size_t length= buf->length() - start;
uchar *place= (uchar *)(buf->ptr() + (start - 2));
DBUG_ASSERT(length < 249); // in fact < 110
DBUG_ASSERT(start >= 3);
DBUG_ASSERT((place - 1)[0] == SESSION_TRACK_TRANSACTION_CHARACTERISTICS);
/* Length of the overall entity. */
- place[0]= length + 1;
+ place[0]= (uchar)length + 1;
/* Transaction characteristics (length-encoded string). */
- place[1]= length;
+ place[1]= (uchar)length;
}
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 5177ac0d1b4..46932e36e95 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3682,11 +3682,11 @@ sql_delay_event(Log_event *ev, THD *thd, rpl_group_info *rgi)
"ev->when= %lu "
"rli->mi->clock_diff_with_master= %lu "
"now= %ld "
- "sql_delay_end= %lu "
+ "sql_delay_end= %llu "
"nap_time= %ld",
sql_delay, (long)ev->when,
rli->mi->clock_diff_with_master,
- (long)now, sql_delay_end, (long)nap_time));
+ (long)now, (ulonglong)sql_delay_end, (long)nap_time));
if (sql_delay_end > now)
{
@@ -4743,12 +4743,12 @@ Stopping slave I/O thread due to out-of-memory error from master");
lastchecktime = currenttime;
if(tokenamount < network_read_len)
{
- ulonglong micro_time = 1000*1000 * (network_read_len - tokenamount) / speed_limit_in_bytes ;
- ulonglong second_time = micro_time / (1000 * 1000);
- micro_time = micro_time % (1000 * 1000);
+ ulonglong duration =1000ULL*1000 * (network_read_len - tokenamount) / speed_limit_in_bytes;
+ time_t second_time = (time_t)(duration / (1000 * 1000));
+ uint micro_time = duration % (1000 * 1000);
// at least sleep 1000 micro second
- my_sleep(micro_time > 1000 ? micro_time : 1000);
+ my_sleep(MY_MAX(micro_time,1000));
/*
If it sleep more than one second,
diff --git a/sql/sp.cc b/sql/sp.cc
index 8f4acd40f10..e2884f49d99 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -720,8 +720,8 @@ Sp_handler::db_find_and_cache_routine(THD *thd,
if (rc == SP_OK)
{
sp_cache_insert(get_cache(thd), *sp);
- DBUG_PRINT("info", ("added new: 0x%lx, level: %lu, flags %x",
- (ulong) sp[0], sp[0]->m_recursion_level,
+ DBUG_PRINT("info", ("added new: %p, level: %lu, flags %x",
+ sp[0], sp[0]->m_recursion_level,
sp[0]->m_flags));
}
return rc;
@@ -1775,11 +1775,11 @@ Sp_handler::sp_clone_and_link_routine(THD *thd,
String retstr(64);
retstr.set_charset(sp->get_creation_ctx()->get_client_cs());
- DBUG_PRINT("info", ("found: 0x%lx", (ulong)sp));
+ DBUG_PRINT("info", ("found: %p", sp));
if (sp->m_first_free_instance)
{
- DBUG_PRINT("info", ("first free: 0x%lx level: %lu flags %x",
- (ulong)sp->m_first_free_instance,
+ DBUG_PRINT("info", ("first free: %p level: %lu flags %x",
+ sp->m_first_free_instance,
sp->m_first_free_instance->m_recursion_level,
sp->m_first_free_instance->m_flags));
DBUG_ASSERT(!(sp->m_first_free_instance->m_flags & sp_head::IS_INVOKED));
@@ -1819,8 +1819,8 @@ Sp_handler::sp_clone_and_link_routine(THD *thd,
new_sp->m_recursion_level= level;
new_sp->m_first_instance= sp;
sp->m_last_cached_sp= sp->m_first_free_instance= new_sp;
- DBUG_PRINT("info", ("added level: 0x%lx, level: %lu, flags %x",
- (ulong)new_sp, new_sp->m_recursion_level,
+ DBUG_PRINT("info", ("added level: %p, level: %lu, flags %x",
+ new_sp, new_sp->m_recursion_level,
new_sp->m_flags));
DBUG_RETURN(new_sp);
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index ebfee30ecd3..0bc269c414c 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -515,7 +515,7 @@ sp_head::operator new(size_t size) throw()
if (sp == NULL)
DBUG_RETURN(NULL);
sp->main_mem_root= own_root;
- DBUG_PRINT("info", ("mem_root 0x%lx", (ulong) &sp->mem_root));
+ DBUG_PRINT("info", ("mem_root %p", &sp->mem_root));
DBUG_RETURN(sp);
}
@@ -532,8 +532,8 @@ sp_head::operator delete(void *ptr, size_t size) throw()
/* Make a copy of main_mem_root as free_root will free the sp */
own_root= sp->main_mem_root;
- DBUG_PRINT("info", ("mem_root 0x%lx moved to 0x%lx",
- (ulong) &sp->mem_root, (ulong) &own_root));
+ DBUG_PRINT("info", ("mem_root %p moved to %p",
+ &sp->mem_root, &own_root));
free_root(&own_root, MYF(0));
DBUG_VOID_RETURN;
@@ -1027,9 +1027,9 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
if (m_next_cached_sp)
{
DBUG_PRINT("info",
- ("first free for 0x%lx ++: 0x%lx->0x%lx level: %lu flags %x",
- (ulong)m_first_instance, (ulong) this,
- (ulong) m_next_cached_sp,
+ ("first free for %p ++: %p->%p level: %lu flags %x",
+ m_first_instance, this,
+ m_next_cached_sp,
m_next_cached_sp->m_recursion_level,
m_next_cached_sp->m_flags));
}
@@ -1333,10 +1333,10 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
}
m_flags&= ~IS_INVOKED;
DBUG_PRINT("info",
- ("first free for 0x%lx --: 0x%lx->0x%lx, level: %lu, flags %x",
- (ulong) m_first_instance,
- (ulong) m_first_instance->m_first_free_instance,
- (ulong) this, m_recursion_level, m_flags));
+ ("first free for %p --: %p->%p, level: %lu, flags %x",
+ m_first_instance,
+ m_first_instance->m_first_free_instance,
+ this, m_recursion_level, m_flags));
/*
Check that we have one of following:
@@ -2324,8 +2324,8 @@ sp_head::backpatch(sp_label *lab)
{
if (bp->lab == lab)
{
- DBUG_PRINT("info", ("backpatch: (m_ip %d, label 0x%lx <%s>) to dest %d",
- bp->instr->m_ip, (ulong) lab, lab->name.str, dest));
+ DBUG_PRINT("info", ("backpatch: (m_ip %d, label %p <%s>) to dest %d",
+ bp->instr->m_ip, lab, lab->name.str, dest));
bp->instr->backpatch(dest, lab->ctx);
}
}
@@ -2355,8 +2355,8 @@ sp_head::backpatch_goto(THD *thd, sp_label *lab,sp_label *lab_begin_block)
if (bp->instr_type == GOTO)
{
DBUG_PRINT("info",
- ("backpatch_goto: (m_ip %d, label 0x%lx <%s>) to dest %d",
- bp->instr->m_ip, (ulong) lab, lab->name.str, dest));
+ ("backpatch_goto: (m_ip %d, label %p <%s>) to dest %d",
+ bp->instr->m_ip, lab, lab->name.str, dest));
bp->instr->backpatch(dest, lab->ctx);
// Jump resolved, remove from the list
li.remove();
@@ -2504,8 +2504,8 @@ sp_head::reset_thd_mem_root(THD *thd)
DBUG_ENTER("sp_head::reset_thd_mem_root");
m_thd_root= thd->mem_root;
thd->mem_root= &main_mem_root;
- DBUG_PRINT("info", ("mem_root 0x%lx moved to thd mem root 0x%lx",
- (ulong) &mem_root, (ulong) &thd->mem_root));
+ DBUG_PRINT("info", ("mem_root %p moved to thd mem root %p",
+ &mem_root, &thd->mem_root));
free_list= thd->free_list; // Keep the old list
thd->free_list= NULL; // Start a new one
m_thd= thd;
@@ -2535,8 +2535,8 @@ sp_head::restore_thd_mem_root(THD *thd)
set_query_arena(thd); // Get new free_list and mem_root
state= STMT_INITIALIZED_FOR_SP;
- DBUG_PRINT("info", ("mem_root 0x%lx returned from thd mem root 0x%lx",
- (ulong) &mem_root, (ulong) &thd->mem_root));
+ DBUG_PRINT("info", ("mem_root %p returned from thd mem root %p",
+ &mem_root, &thd->mem_root));
thd->free_list= flist; // Restore the old one
thd->mem_root= m_thd_root;
m_thd= NULL;
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h
index 215ebbe5f77..9c879099410 100644
--- a/sql/sp_pcontext.h
+++ b/sql/sp_pcontext.h
@@ -433,11 +433,11 @@ public:
/// @return the current number of variables used in the parent contexts
/// (from the root), including this context.
uint current_var_count() const
- { return m_var_offset + m_vars.elements(); }
+ { return m_var_offset + (uint)m_vars.elements(); }
/// @return the number of variables in this context alone.
uint context_var_count() const
- { return m_vars.elements(); }
+ { return (uint)m_vars.elements(); }
/// return the i-th variable on the current context
sp_variable *get_context_variable(uint i) const
@@ -678,10 +678,10 @@ public:
{ return m_cursors.elements(); }
uint max_cursor_index() const
- { return m_max_cursor_index + m_cursors.elements(); }
+ { return m_max_cursor_index + (uint)m_cursors.elements(); }
uint current_cursor_count() const
- { return m_cursor_offset + m_cursors.elements(); }
+ { return m_cursor_offset + (uint)m_cursors.elements(); }
void set_for_loop(const Lex_for_loop_st &for_loop)
{
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index b96ded8cf80..70ab5a576b3 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -51,9 +51,7 @@ sp_rcontext::sp_rcontext(const sp_pcontext *root_parsing_ctx,
sp_rcontext::~sp_rcontext()
{
- if (m_var_table)
- free_blobs(m_var_table);
-
+ delete m_var_table;
// Leave m_handlers, m_handler_call_stack, m_var_items, m_cstack
// and m_case_expr_holders untouched.
// They are allocated in mem roots and will be freed accordingly.
@@ -375,10 +373,16 @@ bool Item_spvar_args::row_create_items(THD *thd, List<Spvar_definition> *list)
}
+Field *Item_spvar_args::get_row_field(uint i) const
+{
+ DBUG_ASSERT(m_table);
+ return m_table->field[i];
+}
+
+
Item_spvar_args::~Item_spvar_args()
{
- if (m_table)
- free_blobs(m_table);
+ delete m_table;
}
diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h
index 1b1329c17f0..66df0359d28 100644
--- a/sql/sp_rcontext.h
+++ b/sql/sp_rcontext.h
@@ -34,6 +34,7 @@ class sp_instr_cpush;
class Query_arena;
class sp_head;
class Item_cache;
+class Virtual_tmp_table;
/*
@@ -363,7 +364,7 @@ private:
const sp_pcontext *m_root_parsing_ctx;
/// Virtual table for storing SP-variables.
- TABLE *m_var_table;
+ Virtual_tmp_table *m_var_table;
/// Collection of Item_field proxies, each of them points to the
/// corresponding field in m_var_table.
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index e61940ea82d..ae7dc336720 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -12359,7 +12359,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio)
static bool
read_client_connect_attrs(char **ptr, char *end, CHARSET_INFO *from_cs)
{
- size_t length;
+ ulonglong length;
char *ptr_save= *ptr;
/* not enough bytes to hold the length */
@@ -12381,10 +12381,10 @@ read_client_connect_attrs(char **ptr, char *end, CHARSET_INFO *from_cs)
return true;
#ifdef HAVE_PSI_THREAD_INTERFACE
- if (PSI_THREAD_CALL(set_thread_connect_attrs)(*ptr, length, from_cs) &&
+ if (PSI_THREAD_CALL(set_thread_connect_attrs)(*ptr, (size_t)length, from_cs) &&
current_thd->variables.log_warnings)
- sql_print_warning("Connection attributes of length %lu were truncated",
- (unsigned long) length);
+ sql_print_warning("Connection attributes of length %llu were truncated",
+ length);
#endif
return false;
}
@@ -12641,7 +12641,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
char *user= end;
char *passwd= strend(user)+1;
- uint user_len= passwd - user - 1, db_len;
+ uint user_len= (uint)(passwd - user - 1), db_len;
char *db= passwd;
char user_buff[USERNAME_LENGTH + 1]; // buffer to store user in utf8
uint dummy_errors;
@@ -12656,15 +12656,22 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
Cast *passwd to an unsigned char, so that it doesn't extend the sign for
*passwd > 127 and become 2**32-127+ after casting to uint.
*/
- uint passwd_len;
+ ulonglong len;
+ size_t passwd_len;
+
if (!(thd->client_capabilities & CLIENT_SECURE_CONNECTION))
- passwd_len= strlen(passwd);
+ len= strlen(passwd);
else if (!(thd->client_capabilities & CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA))
- passwd_len= (uchar)(*passwd++);
+ len= (uchar)(*passwd++);
else
- passwd_len= safe_net_field_length_ll((uchar**)&passwd,
+ {
+ len= safe_net_field_length_ll((uchar**)&passwd,
net->read_pos + pkt_len - (uchar*)passwd);
-
+ if (len > pkt_len)
+ return packet_error;
+ }
+
+ passwd_len= (size_t)len;
db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ?
db + passwd_len + 1 : 0;
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index ce12b73a9e2..c81ca438bcc 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -590,7 +590,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
}
}
#endif
- DBUG_PRINT("admin", ("table: 0x%lx", (long) table->table));
+ DBUG_PRINT("admin", ("table: %p", table->table));
if (prepare_func)
{
diff --git a/sql/sql_audit.h b/sql/sql_audit.h
index 4979375559b..7a11f5aa113 100644
--- a/sql/sql_audit.h
+++ b/sql/sql_audit.h
@@ -60,15 +60,26 @@ static inline void mysql_audit_notify(THD *thd, uint event_class,
#endif
extern void mysql_audit_release(THD *thd);
+static inline unsigned int strlen_uint(const char *s)
+{
+ return (uint)strlen(s);
+}
+
+static inline unsigned int safe_strlen_uint(const char *s)
+{
+ return (uint)safe_strlen(s);
+}
+
#define MAX_USER_HOST_SIZE 512
static inline uint make_user_name(THD *thd, char *buf)
{
const Security_context *sctx= thd->security_ctx;
- return strxnmov(buf, MAX_USER_HOST_SIZE,
+ char *end= strxnmov(buf, MAX_USER_HOST_SIZE,
sctx->priv_user[0] ? sctx->priv_user : "", "[",
sctx->user ? sctx->user : "", "] @ ",
sctx->host ? sctx->host : "", " [",
- sctx->ip ? sctx->ip : "", "]", NullS) - buf;
+ sctx->ip ? sctx->ip : "", "]", NullS);
+ return (uint)(end-buf);
}
/**
@@ -110,7 +121,7 @@ void mysql_audit_general_log(THD *thd, time_t time,
event.general_thread_id= (unsigned long)thd->thread_id;
event.general_charset= thd->variables.character_set_client;
event.database= thd->db;
- event.database_length= thd->db_length;
+ event.database_length= (unsigned int)thd->db_length;
event.query_id= thd->query_id;
}
else
@@ -152,7 +163,7 @@ void mysql_audit_general(THD *thd, uint event_subtype,
event.general_error_code= error_code;
event.general_time= my_time(0);
event.general_command= msg;
- event.general_command_length= safe_strlen(msg);
+ event.general_command_length= safe_strlen_uint(msg);
if (thd)
{
@@ -164,7 +175,7 @@ void mysql_audit_general(THD *thd, uint event_subtype,
event.general_charset= thd->query_string.charset();
event.general_rows= thd->get_stmt_da()->current_row_for_warning();
event.database= thd->db;
- event.database_length= thd->db_length;
+ event.database_length= (uint)thd->db_length;
event.query_id= thd->query_id;
}
else
@@ -199,19 +210,19 @@ void mysql_audit_notify_connection_connect(THD *thd)
thd->get_stmt_da()->sql_errno() : 0;
event.thread_id= (unsigned long)thd->thread_id;
event.user= sctx->user;
- event.user_length= safe_strlen(sctx->user);
+ event.user_length= safe_strlen_uint(sctx->user);
event.priv_user= sctx->priv_user;
- event.priv_user_length= strlen(sctx->priv_user);
+ event.priv_user_length= strlen_uint(sctx->priv_user);
event.external_user= sctx->external_user;
- event.external_user_length= safe_strlen(sctx->external_user);
+ event.external_user_length= safe_strlen_uint(sctx->external_user);
event.proxy_user= sctx->proxy_user;
- event.proxy_user_length= strlen(sctx->proxy_user);
+ event.proxy_user_length= strlen_uint(sctx->proxy_user);
event.host= sctx->host;
- event.host_length= safe_strlen(sctx->host);
+ event.host_length= safe_strlen_uint(sctx->host);
event.ip= sctx->ip;
- event.ip_length= safe_strlen(sctx->ip);
+ event.ip_length= safe_strlen_uint(sctx->ip);
event.database= thd->db;
- event.database_length= safe_strlen(thd->db);
+ event.database_length= safe_strlen_uint(thd->db);
mysql_audit_notify(thd, MYSQL_AUDIT_CONNECTION_CLASS, &event);
}
@@ -229,19 +240,19 @@ void mysql_audit_notify_connection_disconnect(THD *thd, int errcode)
event.status= errcode;
event.thread_id= (unsigned long)thd->thread_id;
event.user= sctx->user;
- event.user_length= safe_strlen(sctx->user);
+ event.user_length= safe_strlen_uint(sctx->user);
event.priv_user= sctx->priv_user;
- event.priv_user_length= strlen(sctx->priv_user);
+ event.priv_user_length= strlen_uint(sctx->priv_user);
event.external_user= sctx->external_user;
- event.external_user_length= safe_strlen(sctx->external_user);
+ event.external_user_length= safe_strlen_uint(sctx->external_user);
event.proxy_user= sctx->proxy_user;
- event.proxy_user_length= strlen(sctx->proxy_user);
+ event.proxy_user_length= strlen_uint(sctx->proxy_user);
event.host= sctx->host;
- event.host_length= safe_strlen(sctx->host);
+ event.host_length= safe_strlen_uint(sctx->host);
event.ip= sctx->ip;
- event.ip_length= safe_strlen(sctx->ip) ;
+ event.ip_length= safe_strlen_uint(sctx->ip) ;
event.database= thd->db;
- event.database_length= safe_strlen(thd->db);
+ event.database_length= safe_strlen_uint(thd->db);
mysql_audit_notify(thd, MYSQL_AUDIT_CONNECTION_CLASS, &event);
}
@@ -260,19 +271,19 @@ void mysql_audit_notify_connection_change_user(THD *thd)
thd->get_stmt_da()->sql_errno() : 0;
event.thread_id= (unsigned long)thd->thread_id;
event.user= sctx->user;
- event.user_length= safe_strlen(sctx->user);
+ event.user_length= safe_strlen_uint(sctx->user);
event.priv_user= sctx->priv_user;
- event.priv_user_length= strlen(sctx->priv_user);
+ event.priv_user_length= strlen_uint(sctx->priv_user);
event.external_user= sctx->external_user;
- event.external_user_length= safe_strlen(sctx->external_user);
+ event.external_user_length= safe_strlen_uint(sctx->external_user);
event.proxy_user= sctx->proxy_user;
- event.proxy_user_length= strlen(sctx->proxy_user);
+ event.proxy_user_length= strlen_uint(sctx->proxy_user);
event.host= sctx->host;
- event.host_length= safe_strlen(sctx->host);
+ event.host_length= safe_strlen_uint(sctx->host);
event.ip= sctx->ip;
- event.ip_length= safe_strlen(sctx->ip);
+ event.ip_length= safe_strlen_uint(sctx->ip);
event.database= thd->db;
- event.database_length= safe_strlen(thd->db);
+ event.database_length= safe_strlen_uint(thd->db);
mysql_audit_notify(thd, MYSQL_AUDIT_CONNECTION_CLASS, &event);
}
@@ -297,9 +308,9 @@ void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock)
event.host= sctx->host;
event.ip= sctx->ip;
event.database= share->db.str;
- event.database_length= share->db.length;
+ event.database_length= (unsigned int)share->db.length;
event.table= share->table_name.str;
- event.table_length= share->table_name.length;
+ event.table_length= (unsigned int)share->table_name.length;
event.new_database= 0;
event.new_database_length= 0;
event.new_table= 0;
@@ -331,9 +342,9 @@ void mysql_audit_create_table(TABLE *table)
event.host= sctx->host;
event.ip= sctx->ip;
event.database= share->db.str;
- event.database_length= share->db.length;
+ event.database_length= (unsigned int)share->db.length;
event.table= share->table_name.str;
- event.table_length= share->table_name.length;
+ event.table_length= (unsigned int)share->table_name.length;
event.new_database= 0;
event.new_database_length= 0;
event.new_table= 0;
@@ -363,9 +374,9 @@ void mysql_audit_drop_table(THD *thd, TABLE_LIST *table)
event.host= sctx->host;
event.ip= sctx->ip;
event.database= table->db;
- event.database_length= table->db_length;
+ event.database_length= (unsigned int)table->db_length;
event.table= table->table_name;
- event.table_length= table->table_name_length;
+ event.table_length= (unsigned int)table->table_name_length;
event.new_database= 0;
event.new_database_length= 0;
event.new_table= 0;
@@ -396,13 +407,13 @@ void mysql_audit_rename_table(THD *thd, const char *old_db, const char *old_tb,
event.host= sctx->host;
event.ip= sctx->ip;
event.database= old_db;
- event.database_length= strlen(old_db);
+ event.database_length= strlen_uint(old_db);
event.table= old_tb;
- event.table_length= strlen(old_tb);
+ event.table_length= strlen_uint(old_tb);
event.new_database= new_db;
- event.new_database_length= strlen(new_db);
+ event.new_database_length= strlen_uint(new_db);
event.new_table= new_tb;
- event.new_table_length= strlen(new_tb);
+ event.new_table_length= strlen_uint(new_tb);
event.query_id= thd->query_id;
mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
@@ -428,9 +439,9 @@ void mysql_audit_alter_table(THD *thd, TABLE_LIST *table)
event.host= sctx->host;
event.ip= sctx->ip;
event.database= table->db;
- event.database_length= table->db_length;
+ event.database_length= (unsigned int)table->db_length;
event.table= table->table_name;
- event.table_length= table->table_name_length;
+ event.table_length= (unsigned int)table->table_name_length;
event.new_database= 0;
event.new_database_length= 0;
event.new_table= 0;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 93dd6239749..e59007d3e5a 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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));
@@ -716,8 +716,8 @@ void close_thread_tables(THD *thd)
#ifdef EXTRA_DEBUG
DBUG_PRINT("tcache", ("open tables:"));
for (table= thd->open_tables; table; table= table->next)
- DBUG_PRINT("tcache", ("table: '%s'.'%s' 0x%lx", table->s->db.str,
- table->s->table_name.str, (long) table));
+ DBUG_PRINT("tcache", ("table: '%s'.'%s' %p", table->s->db.str,
+ table->s->table_name.str, table));
#endif
#if defined(ENABLED_DEBUG_SYNC)
@@ -857,8 +857,8 @@ void close_thread_table(THD *thd, TABLE **table_ptr)
{
TABLE *table= *table_ptr;
DBUG_ENTER("close_thread_table");
- DBUG_PRINT("tcache", ("table: '%s'.'%s' 0x%lx", table->s->db.str,
- table->s->table_name.str, (long) table));
+ DBUG_PRINT("tcache", ("table: '%s'.'%s' %p", table->s->db.str,
+ table->s->table_name.str, table));
DBUG_ASSERT(!table->file->keyread_enabled());
DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
@@ -1192,8 +1192,8 @@ 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: 0x%lx db_stat: %u version: %lu",
- table->s->table_name.str, (ulong) table->s,
+ 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));
if (thd->mdl_context.upgrade_shared_lock(
@@ -1812,7 +1812,7 @@ retry_share:
{
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
@@ -5244,8 +5244,8 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
{
DBUG_ENTER("find_field_in_view");
DBUG_PRINT("enter",
- ("view: '%s', field name: '%s', item name: '%s', ref 0x%lx",
- table_list->alias, name, item_name, (ulong) ref));
+ ("view: '%s', field name: '%s', item name: '%s', ref %p",
+ table_list->alias, name, item_name, ref));
Field_iterator_view field_it;
field_it.set(table_list);
Query_arena *arena= 0, backup;
@@ -5329,8 +5329,8 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
Field *UNINIT_VAR(found_field);
Query_arena *UNINIT_VAR(arena), backup;
DBUG_ENTER("find_field_in_natural_join");
- DBUG_PRINT("enter", ("field name: '%s', ref 0x%lx",
- name, (ulong) ref));
+ DBUG_PRINT("enter", ("field name: '%s', ref %p",
+ name, ref));
DBUG_ASSERT(table_ref->is_natural_join && table_ref->join_columns);
DBUG_ASSERT(*actual_table == NULL);
@@ -5556,8 +5556,8 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
DBUG_ASSERT(name);
DBUG_ASSERT(item_name);
DBUG_PRINT("enter",
- ("table: '%s' field name: '%s' item name: '%s' ref 0x%lx",
- table_list->alias, name, item_name, (ulong) ref));
+ ("table: '%s' field name: '%s' item name: '%s' ref %p",
+ table_list->alias, name, item_name, ref));
/*
Check that the table and database that qualify the current field name
@@ -7456,7 +7456,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
bool found;
char name_buff[SAFE_NAME_LEN+1];
DBUG_ENTER("insert_fields");
- DBUG_PRINT("arena", ("stmt arena: 0x%lx", (ulong)thd->stmt_arena));
+ DBUG_PRINT("arena", ("stmt arena: %p",thd->stmt_arena));
if (db_name && lower_case_table_names)
{
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index d9d057938eb..aa1a1cd6941 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -192,8 +192,8 @@ void mysql_client_binlog_statement(THD* thd)
since it will read from unassigned memory.
*/
DBUG_PRINT("info",
- ("bytes_decoded: %d strptr: 0x%lx endptr: 0x%lx ('%c':%d)",
- bytes_decoded, (long) strptr, (long) endptr, *endptr,
+ ("bytes_decoded: %d strptr: %p endptr: %p ('%c':%d)",
+ bytes_decoded, strptr, endptr, *endptr,
*endptr));
#endif
diff --git a/sql/sql_bootstrap.cc b/sql/sql_bootstrap.cc
index 533459365af..ce7d7a9fc93 100644
--- a/sql/sql_bootstrap.cc
+++ b/sql/sql_bootstrap.cc
@@ -24,8 +24,8 @@ int read_bootstrap_query(char *query, int *query_length,
{
char line_buffer[MAX_BOOTSTRAP_LINE_SIZE];
const char *line;
- int len;
- int query_len= 0;
+ size_t len;
+ size_t query_len= 0;
int fgets_error= 0;
*error= 0;
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index ed5a8f84127..e09b1788441 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -355,27 +355,27 @@ const uchar *query_state_map;
#endif
#if defined(EXTRA_DEBUG) && !defined(DBUG_OFF)
-#define RW_WLOCK(M) {DBUG_PRINT("lock", ("rwlock wlock 0x%lx",(ulong)(M))); \
+#define RW_WLOCK(M) {DBUG_PRINT("lock", ("rwlock wlock %p",(M))); \
if (!mysql_rwlock_wrlock(M)) DBUG_PRINT("lock", ("rwlock wlock ok")); \
else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); }
-#define RW_RLOCK(M) {DBUG_PRINT("lock", ("rwlock rlock 0x%lx", (ulong)(M))); \
+#define RW_RLOCK(M) {DBUG_PRINT("lock", ("rwlock rlock %p",(M))); \
if (!mysql_rwlock_rdlock(M)) DBUG_PRINT("lock", ("rwlock rlock ok")); \
else DBUG_PRINT("lock", ("rwlock wlock FAILED %d", errno)); }
-#define RW_UNLOCK(M) {DBUG_PRINT("lock", ("rwlock unlock 0x%lx",(ulong)(M))); \
+#define RW_UNLOCK(M) {DBUG_PRINT("lock", ("rwlock unlock %p",(M))); \
if (!mysql_rwlock_unlock(M)) DBUG_PRINT("lock", ("rwlock unlock ok")); \
else DBUG_PRINT("lock", ("rwlock unlock FAILED %d", errno)); }
-#define BLOCK_LOCK_WR(B) {DBUG_PRINT("lock", ("%d LOCK_WR 0x%lx",\
- __LINE__,(ulong)(B))); \
+#define BLOCK_LOCK_WR(B) {DBUG_PRINT("lock", ("%d LOCK_WR %p",\
+ __LINE__,(B))); \
B->query()->lock_writing();}
-#define BLOCK_LOCK_RD(B) {DBUG_PRINT("lock", ("%d LOCK_RD 0x%lx",\
- __LINE__,(ulong)(B))); \
+#define BLOCK_LOCK_RD(B) {DBUG_PRINT("lock", ("%d LOCK_RD %p",\
+ __LINE__,(B))); \
B->query()->lock_reading();}
#define BLOCK_UNLOCK_WR(B) { \
- DBUG_PRINT("lock", ("%d UNLOCK_WR 0x%lx",\
- __LINE__,(ulong)(B)));B->query()->unlock_writing();}
+ DBUG_PRINT("lock", ("%d UNLOCK_WR %p",\
+ __LINE__,(B)));B->query()->unlock_writing();}
#define BLOCK_UNLOCK_RD(B) { \
- DBUG_PRINT("lock", ("%d UNLOCK_RD 0x%lx",\
- __LINE__,(ulong)(B)));B->query()->unlock_reading();}
+ DBUG_PRINT("lock", ("%d UNLOCK_RD %p",\
+ __LINE__,(B)));B->query()->unlock_reading();}
#define DUMP(C) DBUG_EXECUTE("qcache", {\
(C)->cache_dump(); (C)->queries_dump();(C)->tables_dump();})
#else
@@ -646,7 +646,7 @@ bool Query_cache::try_lock(THD *thd, Cache_try_lock_mode mode)
else if (mode == TIMEOUT)
{
struct timespec waittime;
- set_timespec_nsec(waittime,(ulong)(50000000L)); /* Wait for 50 msec */
+ set_timespec_nsec(waittime,50000000UL); /* Wait for 50 msec */
int res= mysql_cond_timedwait(&COND_cache_status_changed,
&structure_guard_mutex, &waittime);
if (res == ETIMEDOUT)
@@ -820,7 +820,7 @@ inline Query_cache_block * Query_cache_block_table::block()
void Query_cache_block::init(ulong block_length)
{
DBUG_ENTER("Query_cache_block::init");
- DBUG_PRINT("qcache", ("init block: 0x%lx length: %lu", (ulong) this,
+ DBUG_PRINT("qcache", ("init block: %p length: %lu", this,
block_length));
length = block_length;
used = 0;
@@ -832,8 +832,8 @@ void Query_cache_block::init(ulong block_length)
void Query_cache_block::destroy()
{
DBUG_ENTER("Query_cache_block::destroy");
- DBUG_PRINT("qcache", ("destroy block 0x%lx, type %d",
- (ulong) this, type));
+ DBUG_PRINT("qcache", ("destroy block %p, type %d",
+ this, type));
type = INCOMPLETE;
DBUG_VOID_RETURN;
}
@@ -935,7 +935,7 @@ bool Query_cache_query::try_lock_writing()
DBUG_PRINT("info", ("can't lock rwlock"));
DBUG_RETURN(0);
}
- DBUG_PRINT("info", ("rwlock 0x%lx locked", (ulong) &lock));
+ DBUG_PRINT("info", ("rwlock %p locked", &lock));
DBUG_RETURN(1);
}
@@ -964,9 +964,9 @@ void Query_cache_query::init_n_lock()
res=0; wri = 0; len = 0; ready= 0; hit_count = 0;
mysql_rwlock_init(key_rwlock_query_cache_query_lock, &lock);
lock_writing();
- DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
- (long) (((uchar*) this) -
- ALIGN_SIZE(sizeof(Query_cache_block)))));
+ DBUG_PRINT("qcache", ("inited & locked query for block %p",
+ (uchar*) this -
+ ALIGN_SIZE(sizeof(Query_cache_block))));
DBUG_VOID_RETURN;
}
@@ -974,9 +974,9 @@ void Query_cache_query::init_n_lock()
void Query_cache_query::unlock_n_destroy()
{
DBUG_ENTER("Query_cache_query::unlock_n_destroy");
- DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx",
- (long) (((uchar*) this) -
- ALIGN_SIZE(sizeof(Query_cache_block)))));
+ DBUG_PRINT("qcache", ("destroyed & unlocked query for block %p",
+ (uchar*) this -
+ ALIGN_SIZE(sizeof(Query_cache_block))));
/*
The following call is not needed on system where one can destroy an
active semaphore
@@ -1109,7 +1109,7 @@ Query_cache::insert(THD *thd, Query_cache_tls *query_cache_tls,
{
DBUG_PRINT("warning", ("Can't append data"));
header->result(result);
- DBUG_PRINT("qcache", ("free query 0x%lx", (ulong) query_block));
+ DBUG_PRINT("qcache", ("free query %p", query_block));
// The following call will remove the lock on query_block
query_cache.free_query(query_block);
query_cache.refused++;
@@ -1445,8 +1445,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
flags.default_week_format= thd->variables.default_week_format;
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: %lu, TZ: 0x%lx, \
-sql mode: 0x%llx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
+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",
(int)flags.client_long_flag,
(int)flags.client_protocol_41,
@@ -1457,8 +1457,8 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
flags.character_set_client_num,
flags.character_set_results_num,
flags.collation_connection_num,
- (ulong) flags.limit,
- (ulong) flags.time_zone,
+ (ulonglong)flags.limit,
+ flags.time_zone,
flags.sql_mode,
flags.max_sort_length,
flags.group_concat_max_len,
@@ -1521,7 +1521,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
/* Check if another thread is processing the same query? */
Query_cache_block *competitor = (Query_cache_block *)
my_hash_search(&queries, (uchar*) query, tot_length);
- DBUG_PRINT("qcache", ("competitor 0x%lx", (ulong) competitor));
+ DBUG_PRINT("qcache", ("competitor %p", competitor));
if (competitor == 0)
{
/* Query is not in cache and no one is working with it; Store it */
@@ -1531,8 +1531,8 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
Query_cache_block::QUERY, local_tables);
if (query_block != 0)
{
- DBUG_PRINT("qcache", ("query block 0x%lx allocated, %lu",
- (ulong) query_block, query_block->used));
+ DBUG_PRINT("qcache", ("query block %p allocated, %lu",
+ query_block, query_block->used));
Query_cache_query *header = query_block->query();
header->init_n_lock();
@@ -1943,8 +1943,8 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length)
flags.lc_time_names= thd->variables.lc_time_names;
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: %lu, TZ: 0x%lx, \
-sql mode: 0x%llx, sort len: %lu, conncat len: %lu, div_precision: %lu, \
+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",
(int)flags.client_long_flag,
(int)flags.client_protocol_41,
@@ -1955,8 +1955,8 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
flags.character_set_client_num,
flags.character_set_results_num,
flags.collation_connection_num,
- (ulong) flags.limit,
- (ulong) flags.time_zone,
+ (ulonglong) flags.limit,
+ flags.time_zone,
flags.sql_mode,
flags.max_sort_length,
flags.group_concat_max_len,
@@ -1983,7 +1983,7 @@ lookup:
DBUG_PRINT("qcache", ("No query in query hash or no results"));
goto err_unlock;
}
- DBUG_PRINT("qcache", ("Query in query hash 0x%lx", (ulong)query_block));
+ DBUG_PRINT("qcache", ("Query in query hash %p",query_block));
#ifdef WITH_WSREP
if (once_more && WSREP_CLIENT(thd) && wsrep_must_sync_wait(thd))
@@ -2014,7 +2014,7 @@ lookup:
BLOCK_UNLOCK_RD(query_block);
goto err_unlock;
}
- DBUG_PRINT("qcache", ("Query have result 0x%lx", (ulong) query));
+ DBUG_PRINT("qcache", ("Query have result %p", query));
if (thd->in_multi_stmt_transaction_mode() &&
(query->tables_type() & HA_CACHE_TBL_TRANSACT))
@@ -2111,9 +2111,9 @@ lookup:
if (engine_data != table->engine_data())
{
DBUG_PRINT("qcache",
- ("Handler require invalidation queries of %.*s %lu-%lu",
+ ("Handler require invalidation queries of %.*s %llu-%llu",
qcache_se_key_len, qcache_se_key_name,
- (ulong) engine_data, (ulong) table->engine_data()));
+ engine_data, table->engine_data()));
invalidate_table_internal(thd,
(uchar *) table->db(),
table->key_length());
@@ -2152,9 +2152,9 @@ lookup:
THD_STAGE_INFO(thd, stage_sending_cached_result_to_client);
do
{
- DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %lu)",
+ DBUG_PRINT("qcache", ("Results (len: %lu used: %lu headers: %u)",
result_block->length, result_block->used,
- (ulong) (result_block->headers_len()+
+ (uint) (result_block->headers_len()+
ALIGN_SIZE(sizeof(Query_cache_result)))));
Query_cache_result *result = result_block->result();
@@ -2192,7 +2192,7 @@ lookup:
thd->get_stmt_da()->disable_status();
BLOCK_UNLOCK_RD(query_block);
- MYSQL_QUERY_CACHE_HIT(thd->query(), (ulong) thd->limit_found_rows);
+ MYSQL_QUERY_CACHE_HIT(thd->query(), thd->limit_found_rows);
DBUG_RETURN(1); // Result sent to client
err_unlock:
@@ -2899,8 +2899,8 @@ 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 0x%lx %lu bytes result",
- (ulong) query_block,
+ DBUG_PRINT("qcache", ("free query %p %lu bytes result",
+ query_block,
query_block->query()->length() ));
queries_in_cache--;
@@ -2969,8 +2969,8 @@ 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 0x%lx %lu bytes result",
- (ulong) query_block,
+ DBUG_PRINT("qcache", ("free query %p %lu bytes result",
+ query_block,
query_block->query()->length() ));
my_hash_delete(&queries,(uchar *) query_block);
@@ -3017,8 +3017,8 @@ Query_cache::append_result_data(Query_cache_block **current_block,
Query_cache_block *query_block)
{
DBUG_ENTER("Query_cache::append_result_data");
- DBUG_PRINT("qcache", ("append %lu bytes to 0x%lx query",
- data_len, (long) query_block));
+ DBUG_PRINT("qcache", ("append %lu bytes to %p query",
+ data_len, query_block));
if (query_block->query()->add(data_len) > query_cache_limit)
{
@@ -3035,8 +3035,8 @@ Query_cache::append_result_data(Query_cache_block **current_block,
}
Query_cache_block *last_block = (*current_block)->prev;
- DBUG_PRINT("qcache", ("lastblock 0x%lx len %lu used %lu",
- (ulong) last_block, last_block->length,
+ DBUG_PRINT("qcache", ("lastblock %p len %lu used %lu",
+ last_block, last_block->length,
last_block->used));
my_bool success = 1;
ulong last_block_free_space= last_block->length - last_block->used;
@@ -3081,8 +3081,8 @@ Query_cache::append_result_data(Query_cache_block **current_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 0x%lx to copy %lub",
- last_block_free_space, (ulong)last_block, to_copy));
+ DBUG_PRINT("qcache", ("use free space %lub at block %p to copy %lub",
+ last_block_free_space,last_block, to_copy));
memcpy((uchar*) last_block + last_block->used, data, to_copy);
last_block->used+=to_copy;
}
@@ -3123,8 +3123,8 @@ my_bool Query_cache::write_result_data(Query_cache_block **result_block,
{
block->type = type;
ulong length = block->used - headers_len;
- DBUG_PRINT("qcache", ("write %lu byte in block 0x%lx",length,
- (ulong)block));
+ DBUG_PRINT("qcache", ("write %lu byte in block %p",length,
+ block));
memcpy((uchar*) block+headers_len, rest, length);
rest += length;
block = block->next;
@@ -3387,12 +3387,12 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used,
else
{
DBUG_PRINT("qcache",
- ("table: %s db: %s openinfo: 0x%lx keylen: %lu key: 0x%lx",
+ ("table: %s db: %s openinfo: %p keylen: %zu key: %p",
tables_used->table->s->table_name.str,
tables_used->table->s->table_cache_key.str,
- (ulong) tables_used->table,
- (ulong) tables_used->table->s->table_cache_key.length,
- (ulong) tables_used->table->s->table_cache_key.str));
+ tables_used->table,
+ tables_used->table->s->table_cache_key.length,
+ tables_used->table->s->table_cache_key.str));
if (!insert_table(thd, tables_used->table->s->table_cache_key.length,
tables_used->table->s->table_cache_key.str,
@@ -3429,8 +3429,8 @@ my_bool Query_cache::register_all_tables(THD *thd,
TABLE_COUNTER_TYPE tables_arg)
{
TABLE_COUNTER_TYPE n;
- DBUG_PRINT("qcache", ("register tables block 0x%lx, n %d, header %x",
- (ulong) block, (int) tables_arg,
+ DBUG_PRINT("qcache", ("register tables block %p, n %d, header %x",
+ block, (int) tables_arg,
(int) ALIGN_SIZE(sizeof(Query_cache_block))));
Query_cache_block_table *block_table = block->table(0);
@@ -3469,8 +3469,8 @@ Query_cache::insert_table(THD *thd, uint key_len, const char *key,
my_bool hash)
{
DBUG_ENTER("Query_cache::insert_table");
- DBUG_PRINT("qcache", ("insert table node 0x%lx, len %d",
- (ulong)node, key_len));
+ DBUG_PRINT("qcache", ("insert table node %p, len %d",
+ node, key_len));
Query_cache_block *table_block=
(hash ?
@@ -3481,11 +3481,11 @@ Query_cache::insert_table(THD *thd, uint key_len, const char *key,
table_block->table()->engine_data() != engine_data)
{
DBUG_PRINT("qcache",
- ("Handler require invalidation queries of %s.%s %lu-%lu",
+ ("Handler require invalidation queries of %s.%s %llu-%llu",
table_block->table()->db(),
table_block->table()->table(),
- (ulong) engine_data,
- (ulong) table_block->table()->engine_data()));
+ engine_data,
+ table_block->table()->engine_data()));
/*
as far as we delete all queries with this table, table block will be
deleted, too
@@ -3500,8 +3500,8 @@ Query_cache::insert_table(THD *thd, uint key_len, const char *key,
if (table_block == 0)
{
- DBUG_PRINT("qcache", ("new table block from 0x%lx (%u)",
- (ulong) key, (int) key_len));
+ DBUG_PRINT("qcache", ("new table block from %p (%u)",
+ key, (int) key_len));
table_block= write_block_data(key_len, (uchar*) key,
ALIGN_SIZE(sizeof(Query_cache_table)),
Query_cache_block::TABLE, 1);
@@ -3710,7 +3710,7 @@ Query_cache::get_free_block(ulong len, my_bool not_less, ulong min)
if (block != 0)
exclude_from_free_memory_list(block);
- DBUG_PRINT("qcache",("getting block 0x%lx", (ulong) block));
+ DBUG_PRINT("qcache",("getting block %p", block));
DBUG_RETURN(block);
}
@@ -3721,9 +3721,9 @@ void Query_cache::free_memory_block(Query_cache_block *block)
block->used=0;
block->type= Query_cache_block::FREE; // mark block as free in any case
DBUG_PRINT("qcache",
- ("first_block 0x%lx, block 0x%lx, pnext 0x%lx pprev 0x%lx",
- (ulong) first_block, (ulong) block, (ulong) block->pnext,
- (ulong) block->pprev));
+ ("first_block %p, block %p, pnext %p pprev %p",
+ first_block, block, block->pnext,
+ block->pprev));
if (block->pnext != first_block && block->pnext->is_free())
block = join_free_blocks(block, block->pnext);
@@ -3755,8 +3755,8 @@ void Query_cache::split_block(Query_cache_block *block, ulong len)
else
free_memory_block(new_block);
- DBUG_PRINT("qcache", ("split 0x%lx (%lu) new 0x%lx",
- (ulong) block, len, (ulong) new_block));
+ DBUG_PRINT("qcache", ("split %p (%lu) new %p",
+ block, len, new_block));
DBUG_VOID_RETURN;
}
@@ -3768,9 +3768,9 @@ Query_cache::join_free_blocks(Query_cache_block *first_block_arg,
Query_cache_block *second_block;
DBUG_ENTER("Query_cache::join_free_blocks");
DBUG_PRINT("qcache",
- ("join first 0x%lx, pnext 0x%lx, in list 0x%lx",
- (ulong) first_block_arg, (ulong) first_block_arg->pnext,
- (ulong) block_in_list));
+ ("join first %p, pnext %p, in list %p",
+ first_block_arg, first_block_arg->pnext,
+ block_in_list));
exclude_from_free_memory_list(block_in_list);
second_block = first_block_arg->pnext;
@@ -3792,7 +3792,7 @@ my_bool Query_cache::append_next_free_block(Query_cache_block *block,
{
Query_cache_block *next_block = block->pnext;
DBUG_ENTER("Query_cache::append_next_free_block");
- DBUG_PRINT("enter", ("block 0x%lx, add_size %lu", (ulong) block,
+ DBUG_PRINT("enter", ("block %p, add_size %lu", block,
add_size));
if (next_block != first_block && next_block->is_free())
@@ -3824,8 +3824,8 @@ void Query_cache::exclude_from_free_memory_list(Query_cache_block *free_block)
bin->number--;
free_memory-=free_block->length;
free_memory_blocks--;
- DBUG_PRINT("qcache",("exclude block 0x%lx, bin 0x%lx", (ulong) free_block,
- (ulong) bin));
+ DBUG_PRINT("qcache",("exclude block %p, bin %p", free_block,
+ bin));
DBUG_VOID_RETURN;
}
@@ -3842,8 +3842,8 @@ void Query_cache::insert_into_free_memory_list(Query_cache_block *free_block)
free_block->data());
*bin_ptr = bins+idx;
(*bin_ptr)->number++;
- DBUG_PRINT("qcache",("insert block 0x%lx, bin[%d] 0x%lx",
- (ulong) free_block, idx, (ulong) *bin_ptr));
+ DBUG_PRINT("qcache",("insert block %p, bin[%d] %p",
+ free_block, idx, *bin_ptr));
DBUG_VOID_RETURN;
}
@@ -3940,7 +3940,7 @@ Query_cache::double_linked_list_simple_include(Query_cache_block *point,
list_pointer)
{
DBUG_ENTER("Query_cache::double_linked_list_simple_include");
- DBUG_PRINT("qcache", ("including block 0x%lx", (ulong) point));
+ DBUG_PRINT("qcache", ("including block %p", point));
if (*list_pointer == 0)
*list_pointer=point->next=point->prev=point;
else
@@ -3959,8 +3959,8 @@ Query_cache::double_linked_list_exclude(Query_cache_block *point,
Query_cache_block **list_pointer)
{
DBUG_ENTER("Query_cache::double_linked_list_exclude");
- DBUG_PRINT("qcache", ("excluding block 0x%lx, list 0x%lx",
- (ulong) point, (ulong) list_pointer));
+ DBUG_PRINT("qcache", ("excluding block %p, list %p",
+ point, list_pointer));
if (point->next == point)
*list_pointer = 0; // empty list
else
@@ -4249,7 +4249,7 @@ my_bool Query_cache::move_by_type(uchar **border,
switch (block->type) {
case Query_cache_block::FREE:
{
- DBUG_PRINT("qcache", ("block 0x%lx FREE", (ulong) block));
+ DBUG_PRINT("qcache", ("block %p FREE", block));
if (*border == 0)
{
*border = (uchar *) block;
@@ -4268,7 +4268,7 @@ my_bool Query_cache::move_by_type(uchar **border,
case Query_cache_block::TABLE:
{
HASH_SEARCH_STATE record_idx;
- DBUG_PRINT("qcache", ("block 0x%lx TABLE", (ulong) block));
+ DBUG_PRINT("qcache", ("block %p TABLE", block));
if (*border == 0)
break;
ulong len = block->length, used = block->used;
@@ -4304,9 +4304,9 @@ my_bool Query_cache::move_by_type(uchar **border,
nlist_root->prev = tprev;
tprev->next = nlist_root;
DBUG_PRINT("qcache",
- ("list_root: 0x%lx tnext 0x%lx tprev 0x%lx tprev->next 0x%lx tnext->prev 0x%lx",
- (ulong) list_root, (ulong) tnext, (ulong) tprev,
- (ulong)tprev->next, (ulong)tnext->prev));
+ ("list_root: %p tnext %p tprev %p tprev->next %p tnext->prev %p",
+ list_root, tnext, tprev,
+ tprev->next,tnext->prev));
/*
Go through all queries that uses this table and change them to
point to the new table object
@@ -4321,14 +4321,14 @@ 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 0x%lx, new gap at 0x%lx",
- len, (ulong) new_block, (ulong) *border));
+ DBUG_PRINT("qcache", ("moved %lu bytes to %p, new gap at %p",
+ len, new_block, *border));
break;
}
case Query_cache_block::QUERY:
{
HASH_SEARCH_STATE record_idx;
- DBUG_PRINT("qcache", ("block 0x%lx QUERY", (ulong) block));
+ DBUG_PRINT("qcache", ("block %p QUERY", block));
if (*border == 0)
break;
BLOCK_LOCK_WR(block);
@@ -4414,8 +4414,8 @@ 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 0x%lx, new gap at 0x%lx",
- len, (ulong) new_block, (ulong) *border));
+ DBUG_PRINT("qcache", ("moved %lu bytes to %p, new gap at %p",
+ len, new_block, *border));
break;
}
case Query_cache_block::RES_INCOMPLETE:
@@ -4423,7 +4423,7 @@ my_bool Query_cache::move_by_type(uchar **border,
case Query_cache_block::RES_CONT:
case Query_cache_block::RESULT:
{
- DBUG_PRINT("qcache", ("block 0x%lx RES* (%d)", (ulong) block,
+ DBUG_PRINT("qcache", ("block %p RES* (%d)", block,
(int) block->type));
if (*border == 0)
break;
@@ -4463,13 +4463,13 @@ my_bool Query_cache::move_by_type(uchar **border,
new_block->length -= free_space;
}
BLOCK_UNLOCK_WR(query_block);
- DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx",
- len, (ulong) new_block, (ulong) *border));
+ DBUG_PRINT("qcache", ("moved %lu bytes to %p, new gap at %p",
+ len, new_block, *border));
break;
}
default:
- DBUG_PRINT("error", ("unexpected block type %d, block 0x%lx",
- (int)block->type, (ulong) block));
+ DBUG_PRINT("error", ("unexpected block type %d, block %p",
+ (int)block->type, block));
ok = 0;
}
DBUG_RETURN(ok);
@@ -4670,16 +4670,16 @@ void Query_cache::bins_dump()
DBUG_PRINT("qcache", ("-------------------------"));
for (i=0; i < mem_bin_num; i++)
{
- DBUG_PRINT("qcache", ("%10lu %3d 0x%lx", bins[i].size, bins[i].number,
- (ulong)&(bins[i])));
+ DBUG_PRINT("qcache", ("%10lu %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 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx",
- block->length, (ulong)block,
- (ulong)block->next, (ulong)block->prev,
- (ulong)block->pnext, (ulong)block->pprev));
+ DBUG_PRINT("qcache", ("\\-- %lu %p %p %p %p %p",
+ block->length,block,
+ block->next,block->prev,
+ block->pnext,block->pprev));
block = block->next;
} while ( block != bins[i].free_blocks );
}
@@ -4703,11 +4703,11 @@ void Query_cache::cache_dump()
do
{
DBUG_PRINT("qcache",
- ("%10lu %10lu %1d %2d 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx",
+ ("%10lu %10lu %1d %2d %p %p %p %p %p",
i->length, i->used, (int)i->type,
- i->n_tables, (ulong)i,
- (ulong)i->next, (ulong)i->prev, (ulong)i->pnext,
- (ulong)i->pprev));
+ i->n_tables,i,
+ i->next,i->prev,i->pnext,
+ i->pprev));
i = i->pnext;
} while ( i != first_block );
DBUG_PRINT("qcache", ("-------------------------------------"));
@@ -4737,15 +4737,15 @@ void Query_cache::queries_dump()
Query_cache_query_flags flags;
memcpy(&flags, str+len, QUERY_CACHE_FLAGS_SIZE);
str[len]= 0; // make zero ending DB name
- DBUG_PRINT("qcache", ("F: %u C: %u L: %lu T: '%s' (%lu) '%s' '%s'",
+ DBUG_PRINT("qcache", ("F: %u C: %u L: %llu T: '%s' (%zu) '%s' '%s'",
flags.client_long_flag,
flags.character_set_client_num,
- (ulong)flags.limit,
+ flags.limit,
flags.time_zone->get_name()->ptr(),
- (ulong) len, str, strend(str)+1));
- DBUG_PRINT("qcache", ("-b- 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx", (ulong) block,
- (ulong) block->next, (ulong) block->prev,
- (ulong)block->pnext, (ulong)block->pprev));
+ len, str, strend(str)+1));
+ DBUG_PRINT("qcache", ("-b- %p %p %p %p %p", block,
+ block->next, block->prev,
+ block->pnext,block->pprev));
memcpy(str + len, &flags, QUERY_CACHE_FLAGS_SIZE); // restore flags
for (TABLE_COUNTER_TYPE t= 0; t < block->n_tables; t++)
{
@@ -4759,14 +4759,14 @@ void Query_cache::queries_dump()
Query_cache_block *result_beg = result_block;
do
{
- DBUG_PRINT("qcache", ("-r- %u %lu/%lu 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx",
+ DBUG_PRINT("qcache", ("-r- %u %lu/%lu %p %p %p %p %p",
(uint) result_block->type,
result_block->length, result_block->used,
- (ulong) result_block,
- (ulong) result_block->next,
- (ulong) result_block->prev,
- (ulong) result_block->pnext,
- (ulong) result_block->pprev));
+ result_block,
+ result_block->next,
+ result_block->prev,
+ result_block->pnext,
+ result_block->pprev));
result_block = result_block->next;
} while ( result_block != result_beg );
}
@@ -4845,14 +4845,14 @@ my_bool Query_cache::check_integrity(bool locked)
if (!block)
break;
- DBUG_PRINT("qcache", ("block 0x%lx, type %u...",
- (ulong) block, (uint) block->type));
+ DBUG_PRINT("qcache", ("block %p, type %u...",
+ block, (uint) block->type));
// Check allignment
- if ((((long)block) % (long) ALIGN_SIZE(1)) !=
- (((long)first_block) % (long)ALIGN_SIZE(1)))
+ if ((((size_t)block) % ALIGN_SIZE(1)) !=
+ (((size_t)first_block) % ALIGN_SIZE(1)))
{
DBUG_PRINT("error",
- ("block 0x%lx do not aligned by %d", (ulong) block,
+ ("block %p do not aligned by %d", block,
(int) ALIGN_SIZE(1)));
result = 1;
}
@@ -4863,10 +4863,10 @@ my_bool Query_cache::check_integrity(bool locked)
((uchar*)first_block) + query_cache_size)
{
DBUG_PRINT("error",
- ("block 0x%lx, type %u, ended at 0x%lx, but cache ended at 0x%lx",
- (ulong) block, (uint) block->type,
- (ulong) (((uchar*)block) + block->length),
- (ulong) (((uchar*)first_block) + query_cache_size)));
+ ("block %p, type %u, ended at %p, but cache ended at %p",
+ block, (uint) block->type,
+ (((uchar*)block) + block->length),
+ (((uchar*)first_block) + query_cache_size)));
result = 1;
}
}
@@ -4874,10 +4874,10 @@ my_bool Query_cache::check_integrity(bool locked)
if (((uchar*)block) + block->length != ((uchar*)block->pnext))
{
DBUG_PRINT("error",
- ("block 0x%lx, type %u, ended at 0x%lx, but next block beginning at 0x%lx",
- (ulong) block, (uint) block->type,
- (ulong) (((uchar*)block) + block->length),
- (ulong) ((uchar*)block->pnext)));
+ ("block %p, type %u, ended at %p, but next block beginning at %p",
+ block, (uint) block->type,
+ (((uchar*)block) + block->length),
+ ((uchar*)block->pnext)));
}
if (block->type == Query_cache_block::FREE)
free+= block->length;
@@ -4893,11 +4893,11 @@ my_bool Query_cache::check_integrity(bool locked)
((uchar*)bin) >= ((uchar*)first_block))
{
DBUG_PRINT("error",
- ("free block 0x%lx have bin pointer 0x%lx beyaond of bins array bounds [0x%lx,0x%lx]",
- (ulong) block,
- (ulong) bin,
- (ulong) bins,
- (ulong) first_block));
+ ("free block %p have bin pointer %p beyaond of bins array bounds [%p,%p]",
+ block,
+ bin,
+ bins,
+ first_block));
result = 1;
}
else
@@ -4944,11 +4944,11 @@ my_bool Query_cache::check_integrity(bool locked)
((uchar*)query_block) >= (((uchar*)first_block) + query_cache_size))
{
DBUG_PRINT("error",
- ("result block 0x%lx have query block pointer 0x%lx beyaond of block pool bounds [0x%lx,0x%lx]",
- (ulong) block,
- (ulong) query_block,
- (ulong) first_block,
- (ulong) (((uchar*)first_block) + query_cache_size)));
+ ("result block %p have query block pointer %p beyaond of block pool bounds [%p,%p]",
+ block,
+ query_block,
+ first_block,
+ (((uchar*)first_block) + query_cache_size)));
result = 1;
}
else
@@ -4964,8 +4964,8 @@ my_bool Query_cache::check_integrity(bool locked)
break;
}
default:
- DBUG_PRINT("error", ("block 0x%lx have incorrect type %u",
- (long) block, block->type));
+ DBUG_PRINT("error", ("block %p have incorrect type %u",
+ block, block->type));
result = 1;
}
@@ -4993,15 +4993,15 @@ my_bool Query_cache::check_integrity(bool locked)
{
do
{
- DBUG_PRINT("qcache", ("block 0x%lx, type %u...",
- (ulong) block, (uint) block->type));
+ DBUG_PRINT("qcache", ("block %p, type %u...",
+ block, (uint) block->type));
size_t length;
uchar *key = query_cache_query_get_key((uchar*) block, &length, 0);
uchar* val = my_hash_search(&queries, key, length);
if (((uchar*)block) != val)
{
- DBUG_PRINT("error", ("block 0x%lx found in queries hash like 0x%lx",
- (ulong) block, (ulong) val));
+ DBUG_PRINT("error", ("block %p found in queries hash like %p",
+ block, val));
}
if (in_blocks(block))
result = 1;
@@ -5011,8 +5011,8 @@ my_bool Query_cache::check_integrity(bool locked)
Query_cache_block * result_block = results;
do
{
- DBUG_PRINT("qcache", ("block 0x%lx, type %u...",
- (ulong) block, (uint) block->type));
+ DBUG_PRINT("qcache", ("block %p, type %u...",
+ block, (uint) block->type));
if (in_blocks(result_block))
result = 1;
@@ -5028,15 +5028,15 @@ my_bool Query_cache::check_integrity(bool locked)
{
do
{
- DBUG_PRINT("qcache", ("block 0x%lx, type %u...",
- (ulong) block, (uint) block->type));
+ DBUG_PRINT("qcache", ("block %p, type %u...",
+ block, (uint) block->type));
size_t length;
uchar *key = query_cache_table_get_key((uchar*) block, &length, 0);
uchar* val = my_hash_search(&tables, key, length);
if (((uchar*)block) != val)
{
- DBUG_PRINT("error", ("block 0x%lx found in tables hash like 0x%lx",
- (ulong) block, (ulong) val));
+ DBUG_PRINT("error", ("block %p found in tables hash like %p",
+ block, val));
}
if (in_blocks(block))
@@ -5053,8 +5053,8 @@ my_bool Query_cache::check_integrity(bool locked)
uint count = 0;
do
{
- DBUG_PRINT("qcache", ("block 0x%lx, type %u...",
- (ulong) block, (uint) block->type));
+ DBUG_PRINT("qcache", ("block %p, type %u...",
+ block, (uint) block->type));
if (in_blocks(block))
result = 1;
@@ -5086,13 +5086,13 @@ my_bool Query_cache::in_blocks(Query_cache_block * point)
if (block->pprev->pnext != block)
{
DBUG_PRINT("error",
- ("block 0x%lx in physical list is incorrect linked, prev block 0x%lx refered as next to 0x%lx (check from 0x%lx)",
- (ulong) block, (ulong) block->pprev,
- (ulong) block->pprev->pnext,
- (ulong) point));
+ ("block %p in physical list is incorrect linked, prev block %p refered as next to %p (check from %p)",
+ block, block->pprev,
+ block->pprev->pnext,
+ point));
//back trace
for (; block != point; block = block->pnext)
- DBUG_PRINT("error", ("back trace 0x%lx", (ulong) block));
+ DBUG_PRINT("error", ("back trace %p", block));
result = 1;
goto err1;
}
@@ -5101,8 +5101,8 @@ my_bool Query_cache::in_blocks(Query_cache_block * point)
if (block != first_block)
{
DBUG_PRINT("error",
- ("block 0x%lx (0x%lx<-->0x%lx) not owned by pysical list",
- (ulong) block, (ulong) block->pprev, (ulong )block->pnext));
+ ("block %p (%p<-->%p) not owned by pysical list",
+ block, block->pprev, block->pnext));
return 1;
}
@@ -5114,13 +5114,13 @@ err1:
if (block->pnext->pprev != block)
{
DBUG_PRINT("error",
- ("block 0x%lx in physicel list is incorrect linked, next block 0x%lx refered as prev to 0x%lx (check from 0x%lx)",
- (ulong) block, (ulong) block->pnext,
- (ulong) block->pnext->pprev,
- (ulong) point));
+ ("block %p in physicel list is incorrect linked, next block %p refered as prev to %p (check from %p)",
+ block, block->pnext,
+ block->pnext->pprev,
+ point));
//back trace
for (; block != point; block = block->pprev)
- DBUG_PRINT("error", ("back trace 0x%lx", (ulong) block));
+ DBUG_PRINT("error", ("back trace %p", block));
result = 1;
goto err2;
}
@@ -5143,13 +5143,13 @@ my_bool Query_cache::in_list(Query_cache_block * root,
if (block->prev->next != block)
{
DBUG_PRINT("error",
- ("block 0x%lx in list '%s' 0x%lx is incorrect linked, prev block 0x%lx refered as next to 0x%lx (check from 0x%lx)",
- (ulong) block, name, (ulong) root, (ulong) block->prev,
- (ulong) block->prev->next,
- (ulong) point));
+ ("block %p in list '%s' %p is incorrect linked, prev block %p refered as next to %p (check from %p)",
+ block, name, root, block->prev,
+ block->prev->next,
+ point));
//back trace
for (; block != point; block = block->next)
- DBUG_PRINT("error", ("back trace 0x%lx", (ulong) block));
+ DBUG_PRINT("error", ("back trace %p", block));
result = 1;
goto err1;
}
@@ -5158,10 +5158,10 @@ my_bool Query_cache::in_list(Query_cache_block * root,
if (block != root)
{
DBUG_PRINT("error",
- ("block 0x%lx (0x%lx<-->0x%lx) not owned by list '%s' 0x%lx",
- (ulong) block,
- (ulong) block->prev, (ulong) block->next,
- name, (ulong) root));
+ ("block %p (%p<-->%p) not owned by list '%s' %p",
+ block,
+ block->prev, block->next,
+ name, root));
return 1;
}
err1:
@@ -5172,13 +5172,13 @@ err1:
if (block->next->prev != block)
{
DBUG_PRINT("error",
- ("block 0x%lx in list '%s' 0x%lx is incorrect linked, next block 0x%lx refered as prev to 0x%lx (check from 0x%lx)",
- (ulong) block, name, (ulong) root, (ulong) block->next,
- (ulong) block->next->prev,
- (ulong) point));
+ ("block %p in list '%s' %p is incorrect linked, next block %p refered as prev to %p (check from %p)",
+ block, name, root, block->next,
+ block->next->prev,
+ point));
//back trace
for (; block != point; block = block->prev)
- DBUG_PRINT("error", ("back trace 0x%lx", (ulong) block));
+ DBUG_PRINT("error", ("back trace %p", block));
result = 1;
goto err2;
}
@@ -5191,13 +5191,13 @@ err2:
void dump_node(Query_cache_block_table * node,
const char * call, const char * descr)
{
- DBUG_PRINT("qcache", ("%s: %s: node: 0x%lx", call, descr, (ulong) node));
- DBUG_PRINT("qcache", ("%s: %s: node block: 0x%lx",
- call, descr, (ulong) node->block()));
- DBUG_PRINT("qcache", ("%s: %s: next: 0x%lx", call, descr,
- (ulong) node->next));
- DBUG_PRINT("qcache", ("%s: %s: prev: 0x%lx", call, descr,
- (ulong) node->prev));
+ DBUG_PRINT("qcache", ("%s: %s: node: %p", call, descr, node));
+ DBUG_PRINT("qcache", ("%s: %s: node block: %p",
+ call, descr, node->block()));
+ DBUG_PRINT("qcache", ("%s: %s: next: %p", call, descr,
+ node->next));
+ DBUG_PRINT("qcache", ("%s: %s: prev: %p", call, descr,
+ node->prev));
}
my_bool Query_cache::in_table_list(Query_cache_block_table * root,
@@ -5214,17 +5214,17 @@ my_bool Query_cache::in_table_list(Query_cache_block_table * root,
if (table->prev->next != table)
{
DBUG_PRINT("error",
- ("table 0x%lx(0x%lx) in list '%s' 0x%lx(0x%lx) is incorrect linked, prev table 0x%lx(0x%lx) refered as next to 0x%lx(0x%lx) (check from 0x%lx(0x%lx))",
- (ulong) table, (ulong) table->block(), name,
- (ulong) root, (ulong) root->block(),
- (ulong) table->prev, (ulong) table->prev->block(),
- (ulong) table->prev->next,
- (ulong) table->prev->next->block(),
- (ulong) point, (ulong) point->block()));
+ ("table %p(%p) in list '%s' %p(%p) is incorrect linked, prev table %p(%p) refered as next to %p(%p) (check from %p(%p))",
+ table, table->block(), name,
+ root, root->block(),
+ table->prev, table->prev->block(),
+ table->prev->next,
+ table->prev->next->block(),
+ point, point->block()));
//back trace
for (; table != point; table = table->next)
- DBUG_PRINT("error", ("back trace 0x%lx(0x%lx)",
- (ulong) table, (ulong) table->block()));
+ DBUG_PRINT("error", ("back trace %p(%p)",
+ table, table->block()));
result = 1;
goto err1;
}
@@ -5233,11 +5233,11 @@ my_bool Query_cache::in_table_list(Query_cache_block_table * root,
if (table != root)
{
DBUG_PRINT("error",
- ("table 0x%lx(0x%lx) (0x%lx(0x%lx)<-->0x%lx(0x%lx)) not owned by list '%s' 0x%lx(0x%lx)",
- (ulong) table, (ulong) table->block(),
- (ulong) table->prev, (ulong) table->prev->block(),
- (ulong) table->next, (ulong) table->next->block(),
- name, (ulong) root, (ulong) root->block()));
+ ("table %p(%p) (%p(%p)<-->%p(%p)) not owned by list '%s' %p(%p)",
+ table, table->block(),
+ table->prev, table->prev->block(),
+ table->next, table->next->block(),
+ name, root, root->block()));
return 1;
}
err1:
@@ -5249,17 +5249,17 @@ err1:
if (table->next->prev != table)
{
DBUG_PRINT("error",
- ("table 0x%lx(0x%lx) in list '%s' 0x%lx(0x%lx) is incorrect linked, next table 0x%lx(0x%lx) refered as prev to 0x%lx(0x%lx) (check from 0x%lx(0x%lx))",
- (ulong) table, (ulong) table->block(),
- name, (ulong) root, (ulong) root->block(),
- (ulong) table->next, (ulong) table->next->block(),
- (ulong) table->next->prev,
- (ulong) table->next->prev->block(),
- (ulong) point, (ulong) point->block()));
+ ("table %p(%p) in list '%s' %p(%p) is incorrect linked, next table %p(%p) refered as prev to %p(%p) (check from %p(%p))",
+ table, table->block(),
+ name, root, root->block(),
+ table->next, table->next->block(),
+ table->next->prev,
+ table->next->prev->block(),
+ point, point->block()));
//back trace
for (; table != point; table = table->prev)
- DBUG_PRINT("error", ("back trace 0x%lx(0x%lx)",
- (ulong) table, (ulong) table->block()));
+ DBUG_PRINT("error", ("back trace %p(%p)",
+ table, table->block()));
result = 1;
goto err2;
}
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index 383bff305d9..a6592e9b782 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -560,8 +560,8 @@ struct Query_cache_query_flags
ha_rows limit;
Time_zone *time_zone;
sql_mode_t sql_mode;
- ulong max_sort_length;
- ulong group_concat_max_len;
+ ulonglong max_sort_length;
+ ulonglong group_concat_max_len;
ulong default_week_format;
ulong div_precision_increment;
MY_LOCALE *lc_time_names;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2a66427a26f..5c8a378eacd 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -569,8 +569,8 @@ char *thd_get_error_context_description(THD *thd, char *buffer,
const char *proc_info= thd->proc_info;
len= my_snprintf(header, sizeof(header),
- "MySQL thread id %lu, OS thread handle %p, query id %lu",
- (ulong) thd->thread_id, (void*) thd->real_id, (ulong) thd->query_id);
+ "MySQL thread id %lu, OS thread handle %lu, query id %lu",
+ (ulong) thd->thread_id, (ulong) thd->real_id, (ulong) thd->query_id);
str.length(0);
str.append(header, len);
@@ -936,7 +936,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
by adding the address of the stack.
*/
tmp= (ulong) (my_rnd(&sql_rand) * 0xffffffff);
- my_rnd_init(&rand, tmp + (ulong) &rand, tmp + (ulong) ::global_query_id);
+ my_rnd_init(&rand, tmp + (ulong)((size_t) &rand), tmp + (ulong) ::global_query_id);
substitute_null_with_insert_id = FALSE;
lock_info.mysql_thd= (void *)this;
@@ -1177,13 +1177,13 @@ Sql_condition* THD::raise_condition(uint sql_errno,
}
extern "C"
-void *thd_alloc(MYSQL_THD thd, unsigned int size)
+void *thd_alloc(MYSQL_THD thd, size_t size)
{
return thd->alloc(size);
}
extern "C"
-void *thd_calloc(MYSQL_THD thd, unsigned int size)
+void *thd_calloc(MYSQL_THD thd, size_t size)
{
return thd->calloc(size);
}
@@ -1195,14 +1195,14 @@ char *thd_strdup(MYSQL_THD thd, const char *str)
}
extern "C"
-char *thd_strmake(MYSQL_THD thd, const char *str, unsigned int size)
+char *thd_strmake(MYSQL_THD thd, const char *str, size_t size)
{
return thd->strmake(str, size);
}
extern "C"
LEX_CSTRING *thd_make_lex_string(THD *thd, LEX_CSTRING *lex_str,
- const char *str, unsigned int size,
+ const char *str, size_t size,
int allocate_lex_string)
{
return allocate_lex_string ? thd->make_clex_string(str, size)
@@ -1210,7 +1210,7 @@ LEX_CSTRING *thd_make_lex_string(THD *thd, LEX_CSTRING *lex_str,
}
extern "C"
-void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size)
+void *thd_memdup(MYSQL_THD thd, const void* str, size_t size)
{
return thd->memdup(str, size);
}
@@ -3634,7 +3634,7 @@ void Query_arena::free_items()
{
next= free_list->next;
DBUG_ASSERT(free_list != next);
- DBUG_PRINT("info", ("free item: 0x%lx", (ulong) free_list));
+ DBUG_PRINT("info", ("free item: %p", free_list));
free_list->delete_self();
}
/* Postcondition: free_list is 0 */
@@ -4103,7 +4103,7 @@ int select_materialize_with_stats::send_data(List<Item> &items)
void TMP_TABLE_PARAM::init()
{
DBUG_ENTER("TMP_TABLE_PARAM::init");
- DBUG_PRINT("enter", ("this: 0x%lx", (ulong)this));
+ DBUG_PRINT("enter", ("this: %p", this));
field_count= sum_func_count= func_count= hidden_field_count= 0;
group_parts= group_length= group_null_parts= 0;
quick_group= 1;
@@ -5403,9 +5403,9 @@ void THD::inc_status_sort_range()
void THD::inc_status_sort_rows(ha_rows count)
{
- statistic_add(status_var.filesort_rows_, count, &LOCK_status);
+ statistic_add(status_var.filesort_rows_, (ulong)count, &LOCK_status);
#ifdef HAVE_PSI_STATEMENT_INTERFACE
- PSI_STATEMENT_CALL(inc_statement_sort_rows)(m_statement_psi, count);
+ PSI_STATEMENT_CALL(inc_statement_sort_rows)(m_statement_psi, (ulong)count);
#endif
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 7d4a34b6613..bc72fc25a18 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3949,7 +3949,7 @@ public:
mysql_mutex_unlock(&LOCK_thd_data);
#ifdef HAVE_PSI_THREAD_INTERFACE
if (result)
- PSI_THREAD_CALL(set_thread_db)(new_db, new_db_len);
+ PSI_THREAD_CALL(set_thread_db)(new_db, (int) new_db_len);
#endif
return result;
}
@@ -3974,7 +3974,7 @@ public:
db_length= new_db_len;
mysql_mutex_unlock(&LOCK_thd_data);
#ifdef HAVE_PSI_THREAD_INTERFACE
- PSI_THREAD_CALL(set_thread_db)(new_db, new_db_len);
+ PSI_THREAD_CALL(set_thread_db)(new_db, (int) new_db_len);
#endif
}
}
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 3a161ce6d31..32ff44d9343 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -45,7 +45,7 @@
// end_read_record
#include "sql_partition.h" // make_used_partitions_str
-#define MEM_STRIP_BUF_SIZE thd->variables.sortbuff_size
+#define MEM_STRIP_BUF_SIZE ((size_t) thd->variables.sortbuff_size)
/*
@brief
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index b857dc8d2ec..2df3af03af5 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -641,7 +641,7 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
SELECT_LEX_UNIT *unit= derived->get_unit();
DBUG_ENTER("mysql_derived_prepare");
bool res= FALSE;
- DBUG_PRINT("enter", ("unit 0x%lx", (ulong) unit));
+ DBUG_PRINT("enter", ("unit %p", unit));
if (!unit)
DBUG_RETURN(FALSE);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 4ae66dcd32f..e592a873ef0 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1472,8 +1472,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
bool res= 0;
table_map map= 0;
DBUG_ENTER("mysql_prepare_insert");
- DBUG_PRINT("enter", ("table_list: 0x%lx table: 0x%lx view: %d",
- (ulong)table_list, (ulong)table,
+ DBUG_PRINT("enter", ("table_list: %p table: %p view: %d",
+ table_list, table,
(int)insert_into_view));
/* INSERT should have a SELECT or VALUES clause */
DBUG_ASSERT (!select_insert || !values);
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 5b3d46fc747..9a7b8f2af21 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -696,7 +696,7 @@ void JOIN_CACHE::set_constants()
pack_length_with_blob_ptrs= pack_length + blobs*sizeof(uchar *);
min_buff_size= 0;
min_records= 1;
- buff_size= MY_MAX(join->thd->variables.join_buff_size,
+ buff_size= (size_t)MY_MAX(join->thd->variables.join_buff_size,
get_min_join_buffer_size());
size_of_rec_ofs= offset_size(buff_size);
size_of_rec_len= blobs ? size_of_rec_ofs : offset_size(len);
@@ -841,7 +841,7 @@ ulong JOIN_CACHE::get_max_join_buffer_size(bool optimize_buff_size)
len+= get_max_key_addon_space_per_record() + avg_aux_buffer_incr;
space_per_record= len;
- size_t limit_sz= join->thd->variables.join_buff_size;
+ size_t limit_sz= (size_t)join->thd->variables.join_buff_size;
if (join_tab->join_buffer_size_limit)
set_if_smaller(limit_sz, join_tab->join_buffer_size_limit);
if (!optimize_buff_size)
@@ -3829,7 +3829,7 @@ uint JOIN_TAB_SCAN_MRR::aux_buffer_incr(ulong recno)
set_if_bigger(rec_per_key, 1);
if (recno == 1)
incr= ref->key_length + tab->file->ref_length;
- incr+= tab->file->stats.mrr_length_per_rec * rec_per_key;
+ incr+= (uint)(tab->file->stats.mrr_length_per_rec * rec_per_key);
return incr;
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 3bd72314714..b8d51a5783f 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -391,7 +391,7 @@ void Lex_input_stream::body_utf8_append(const char *ptr,
if (m_cpp_utf8_processed_ptr >= ptr)
return;
- int bytes_to_copy= ptr - m_cpp_utf8_processed_ptr;
+ size_t bytes_to_copy= ptr - m_cpp_utf8_processed_ptr;
memcpy(m_body_utf8_ptr, m_cpp_utf8_processed_ptr, bytes_to_copy);
m_body_utf8_ptr += bytes_to_copy;
@@ -778,7 +778,7 @@ void LEX::start(THD *thd_arg)
void lex_end(LEX *lex)
{
DBUG_ENTER("lex_end");
- DBUG_PRINT("enter", ("lex: 0x%lx", (long) lex));
+ DBUG_PRINT("enter", ("lex: %p", lex));
lex_end_stage1(lex);
lex_end_stage2(lex);
@@ -2656,7 +2656,7 @@ bool st_select_lex::add_gorder_to_list(THD *thd, Item *item, bool asc)
bool st_select_lex::add_item_to_list(THD *thd, Item *item)
{
DBUG_ENTER("st_select_lex::add_item_to_list");
- DBUG_PRINT("info", ("Item: 0x%lx", (long) item));
+ DBUG_PRINT("info", ("Item: %p", item));
DBUG_RETURN(item_list.push_back(item, thd->mem_root));
}
@@ -4763,9 +4763,9 @@ bool LEX::set_arena_for_set_stmt(Query_arena *backup)
Query_arena_memroot(mem_root_for_set_stmt,
Query_arena::STMT_INITIALIZED)))
DBUG_RETURN(1);
- DBUG_PRINT("info", ("mem_root: 0x%lx arena: 0x%lx",
- (ulong) mem_root_for_set_stmt,
- (ulong) arena_for_set_stmt));
+ DBUG_PRINT("info", ("mem_root: %p arena: %p",
+ mem_root_for_set_stmt,
+ arena_for_set_stmt));
thd->set_n_backup_active_arena(arena_for_set_stmt, backup);
DBUG_RETURN(0);
}
@@ -4776,9 +4776,9 @@ void LEX::reset_arena_for_set_stmt(Query_arena *backup)
DBUG_ENTER("LEX::reset_arena_for_set_stmt");
DBUG_ASSERT(arena_for_set_stmt);
thd->restore_active_arena(arena_for_set_stmt, backup);
- DBUG_PRINT("info", ("mem_root: 0x%lx arena: 0x%lx",
- (ulong) arena_for_set_stmt->mem_root,
- (ulong) arena_for_set_stmt));
+ DBUG_PRINT("info", ("mem_root: %p arena: %p",
+ arena_for_set_stmt->mem_root,
+ arena_for_set_stmt));
DBUG_VOID_RETURN;
}
@@ -4788,9 +4788,9 @@ void LEX::free_arena_for_set_stmt()
DBUG_ENTER("LEX::free_arena_for_set_stmt");
if (!arena_for_set_stmt)
return;
- DBUG_PRINT("info", ("mem_root: 0x%lx arena: 0x%lx",
- (ulong) arena_for_set_stmt->mem_root,
- (ulong) arena_for_set_stmt));
+ DBUG_PRINT("info", ("mem_root: %p arena: %p",
+ arena_for_set_stmt->mem_root,
+ arena_for_set_stmt));
arena_for_set_stmt->free_items();
delete(arena_for_set_stmt);
free_root(mem_root_for_set_stmt, MYF(MY_KEEP_PREALLOC));
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index eeaf888cc09..f787d39b774 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -159,7 +159,7 @@ void stop_handle_manager()
if (manager_thread_in_use)
{
mysql_mutex_lock(&LOCK_manager);
- DBUG_PRINT("quit", ("initiate shutdown of handle manager thread: 0x%lx",
+ DBUG_PRINT("quit", ("initiate shutdown of handle manager thread: %lu",
(ulong)manager_thread));
mysql_cond_signal(&COND_manager);
mysql_mutex_unlock(&LOCK_manager);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 82794367b74..0c68615f911 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1482,10 +1482,10 @@ uint maria_multi_check(THD *thd, char *packet, uint packet_length)
{
char *packet_start= packet;
size_t subpacket_length= net_field_length((uchar **)&packet_start);
- uint length_length= packet_start - packet;
+ size_t length_length= packet_start - packet;
// length of command + 3 bytes where that length was stored
- DBUG_PRINT("info", ("sub-packet length: %ld + %d command: %x",
- (ulong)subpacket_length, length_length,
+ DBUG_PRINT("info", ("sub-packet length: %zu + %zu command: %x",
+ subpacket_length, length_length,
packet_start[3]));
if (subpacket_length == 0 ||
@@ -1939,7 +1939,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
(The packet is guaranteed to end with an end zero)
*/
arg_end= strend(packet);
- uint arg_length= arg_end - packet;
+ uint arg_length= (uint)(arg_end - packet);
/* Check given table name length. */
if (packet_length - arg_length > NAME_LEN + 1 || arg_length > SAFE_NAME_LEN)
@@ -2178,7 +2178,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,
@@ -2267,7 +2267,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char *packet_start= packet;
/* We have to store next length because it will be destroyed by '\0' */
size_t next_subpacket_length= net_field_length((uchar **)&packet_start);
- uint next_length_length= packet_start - packet;
+ size_t next_length_length= packet_start - packet;
unsigned char *readbuff= net->buff;
if (net_allocate_new_packet(net, thd, MYF(0)))
@@ -2282,7 +2282,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
{
current_com++;
size_t subpacket_length= next_subpacket_length + next_length_length;
- uint length_length= next_length_length;
+ size_t length_length= next_length_length;
if (subpacket_length < packet_length)
{
packet_start= packet + subpacket_length;
@@ -4555,6 +4555,7 @@ end_with_restore_list:
else
res= 0;
+ unit->set_limit(select_lex);
res= mysql_multi_update_prepare(thd);
#ifdef HAVE_REPLICATION
@@ -7690,7 +7691,7 @@ void create_select_for_variable(THD *thd, LEX_CSTRING *var_name)
if ((var= get_system_var(thd, OPT_SESSION, var_name, &null_clex_str)))
{
end= strxmov(buff, "@@session.", var_name->str, NullS);
- var->set_name(thd, buff, end-buff, system_charset_info);
+ var->set_name(thd, buff, (uint)(end-buff), system_charset_info);
add_item_to_list(thd, var);
}
DBUG_VOID_RETURN;
@@ -9083,7 +9084,6 @@ Item * all_any_subquery_creator(THD *thd, Item *left_expr,
bool multi_update_precheck(THD *thd, TABLE_LIST *tables)
{
- const char *msg= 0;
TABLE_LIST *table;
LEX *lex= thd->lex;
SELECT_LEX *select_lex= &lex->select_lex;
@@ -9139,15 +9139,6 @@ bool multi_update_precheck(THD *thd, TABLE_LIST *tables)
}
}
- if (select_lex->order_list.elements)
- msg= "ORDER BY";
- else if (select_lex->select_limit)
- msg= "LIMIT";
- if (msg)
- {
- my_error(ER_WRONG_USAGE, MYF(0), "UPDATE", msg);
- DBUG_RETURN(TRUE);
- }
DBUG_RETURN(FALSE);
}
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 9fc67272bfa..3fc49dc42ca 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -4884,7 +4884,7 @@ that are reorganised.
{
if (!alt_part_info->use_default_partitions)
{
- DBUG_PRINT("info", ("part_info: 0x%lx", (long) tab_part_info));
+ DBUG_PRINT("info", ("part_info: %p", tab_part_info));
tab_part_info->use_default_partitions= FALSE;
}
tab_part_info->use_default_num_partitions= FALSE;
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 00bacad8195..a4e6546e38a 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -775,7 +775,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_CSTRING *dl, int report)
if (global_system_variables.log_warnings > 2)
{
struct link_map *lm = (struct link_map*) plugin_dl.handle;
- sql_print_information("Loaded '%s' with offset 0x%lx", dl->str, lm->l_addr);
+ sql_print_information("Loaded '%s' with offset 0x%zx", dl->str, (size_t)lm->l_addr);
}
#endif
@@ -983,8 +983,8 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc)
*plugin= pi;
#endif
pi->ref_count++;
- DBUG_PRINT("lock",("thd: 0x%lx plugin: \"%s\" LOCK ref_count: %d",
- (long) current_thd, pi->name.str, pi->ref_count));
+ DBUG_PRINT("lock",("thd: %p plugin: \"%s\" LOCK ref_count: %d",
+ current_thd, pi->name.str, pi->ref_count));
if (lex)
insert_dynamic(&lex->plugins, (uchar*)&plugin);
@@ -1365,8 +1365,8 @@ static void intern_plugin_unlock(LEX *lex, plugin_ref plugin)
DBUG_ASSERT(pi->ref_count);
pi->ref_count--;
- DBUG_PRINT("lock",("thd: 0x%lx plugin: \"%s\" UNLOCK ref_count: %d",
- (long) current_thd, pi->name.str, pi->ref_count));
+ DBUG_PRINT("lock",("thd: %p plugin: \"%s\" UNLOCK ref_count: %d",
+ current_thd, pi->name.str, pi->ref_count));
if (pi->state == PLUGIN_IS_DELETED && !pi->ref_count)
reap_needed= true;
@@ -3280,8 +3280,8 @@ static void plugin_vars_free_values(sys_var *vars)
{
/* Free the string from global_system_variables. */
char **valptr= (char**) piv->real_value_ptr(NULL, OPT_GLOBAL);
- DBUG_PRINT("plugin", ("freeing value for: '%s' addr: 0x%lx",
- var->name.str, (long) valptr));
+ DBUG_PRINT("plugin", ("freeing value for: '%s' addr: %p",
+ var->name.str, valptr));
my_free(*valptr);
*valptr= NULL;
}
@@ -3344,14 +3344,14 @@ uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
{
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) {
case PLUGIN_VAR_BOOL:
- thd->sys_var_tmp.my_bool_value= option.def_value;
+ thd->sys_var_tmp.my_bool_value= (my_bool)option.def_value;
return (uchar*) &thd->sys_var_tmp.my_bool_value;
case PLUGIN_VAR_INT:
- thd->sys_var_tmp.int_value= option.def_value;
+ thd->sys_var_tmp.int_value= (int)option.def_value;
return (uchar*) &thd->sys_var_tmp.int_value;
case PLUGIN_VAR_LONG:
case PLUGIN_VAR_ENUM:
- thd->sys_var_tmp.long_value= option.def_value;
+ thd->sys_var_tmp.long_value= (long)option.def_value;
return (uchar*) &thd->sys_var_tmp.long_value;
case PLUGIN_VAR_LONGLONG:
case PLUGIN_VAR_SET:
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index b81d1f7542b..7fc6141bcea 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1400,6 +1400,7 @@ static int mysql_test_update(Prepared_statement *stmt,
int res;
THD *thd= stmt->thd;
uint table_count= 0;
+ TABLE_LIST *update_source_table;
SELECT_LEX *select= &stmt->lex->select_lex;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
uint want_privilege;
@@ -1413,9 +1414,11 @@ static int mysql_test_update(Prepared_statement *stmt,
if (mysql_handle_derived(thd->lex, DT_INIT))
goto error;
- if (table_list->is_multitable())
+ if (((update_source_table= unique_table(thd, table_list,
+ table_list->next_global, 0)) ||
+ table_list->is_multitable()))
{
- DBUG_ASSERT(table_list->view != 0);
+ DBUG_ASSERT(update_source_table || table_list->view != 0);
DBUG_PRINT("info", ("Switch to multi-update"));
/* pass counter value */
thd->lex->table_count= table_count;
@@ -3227,7 +3230,7 @@ void mysql_sql_stmt_execute(THD *thd)
DBUG_VOID_RETURN;
}
- DBUG_PRINT("info",("stmt: 0x%lx", (long) stmt));
+ DBUG_PRINT("info",("stmt: %p", stmt));
if (lex->prepared_stmt_params_fix_fields(thd))
DBUG_VOID_RETURN;
@@ -3754,8 +3757,8 @@ void Prepared_statement::setup_set_params()
Prepared_statement::~Prepared_statement()
{
DBUG_ENTER("Prepared_statement::~Prepared_statement");
- DBUG_PRINT("enter",("stmt: 0x%lx cursor: 0x%lx",
- (long) this, (long) cursor));
+ DBUG_PRINT("enter",("stmt: %p cursor: %p",
+ this, cursor));
delete cursor;
/*
We have to call free on the items even if cleanup is called as some items,
@@ -3782,7 +3785,7 @@ Query_arena::Type Prepared_statement::type() const
void Prepared_statement::cleanup_stmt()
{
DBUG_ENTER("Prepared_statement::cleanup_stmt");
- DBUG_PRINT("enter",("stmt: 0x%lx", (long) this));
+ DBUG_PRINT("enter",("stmt: %p", this));
lex->restore_set_statement_var();
cleanup_items(free_list);
thd->cleanup_after_query();
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index ba3d2e7da2f..394492f6a1d 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1990,7 +1990,8 @@ int JOIN::optimize_stage2()
FORCE INDEX FOR ORDER BY can be used to prevent join buffering when
sorting on the first table.
*/
- if (!stable || !stable->force_index_order)
+ if (!stable || (!stable->force_index_order &&
+ !map2table[stable->tablenr]->keep_current_rowid))
{
if (group_list)
simple_group= 0;
@@ -7873,7 +7874,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
*/
if (!is_hash_join_key_no(key))
{
- table_map quick_key_map= (table_map(1) << table->quick_key_parts[key]) - 1;
+ key_part_map quick_key_map= (key_part_map(1) << table->quick_key_parts[key]) - 1;
if (table->quick_rows[key] &&
!(quick_key_map & ~table->const_key_parts[key]))
{
@@ -10603,8 +10604,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
tmp_cond= new (thd->mem_root) Item_func_trig_cond(thd, tmp_cond,
&first_inner_tab->
not_null_compl);
- DBUG_PRINT("info", ("Item_func_trig_cond 0x%lx",
- (ulong) tmp_cond));
+ DBUG_PRINT("info", ("Item_func_trig_cond %p",
+ tmp_cond));
if (tmp_cond)
tmp_cond->quick_fix_field();
/* Add the predicate to other pushed down predicates */
@@ -10612,8 +10613,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
*sel_cond_ref= !(*sel_cond_ref) ?
tmp_cond :
new (thd->mem_root) Item_cond_and(thd, *sel_cond_ref, tmp_cond);
- DBUG_PRINT("info", ("Item_cond_and 0x%lx",
- (ulong)(*sel_cond_ref)));
+ DBUG_PRINT("info", ("Item_cond_and %p",
+ (*sel_cond_ref)));
if (!(*sel_cond_ref))
DBUG_RETURN(1);
(*sel_cond_ref)->quick_fix_field();
@@ -20340,9 +20341,9 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
Item *item= *group->item;
if (group->fast_field_copier_setup != group->field)
{
- DBUG_PRINT("info", ("new setup 0x%lx -> 0x%lx",
- (ulong)group->fast_field_copier_setup,
- (ulong)group->field));
+ DBUG_PRINT("info", ("new setup %p -> %p",
+ group->fast_field_copier_setup,
+ group->field));
group->fast_field_copier_setup= group->field;
group->fast_field_copier_func=
item->setup_fast_field_copier(group->field);
@@ -24976,8 +24977,8 @@ int JOIN::save_explain_data_intern(Explain_query *output,
JOIN *join= this; /* Legacy: this code used to be a non-member function */
int cur_error= 0;
DBUG_ENTER("JOIN::save_explain_data_intern");
- DBUG_PRINT("info", ("Select 0x%lx, type %s, message %s",
- (ulong)join->select_lex, join->select_lex->type,
+ DBUG_PRINT("info", ("Select %p, type %s, message %s",
+ join->select_lex, join->select_lex->type,
message ? message : "NULL"));
DBUG_ASSERT(have_query_plan == QEP_AVAILABLE);
/* fake_select_lex is created/printed by Explain_union */
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 9f91733ae9c..b6b8deb99f5 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -2013,7 +2013,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
class Virtual_tmp_table: public TABLE
{
/**
- Destruct collected fields. This method is called on errors only,
+ Destruct collected fields. This method can be called on errors,
when we could not make the virtual temporary table completely,
e.g. when some of the fields could not be created or added.
@@ -2024,7 +2024,10 @@ class Virtual_tmp_table: public TABLE
void destruct_fields()
{
for (uint i= 0; i < s->fields; i++)
+ {
+ field[i]->free();
delete field[i]; // to invoke the field destructor
+ }
s->fields= 0; // safety
}
@@ -2144,7 +2147,7 @@ public:
TABLE object ready for read and write in case of success
*/
-inline TABLE *
+inline Virtual_tmp_table *
create_virtual_tmp_table(THD *thd, List<Spvar_definition> &field_list)
{
Virtual_tmp_table *table;
diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc
index c070c8e5549..30b2e11139b 100644
--- a/sql/sql_servers.cc
+++ b/sql/sql_servers.cc
@@ -350,8 +350,8 @@ get_server_from_table_to_cache(TABLE *table)
DBUG_PRINT("info", ("server->socket %s", server->socket));
if (my_hash_insert(&servers_cache, (uchar*) server))
{
- DBUG_PRINT("info", ("had a problem inserting server %s at %lx",
- server->server_name, (long unsigned int) server));
+ DBUG_PRINT("info", ("had a problem inserting server %s at %p",
+ server->server_name, server));
// error handling needed here
DBUG_RETURN(TRUE);
}
@@ -431,13 +431,13 @@ insert_server_record_into_cache(FOREIGN_SERVER *server)
We succeded in insertion of the server to the table, now insert
the server to the cache
*/
- DBUG_PRINT("info", ("inserting server %s at %lx, length %d",
- server->server_name, (long unsigned int) server,
+ DBUG_PRINT("info", ("inserting server %s at %p, length %d",
+ server->server_name, server,
server->server_name_length));
if (my_hash_insert(&servers_cache, (uchar*) server))
{
- DBUG_PRINT("info", ("had a problem inserting server %s at %lx",
- server->server_name, (long unsigned int) server));
+ DBUG_PRINT("info", ("had a problem inserting server %s at %p",
+ server->server_name, server));
// error handling needed here
error= 1;
}
@@ -804,8 +804,8 @@ int update_server_record_in_cache(FOREIGN_SERVER *existing,
*/
if (my_hash_insert(&servers_cache, (uchar*)altered))
{
- DBUG_PRINT("info", ("had a problem inserting server %s at %lx",
- altered->server_name, (long unsigned int) altered));
+ DBUG_PRINT("info", ("had a problem inserting server %s at %p",
+ altered->server_name,altered));
error= ER_OUT_OF_RESOURCES;
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 68ded844938..de928fe9e85 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2527,7 +2527,7 @@ public:
size_t size __attribute__((unused)))
{ TRASH(ptr, size); }
- ulong thread_id;
+ my_thread_id thread_id;
uint32 os_thread_id;
ulonglong start_time;
uint command;
@@ -2701,7 +2701,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
while ((thd_info=thread_infos.get()))
{
protocol->prepare_for_resend();
- protocol->store((ulonglong) thd_info->thread_id);
+ protocol->store(thd_info->thread_id);
protocol->store(thd_info->user, system_charset_info);
protocol->store(thd_info->host, system_charset_info);
protocol->store(thd_info->db, system_charset_info);
@@ -6563,7 +6563,7 @@ static bool store_trigger(THD *thd, Trigger *trigger,
{
table->field[16]->set_notnull();
thd->variables.time_zone->gmt_sec_to_TIME(&timestamp,
- trigger->create_time/100);
+ (my_time_t)(trigger->create_time/100));
/* timestamp is with 6 digits */
timestamp.second_part= (trigger->create_time % 100) * 10000;
((Field_temporal_with_date*) table->field[16])->store_time_dec(&timestamp,
@@ -9590,7 +9590,7 @@ static bool show_create_trigger_impl(THD *thd, Trigger *trigger)
{
MYSQL_TIME timestamp;
thd->variables.time_zone->gmt_sec_to_TIME(&timestamp,
- trigger->create_time/100);
+ (my_time_t)(trigger->create_time/100));
timestamp.second_part= (trigger->create_time % 100) * 10000;
p->store(&timestamp, 2);
}
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 3e023767807..0048e525cad 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -3757,7 +3757,10 @@ double get_column_avg_frequency(Field * field)
using the statistical data from the table column_stats.
@retval
- The required estimate of the rows in the column range
+ - The required estimate of the rows in the column range
+ - If there is some kind of error, this function should return DBL_MAX (and
+ not HA_POS_ERROR as that is an integer constant).
+
*/
double get_column_range_cardinality(Field *field,
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 2c35abe3ff0..70ddf7b1241 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -31,9 +31,9 @@
** String functions
*****************************************************************************/
-bool String::real_alloc(uint32 length)
+bool String::real_alloc(size_t length)
{
- uint32 arg_length= ALIGN_SIZE(length + 1);
+ size_t arg_length= ALIGN_SIZE(length + 1);
DBUG_ASSERT(arg_length > length);
if (arg_length <= length)
return TRUE; /* Overflow */
@@ -45,7 +45,8 @@ bool String::real_alloc(uint32 length)
(thread_specific ?
MY_THREAD_SPECIFIC : 0)))))
return TRUE;
- Alloced_length=arg_length;
+ DBUG_ASSERT(length < UINT_MAX32);
+ Alloced_length=(uint32) arg_length;
alloced=1;
}
Ptr[0]=0;
@@ -80,7 +81,7 @@ bool String::real_alloc(uint32 length)
@retval true An error occurred when attempting to allocate memory.
*/
-bool String::realloc_raw(uint32 alloc_length)
+bool String::realloc_raw(size_t alloc_length)
{
if (Alloced_length <= alloc_length)
{
@@ -112,7 +113,8 @@ bool String::realloc_raw(uint32 alloc_length)
else
return TRUE; // Signal error
Ptr= new_ptr;
- Alloced_length= len;
+ DBUG_ASSERT(len < UINT_MAX32);
+ Alloced_length= (uint32)len;
}
return FALSE;
}
@@ -194,7 +196,7 @@ bool String::set_real(double num,uint decimals, CHARSET_INFO *cs)
if (decimals >= FLOATING_POINT_DECIMALS)
{
len= my_gcvt(num, MY_GCVT_ARG_DOUBLE, sizeof(buff) - 1, buff, NULL);
- return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
+ return copy(buff, (uint)len, &my_charset_latin1, cs, &dummy_errors);
}
len= my_fcvt(num, decimals, buff, NULL);
return copy(buff, (uint32) len, &my_charset_latin1, cs,
@@ -234,10 +236,11 @@ bool String::copy(const String &str)
return FALSE;
}
-bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
+bool String::copy(const char *str,size_t arg_length, CHARSET_INFO *cs)
{
if (alloc(arg_length))
return TRUE;
+ DBUG_ASSERT(arg_length < UINT_MAX32);
if ((str_length=arg_length))
memcpy(Ptr,str,arg_length);
Ptr[arg_length]=0;
@@ -494,8 +497,10 @@ bool String::append(const String &s)
Append an ASCII string to the a string of the current character set
*/
-bool String::append(const char *s,uint32 arg_length)
+bool String::append(const char *s,size_t size)
{
+ DBUG_ASSERT(size <= UINT_MAX32);
+ uint32 arg_length= (uint32) size;
if (!arg_length)
return FALSE;
@@ -539,7 +544,7 @@ bool String::append_longlong(longlong val)
if (realloc(str_length+MAX_BIGINT_WIDTH+2))
return TRUE;
char *end= (char*) longlong10_to_str(val, (char*) Ptr + str_length, -10);
- str_length= end - Ptr;
+ str_length= (uint32)(end - Ptr);
return FALSE;
}
@@ -549,7 +554,7 @@ bool String::append_ulonglong(ulonglong val)
if (realloc(str_length+MAX_BIGINT_WIDTH+2))
return TRUE;
char *end= (char*) longlong10_to_str(val, (char*) Ptr + str_length, 10);
- str_length= end - Ptr;
+ str_length= (uint32) (end - Ptr);
return FALSE;
}
@@ -558,7 +563,7 @@ bool String::append_ulonglong(ulonglong val)
with character set recoding
*/
-bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs)
+bool String::append(const char *s, uint arg_length, CHARSET_INFO *cs)
{
uint32 offset;
@@ -645,7 +650,7 @@ bool String::append_with_prefill(const char *s,uint32 arg_length,
uint32 String::numchars() const
{
- return str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length);
+ return (uint32) str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length);
}
int String::charpos(longlong i,uint32 offset)
@@ -774,7 +779,7 @@ void String::qs_append(const char *str, uint32 len)
void String::qs_append(double d)
{
char *buff = Ptr + str_length;
- str_length+= my_gcvt(d, MY_GCVT_ARG_DOUBLE, FLOATING_POINT_BUFFER - 1, buff,
+ str_length+= (uint32) my_gcvt(d, MY_GCVT_ARG_DOUBLE, FLOATING_POINT_BUFFER - 1, buff,
NULL);
}
@@ -1078,10 +1083,10 @@ String_copier::well_formed_copy(CHARSET_INFO *to_cs,
my_charset_same(from_cs, to_cs))
{
m_cannot_convert_error_pos= NULL;
- return to_cs->cset->copy_fix(to_cs, to, to_length, from, from_length,
+ return (uint) to_cs->cset->copy_fix(to_cs, to, to_length, from, from_length,
nchars, this);
}
- return my_convert_fix(to_cs, to, to_length, from_cs, from, from_length,
+ return (uint) my_convert_fix(to_cs, to, to_length, from_cs, from, from_length,
nchars, this, this);
}
@@ -1216,5 +1221,5 @@ uint convert_to_printable(char *to, size_t to_len,
memcpy(dots, STRING_WITH_LEN("...\0"));
else
*t= '\0';
- return t - to;
+ return (uint) (t - to);
}
diff --git a/sql/sql_string.h b/sql/sql_string.h
index af3765443c5..c88c58b1b40 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -357,22 +357,22 @@ public:
Ptr=0;
str_length=0; /* Safety */
}
- inline bool alloc(uint32 arg_length)
+ inline bool alloc(size_t arg_length)
{
if (arg_length < Alloced_length)
return 0;
return real_alloc(arg_length);
}
- bool real_alloc(uint32 arg_length); // Empties old string
- bool realloc_raw(uint32 arg_length);
- bool realloc(uint32 arg_length)
+ bool real_alloc(size_t arg_length); // Empties old string
+ bool realloc_raw(size_t arg_length);
+ bool realloc(size_t arg_length)
{
if (realloc_raw(arg_length))
return TRUE;
Ptr[arg_length]=0; // This make other funcs shorter
return FALSE;
}
- bool realloc_with_extra(uint32 arg_length)
+ bool realloc_with_extra(size_t arg_length)
{
if (extra_alloc < 4096)
extra_alloc= extra_alloc*2+128;
@@ -381,7 +381,7 @@ public:
Ptr[arg_length]=0; // This make other funcs shorter
return FALSE;
}
- bool realloc_with_extra_if_needed(uint32 arg_length)
+ bool realloc_with_extra_if_needed(size_t arg_length)
{
if (arg_length < Alloced_length)
{
@@ -391,7 +391,7 @@ public:
return realloc_with_extra(arg_length);
}
// Shrink the buffer, but only if it is allocated on the heap.
- inline void shrink(uint32 arg_length)
+ inline void shrink(size_t arg_length)
{
if (!is_alloced())
return;
@@ -408,7 +408,7 @@ public:
else
{
Ptr=new_ptr;
- Alloced_length=arg_length;
+ Alloced_length=(uint32)arg_length;
}
}
}
@@ -431,7 +431,7 @@ public:
bool copy(); // Alloc string if not alloced
bool copy(const String &s); // Allocate new string
- bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string
+ bool copy(const char *s,size_t arg_length, CHARSET_INFO *cs); // Allocate new string
static bool needs_conversion(uint32 arg_length,
CHARSET_INFO *cs_from, CHARSET_INFO *cs_to,
uint32 *offset);
@@ -484,8 +484,8 @@ public:
DBUG_ASSERT(ls.length < UINT_MAX32);
return append(ls.str, (uint32) ls.length);
}
- bool append(const char *s, uint32 arg_length);
- bool append(const char *s, uint32 arg_length, CHARSET_INFO *cs);
+ bool append(const char *s, size_t size);
+ bool append(const char *s, uint arg_length, CHARSET_INFO *cs);
bool append_ulonglong(ulonglong val);
bool append_longlong(longlong val);
bool append(IO_CACHE* file, uint32 arg_length);
@@ -568,10 +568,11 @@ public:
float8store(Ptr + str_length, *d);
str_length += 8;
}
- void q_append(const char *data, uint32 data_len)
+ void q_append(const char *data, size_t data_len)
{
memcpy(Ptr + str_length, data, data_len);
- str_length += data_len;
+ DBUG_ASSERT(str_length <= UINT_MAX32 - data_len);
+ str_length += (uint)data_len;
}
void q_append(const LEX_CSTRING *ls)
{
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 9c746e470f7..724389592e3 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2275,9 +2275,9 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
size_t db_length= table->db_length;
handlerton *table_type= 0;
- DBUG_PRINT("table", ("table_l: '%s'.'%s' table: 0x%lx s: 0x%lx",
- table->db, table->table_name, (long) table->table,
- table->table ? (long) table->table->s : (long) -1));
+ DBUG_PRINT("table", ("table_l: '%s'.'%s' table: %p s: %p",
+ table->db, table->table_name, table->table,
+ table->table ? table->table->s : NULL));
/*
If we are in locked tables mode and are dropping a temporary table,
@@ -2526,8 +2526,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
mysql_audit_drop_table(thd, table);
}
- DBUG_PRINT("table", ("table: 0x%lx s: 0x%lx", (long) table->table,
- table->table ? (long) table->table->s : (long) -1));
+ DBUG_PRINT("table", ("table: %p s: %p", table->table,
+ table->table ? table->table->s : NULL));
}
DEBUG_SYNC(thd, "rm_table_no_locks_before_binlog");
thd->thread_specific_used|= (trans_tmp_table_deleted ||
@@ -4229,7 +4229,7 @@ bool Column_definition::prepare_blob_field(THD *thd)
real_field_type() == FIELD_TYPE_MEDIUM_BLOB)
{
/* The user has given a length to the blob column */
- set_handler(Type_handler::blob_type_handler(length));
+ set_handler(Type_handler::blob_type_handler((uint) length));
pack_length= type_handler()->calc_pack_length(0);
}
length= 0;
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index b130cd9ebe2..ab12278ef8c 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -433,7 +433,7 @@ static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data,
if (table && table->s->tmp_table == NO_TMP_TABLE)
{
TABLE_LOCK_INFO table_lock_info;
- table_lock_info.thread_id= table->in_use->thread_id;
+ table_lock_info.thread_id= (ulong)table->in_use->thread_id;
memcpy(table_lock_info.table_name, table->s->table_cache_key.str,
table->s->table_cache_key.length);
table_lock_info.table_name[strlen(table_lock_info.table_name)]='.';
diff --git a/sql/sql_time.h b/sql/sql_time.h
index 91a026512c1..1832e4501ed 100644
--- a/sql/sql_time.h
+++ b/sql/sql_time.h
@@ -193,7 +193,7 @@ inline bool parse_date_time_format(timestamp_type format_type,
{
return parse_date_time_format(format_type,
date_time_format->format.str,
- date_time_format->format.length,
+ (uint) date_time_format->format.length,
date_time_format);
}
diff --git a/sql/sql_type.h b/sql/sql_type.h
index 525a05b71e6..0354adfde1e 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -704,7 +704,12 @@ public:
}
virtual bool is_scalar_type() const { return true; }
virtual bool can_return_int() const { return true; }
+ virtual bool can_return_decimal() const { return true; }
virtual bool can_return_real() const { return true; }
+ virtual bool can_return_str() const { return true; }
+ virtual bool can_return_text() const { return true; }
+ virtual bool can_return_date() const { return true; }
+ virtual bool can_return_time() const { return true; }
virtual bool is_general_purpose_string_type() const { return false; }
virtual uint Item_time_precision(Item *item) const;
virtual uint Item_datetime_precision(Item *item) const;
@@ -1001,7 +1006,12 @@ public:
const Name name() const { return m_name_row; }
bool is_scalar_type() const { return false; }
bool can_return_int() const { return false; }
+ bool can_return_decimal() const { return false; }
bool can_return_real() const { return false; }
+ bool can_return_str() const { return false; }
+ bool can_return_text() const { return false; }
+ bool can_return_date() const { return false; }
+ bool can_return_time() const { return false; }
enum_field_types field_type() const
{
DBUG_ASSERT(0);
@@ -2689,7 +2699,11 @@ public:
TABLE *table) const;
bool can_return_int() const { return false; }
+ bool can_return_decimal() const { return false; }
bool can_return_real() const { return false; }
+ bool can_return_text() const { return false; }
+ bool can_return_date() const { return false; }
+ bool can_return_time() const { return false; }
bool is_traditional_type() const
{
return false;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 3f39765b531..d188be8bc97 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -278,6 +278,7 @@ int mysql_update(THD *thd,
killed_state killed_status= NOT_KILLED;
Update_plan query_plan(thd->mem_root);
Explain_update *explain;
+ TABLE_LIST *update_source_table;
query_plan.index= MAX_KEY;
query_plan.using_filesort= FALSE;
DBUG_ENTER("mysql_update");
@@ -290,9 +291,11 @@ int mysql_update(THD *thd,
if (mysql_handle_derived(thd->lex, DT_INIT))
DBUG_RETURN(1);
- if (table_list->is_multitable())
+ if (((update_source_table=unique_table(thd, table_list,
+ table_list->next_global, 0)) ||
+ table_list->is_multitable()))
{
- DBUG_ASSERT(table_list->view != 0);
+ DBUG_ASSERT(update_source_table || table_list->view != 0);
DBUG_PRINT("info", ("Switch to multi-update"));
/* pass counter value */
thd->lex->table_count= table_count;
@@ -1540,16 +1543,6 @@ int mysql_multi_update_prepare(THD *thd)
}
DBUG_PRINT("info", ("table: %s want_privilege: %u", tl->alias,
(uint) table->grant.want_privilege));
- if (tl->lock_type != TL_READ &&
- tl->lock_type != TL_READ_NO_INSERT)
- {
- TABLE_LIST *duplicate;
- if ((duplicate= unique_table(thd, tl, table_list, 0)))
- {
- update_non_unique_table_error(table_list, "UPDATE", duplicate);
- DBUG_RETURN(TRUE);
- }
- }
}
/*
Set exclude_from_table_unique_test value back to FALSE. It is needed for
@@ -1595,10 +1588,9 @@ bool mysql_multi_update(THD *thd,
List<Item> total_list;
res= mysql_select(thd,
- table_list, select_lex->with_wild,
- total_list,
- conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL,
- (ORDER *)NULL,
+ table_list, select_lex->with_wild, total_list, conds,
+ select_lex->order_list.elements, select_lex->order_list.first,
+ (ORDER *)NULL, (Item *) NULL, (ORDER *)NULL,
options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK |
OPTION_SETUP_TABLES_DONE,
*result, unit, select_lex);
@@ -1857,6 +1849,8 @@ static bool safe_update_on_fly(THD *thd, JOIN_TAB *join_tab,
TABLE *table= join_tab->table;
if (unique_table(thd, table_ref, all_tables, 0))
return 0;
+ if (join_tab->join->order) // FIXME this is probably too strong
+ return 0;
switch (join_tab->type) {
case JT_SYSTEM:
case JT_CONST:
@@ -1934,6 +1928,7 @@ multi_update::initialize_tables(JOIN *join)
}
}
table->prepare_for_position();
+ join->map2table[table->tablenr]->keep_current_rowid= true;
/*
enable uncacheable flag if we update a view with check option
@@ -2001,6 +1996,7 @@ loop_end:
that we need a position to be read first.
*/
tbl->prepare_for_position();
+ join->map2table[tbl->tablenr]->keep_current_rowid= true;
Field_string *field= new Field_string(tbl->file->ref_length, 0,
&field_name,
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 26941e9d6e7..fd6ecbbdec9 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -1156,7 +1156,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
bool result, view_is_mergeable;
TABLE_LIST *UNINIT_VAR(view_main_select_tables);
DBUG_ENTER("mysql_make_view");
- DBUG_PRINT("info", ("table: 0x%lx (%s)", (ulong) table, table->table_name));
+ DBUG_PRINT("info", ("table: %p (%s)", table, table->table_name));
if (table->required_type == TABLE_TYPE_NORMAL)
{
diff --git a/sql/sql_window.cc b/sql/sql_window.cc
index 18bab30d2fd..d22fff9d486 100644
--- a/sql/sql_window.cc
+++ b/sql/sql_window.cc
@@ -1827,7 +1827,7 @@ public:
private:
void move_cursor_if_possible()
{
- int rows_difference= n_rows - n_rows_behind;
+ longlong rows_difference= n_rows - n_rows_behind;
if (rows_difference > 0) /* We still have to wait. */
return;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a801251f5df..277d67ca014 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -16483,7 +16483,7 @@ view_select:
opt_with_clause query_expression_body_view view_check_option
{
LEX *lex= Lex;
- uint len= YYLIP->get_cpp_ptr() - lex->create_view->select.str;
+ size_t len= YYLIP->get_cpp_ptr() - lex->create_view->select.str;
uint not_used;
void *create_view_select= thd->memdup(lex->create_view->select.str, len);
lex->create_view->select.length= len;
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index c3a84fcc482..ad8b6697ce7 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -16686,7 +16686,7 @@ view_select:
opt_with_clause query_expression_body_view view_check_option
{
LEX *lex= Lex;
- uint len= YYLIP->get_cpp_ptr() - lex->create_view->select.str;
+ size_t len= YYLIP->get_cpp_ptr() - lex->create_view->select.str;
uint not_used;
void *create_view_select= thd->memdup(lex->create_view->select.str, len);
lex->create_view->select.length= len;
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index 43a2698c4be..f4c8fcd517f 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -158,7 +158,7 @@ uint find_type2(const TYPELIB *typelib, const char *x, uint length,
int pos;
const char *j;
DBUG_ENTER("find_type2");
- DBUG_PRINT("enter",("x: '%.*s' lib: 0x%lx", length, x, (long) typelib));
+ DBUG_PRINT("enter",("x: '%.*s' lib: %p", length, x, typelib));
if (!typelib->count)
{
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 6ae9a7e8f2e..d16ae7f85a3 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -2783,7 +2783,7 @@ static Sys_var_enum Sys_thread_handling(
#ifdef HAVE_QUERY_CACHE
static bool fix_query_cache_size(sys_var *self, THD *thd, enum_var_type type)
{
- ulong new_cache_size= query_cache.resize(query_cache_size);
+ ulong new_cache_size= query_cache.resize((ulong)query_cache_size);
/*
Note: query_cache_size is a global variable reflecting the
requested cache size. See also query_cache_size_arg
@@ -4835,7 +4835,7 @@ static Sys_var_multi_source_ulonglong Sys_slave_skip_counter(
static bool update_max_relay_log_size(sys_var *self, THD *thd, Master_info *mi)
{
mi->rli.max_relay_log_size= thd->variables.max_relay_log_size;
- mi->rli.relay_log.set_max_size(mi->rli.max_relay_log_size);
+ mi->rli.relay_log.set_max_size((ulong)mi->rli.max_relay_log_size);
return false;
}
@@ -5487,7 +5487,7 @@ static Sys_var_ulong Sys_rowid_merge_buff_size(
"rowid_merge_buff_size",
"The size of the buffers used [NOT] IN evaluation via partial matching",
SESSION_VAR(rowid_merge_buff_size), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(0, ((ulonglong)~(intptr)0)/2), DEFAULT(8*1024*1024),
+ VALID_RANGE(0, LONG_MAX), DEFAULT(8*1024*1024),
BLOCK_SIZE(1));
static Sys_var_mybool Sys_userstat(
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic
index f3ce4467a5f..da6d902a167 100644
--- a/sql/sys_vars.ic
+++ b/sql/sys_vars.ic
@@ -234,25 +234,25 @@ typedef Sys_var_integer<long, GET_LONG, SHOW_SLONG> Sys_var_long;
template<> uchar *Sys_var_int::default_value_ptr(THD *thd)
{
- thd->sys_var_tmp.int_value= option.def_value;
+ thd->sys_var_tmp.int_value= (int)option.def_value;
return (uchar*) &thd->sys_var_tmp.int_value;
}
template<> uchar *Sys_var_uint::default_value_ptr(THD *thd)
{
- thd->sys_var_tmp.uint_value= option.def_value;
+ thd->sys_var_tmp.uint_value= (uint)option.def_value;
return (uchar*) &thd->sys_var_tmp.uint_value;
}
template<> uchar *Sys_var_long::default_value_ptr(THD *thd)
{
- thd->sys_var_tmp.long_value= option.def_value;
+ thd->sys_var_tmp.long_value= (long)option.def_value;
return (uchar*) &thd->sys_var_tmp.long_value;
}
template<> uchar *Sys_var_ulong::default_value_ptr(THD *thd)
{
- thd->sys_var_tmp.ulong_value= option.def_value;
+ thd->sys_var_tmp.ulong_value= (ulong)option.def_value;
return (uchar*) &thd->sys_var_tmp.ulong_value;
}
@@ -369,7 +369,7 @@ public:
uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ return valptr(thd, global_var(ulong)); }
uchar *default_value_ptr(THD *thd)
- { return valptr(thd, option.def_value); }
+ { return valptr(thd, (ulong)option.def_value); }
};
/**
@@ -416,7 +416,7 @@ public:
{ var->save_result.ulonglong_value= option.def_value; }
uchar *default_value_ptr(THD *thd)
{
- thd->sys_var_tmp.my_bool_value= option.def_value;
+ thd->sys_var_tmp.my_bool_value=(my_bool) option.def_value;
return (uchar*) &thd->sys_var_tmp.my_bool_value;
}
};
diff --git a/sql/table.cc b/sql/table.cc
index 7dd93d5107d..70adb869e0a 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -338,7 +338,7 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name,
*/
do
{
- share->table_map_id= my_atomic_add64_explicit(&last_table_id, 1,
+ share->table_map_id=(ulong) my_atomic_add64_explicit(&last_table_id, 1,
MY_MEMORY_ORDER_RELAXED);
} while (unlikely(share->table_map_id == ~0UL));
}
@@ -3013,8 +3013,8 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
Field **field_ptr;
uint8 save_context_analysis_only= thd->lex->context_analysis_only;
DBUG_ENTER("open_table_from_share");
- DBUG_PRINT("enter",("name: '%s.%s' form: 0x%lx", share->db.str,
- share->table_name.str, (long) outparam));
+ DBUG_PRINT("enter",("name: '%s.%s' form: %p", share->db.str,
+ share->table_name.str, outparam));
thd->lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_VIEW; // not a view
@@ -3425,7 +3425,7 @@ int closefrm(register TABLE *table)
{
int error=0;
DBUG_ENTER("closefrm");
- DBUG_PRINT("enter", ("table: 0x%lx", (long) table));
+ DBUG_PRINT("enter", ("table: %p", table));
if (table->db_stat)
error=table->file->ha_close();
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index 0cbc06ff81e..6067ecb059d 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -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;
@@ -913,8 +913,8 @@ retry:
}
end:
- DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u",
- (ulong) share, share->tdc->ref_count));
+ DBUG_PRINT("exit", ("share: %p ref_count: %u",
+ share, share->tdc->ref_count));
if (flags & GTS_NOLOCK)
{
tdc_release_share(share);
@@ -945,8 +945,8 @@ void tdc_release_share(TABLE_SHARE *share)
mysql_mutex_lock(&share->tdc->LOCK_table_share);
DBUG_PRINT("enter",
- ("share: 0x%lx table: %s.%s ref_count: %u version: %lu",
- (ulong) share, share->db.str, share->table_name.str,
+ ("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 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= 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;
}
diff --git a/sql/table_cache.h b/sql/table_cache.h
index cac69296cc2..2e5bb3428dc 100644
--- a/sql/table_cache.h
+++ b/sql/table_cache.h
@@ -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);
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index b191693073c..2c3cd0fe24e 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -1133,8 +1133,8 @@ TABLE *THD::open_temporary_table(TMP_TABLE_SHARE *share,
thread_safe_increment32(&slave_open_temp_tables);
}
- DBUG_PRINT("tmptable", ("Opened table: '%s'.'%s' 0x%lx", table->s->db.str,
- table->s->table_name.str, (long) table));
+ DBUG_PRINT("tmptable", ("Opened table: '%s'.'%s'%p", table->s->db.str,
+ table->s->table_name.str, table));
DBUG_RETURN(table);
}
@@ -1227,9 +1227,9 @@ void THD::close_temporary_table(TABLE *table)
{
DBUG_ENTER("THD::close_temporary_table");
- DBUG_PRINT("tmptable", ("closing table: '%s'.'%s' 0x%lx alias: '%s'",
+ DBUG_PRINT("tmptable", ("closing table: '%s'.'%s'%p alias: '%s'",
table->s->db.str, table->s->table_name.str,
- (long) table, table->alias.c_ptr()));
+ table, table->alias.c_ptr()));
closefrm(table);
my_free(table);
diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc
index 7365e99dca6..3fdaff0504f 100644
--- a/sql/threadpool_generic.cc
+++ b/sql/threadpool_generic.cc
@@ -55,6 +55,9 @@ typedef OVERLAPPED_ENTRY native_event;
#error threadpool is not available on this platform
#endif
+#ifdef _MSC_VER
+#pragma warning (disable : 4312)
+#endif
static void io_poll_close(int fd)
{
@@ -447,10 +450,11 @@ static void* native_event_get_userdata(native_event *event)
#elif defined(HAVE_IOCP)
+
static int io_poll_create()
{
HANDLE h= CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0);
- return (int)h;
+ return PtrToInt(h);
}
@@ -476,7 +480,7 @@ int io_poll_start_read(int pollfd, int fd, void *, void *opt)
static int io_poll_associate_fd(int pollfd, int fd, void *data, void *opt)
{
- HANDLE h= CreateIoCompletionPort((HANDLE)fd, (HANDLE)pollfd, (ULONG_PTR)data, 0);
+ HANDLE h= CreateIoCompletionPort(IntToPtr(fd), IntToPtr(pollfd), (ULONG_PTR)data, 0);
if (!h)
return -1;
return io_poll_start_read(pollfd,fd, 0, opt);
@@ -504,7 +508,6 @@ static void* native_event_get_userdata(native_event *event)
{
return (void *)event->lpCompletionKey;
}
-
#endif
@@ -1483,7 +1486,7 @@ static int change_group(TP_connection_generic *c,
thread_group_t *new_group)
{
int ret= 0;
- int fd= mysql_socket_getfd(c->thd->net.vio->mysql_socket);
+ int fd= (int)mysql_socket_getfd(c->thd->net.vio->mysql_socket);
DBUG_ASSERT(c->thread_group == old_group);
@@ -1511,7 +1514,7 @@ static int change_group(TP_connection_generic *c,
int TP_connection_generic::start_io()
{
- int fd= mysql_socket_getfd(thd->net.vio->mysql_socket);
+ int fd= (int)mysql_socket_getfd(thd->net.vio->mysql_socket);
#ifndef HAVE_IOCP
/*
diff --git a/sql/udf_example.c b/sql/udf_example.c
index ce39b3461b3..cc9a703373c 100644
--- a/sql/udf_example.c
+++ b/sql/udf_example.c
@@ -1095,7 +1095,7 @@ my_bool is_const_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
strmov(message, "IS_CONST accepts only one argument");
return 1;
}
- initid->ptr= (char*)((args->args[0] != NULL) ? 1UL : 0);
+ initid->ptr= (char*)((args->args[0] != NULL) ? (size_t)1 : (size_t)0);
return 0;
}
diff --git a/sql/uniques.cc b/sql/uniques.cc
index e7dc40a5a5f..894e959cace 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -79,7 +79,7 @@ int unique_intersect_write_to_ptrs(uchar* key, element_count count, Unique *uniq
Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
- uint size_arg, ulonglong max_in_memory_size_arg,
+ uint size_arg, size_t max_in_memory_size_arg,
uint min_dupl_count_arg)
:max_in_memory_size(max_in_memory_size_arg),
size(size_arg),
@@ -91,7 +91,7 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
if (min_dupl_count_arg)
full_size+= sizeof(element_count);
with_counters= MY_TEST(min_dupl_count_arg);
- init_tree(&tree, (ulong) (max_in_memory_size / 16), 0, size, comp_func,
+ init_tree(&tree, (max_in_memory_size / 16), 0, size, comp_func,
NULL, comp_func_fixed_arg, MYF(MY_THREAD_SPECIFIC));
/* If the following fail's the next add will also fail */
my_init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16,
@@ -306,7 +306,7 @@ static double get_merge_many_buffs_cost(uint *buffer,
*/
double Unique::get_use_cost(uint *buffer, size_t nkeys, uint key_size,
- ulonglong max_in_memory_size,
+ size_t max_in_memory_size,
uint compare_factor,
bool intersect_fl, bool *in_memory)
{
diff --git a/sql/uniques.h b/sql/uniques.h
index 0210e879788..efc79953bb6 100644
--- a/sql/uniques.h
+++ b/sql/uniques.h
@@ -30,7 +30,7 @@ class Unique :public Sql_alloc
{
DYNAMIC_ARRAY file_ptrs;
ulong max_elements;
- ulonglong max_in_memory_size;
+ size_t max_in_memory_size;
IO_CACHE file;
TREE tree;
ulong filtered_out_elems;
@@ -46,7 +46,7 @@ public:
ulong elements;
SORT_INFO sort;
Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
- uint size_arg, ulonglong max_in_memory_size_arg,
+ uint size_arg, size_t max_in_memory_size_arg,
uint min_dupl_count_arg= 0);
~Unique();
ulong elements_in_tree() { return tree.elements_in_tree; }
@@ -72,12 +72,12 @@ public:
}
static double get_use_cost(uint *buffer, size_t nkeys, uint key_size,
- ulonglong max_in_memory_size, uint compare_factor,
+ size_t max_in_memory_size, uint compare_factor,
bool intersect_fl, bool *in_memory);
inline static int get_cost_calc_buff_size(size_t nkeys, uint key_size,
- ulonglong max_in_memory_size)
+ size_t max_in_memory_size)
{
- register ulonglong max_elems_in_tree=
+ register size_t max_elems_in_tree=
max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size);
return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree));
}
@@ -86,7 +86,7 @@ public:
bool walk(TABLE *table, tree_walk_action action, void *walk_action_arg);
uint get_size() const { return size; }
- ulonglong get_max_in_memory_size() const { return max_in_memory_size; }
+ size_t get_max_in_memory_size() const { return max_in_memory_size; }
friend int unique_write_to_file(uchar* key, element_count count, Unique *unique);
friend int unique_write_to_ptrs(uchar* key, element_count count, Unique *unique);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index cfcd0851f81..49724a3f47e 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -452,9 +452,9 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
int2store(pos+6, key->block_size);
pos+=8;
key_parts+=key->user_defined_key_parts;
- DBUG_PRINT("loop", ("flags: %lu key_parts: %d key_part: 0x%lx",
+ DBUG_PRINT("loop", ("flags: %lu key_parts: %d key_part: %p",
key->flags, key->user_defined_key_parts,
- (long) key->key_part));
+ key->key_part));
for (key_part=key->key_part,key_part_end=key_part+key->user_defined_key_parts ;
key_part != key_part_end ;
key_part++)
@@ -620,7 +620,7 @@ static bool pack_header(THD *thd, uchar *forminfo,
field->field_name.str))
DBUG_RETURN(1);
- totlength+= field->length;
+ totlength+= (size_t)field->length;
com_length+= field->comment.length;
/*
We mark first TIMESTAMP field with NOW() in DEFAULT or ON UPDATE
@@ -950,7 +950,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options,
/* regfield don't have to be deleted as it's allocated on THD::mem_root */
Field *regfield= make_field(&share, thd->mem_root,
buff+field->offset + data_offset,
- field->length,
+ (uint32)field->length,
null_pos + null_count / 8,
null_count & 7,
field->pack_flag,