mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge 5.2->5.3
- Re-commit Monty's merge, partially fixed by Igor and SergeyP, but still broken
This commit is contained in:
@ -803,6 +803,10 @@ THD::THD()
|
||||
thr_lock_owner_init(&main_lock_id, &lock_info);
|
||||
|
||||
m_internal_handler= NULL;
|
||||
arena_for_cached_items= 0;
|
||||
current_user_used= FALSE;
|
||||
memset(&invoker_user, 0, sizeof(invoker_user));
|
||||
memset(&invoker_host, 0, sizeof(invoker_host));
|
||||
}
|
||||
|
||||
|
||||
@ -1215,13 +1219,13 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
|
||||
while (to != end)
|
||||
*(to++)+= *(from++) - *(dec++);
|
||||
|
||||
to_var->bytes_received= (from_var->bytes_received -
|
||||
dec_var->bytes_received);
|
||||
to_var->bytes_sent+= from_var->bytes_sent - dec_var->bytes_sent;
|
||||
to_var->binlog_bytes_written= (from_var->binlog_bytes_written -
|
||||
dec_var->binlog_bytes_written);
|
||||
to_var->cpu_time+= from_var->cpu_time - dec_var->cpu_time;
|
||||
to_var->busy_time+= from_var->busy_time - dec_var->busy_time;
|
||||
to_var->bytes_received+= from_var->bytes_received -
|
||||
dec_var->bytes_received;
|
||||
to_var->bytes_sent+= from_var->bytes_sent - dec_var->bytes_sent;
|
||||
to_var->binlog_bytes_written+= from_var->binlog_bytes_written -
|
||||
dec_var->binlog_bytes_written;
|
||||
to_var->cpu_time+= from_var->cpu_time - dec_var->cpu_time;
|
||||
to_var->busy_time+= from_var->busy_time - dec_var->busy_time;
|
||||
}
|
||||
|
||||
#define SECONDS_TO_WAIT_FOR_KILL 2
|
||||
@ -1428,6 +1432,7 @@ void THD::cleanup_after_query()
|
||||
where= THD::DEFAULT_WHERE;
|
||||
/* reset table map for multi-table update */
|
||||
table_map_for_update= 0;
|
||||
clean_current_user_used();
|
||||
}
|
||||
|
||||
|
||||
@ -2190,9 +2195,21 @@ bool select_export::send_data(List<Item> &items)
|
||||
const char *from_end_pos;
|
||||
const char *error_pos;
|
||||
uint32 bytes;
|
||||
bytes= well_formed_copy_nchars(write_cs, cvt_buff, sizeof(cvt_buff),
|
||||
uint64 estimated_bytes=
|
||||
((uint64) res->length() / res->charset()->mbminlen + 1) *
|
||||
write_cs->mbmaxlen + 1;
|
||||
set_if_smaller(estimated_bytes, UINT_MAX32);
|
||||
if (cvt_str.realloc((uint32) estimated_bytes))
|
||||
{
|
||||
my_error(ER_OUTOFMEMORY, MYF(0), (uint32) estimated_bytes);
|
||||
goto err;
|
||||
}
|
||||
|
||||
bytes= well_formed_copy_nchars(write_cs, (char *) cvt_str.ptr(),
|
||||
cvt_str.alloced_length(),
|
||||
res->charset(), res->ptr(), res->length(),
|
||||
sizeof(cvt_buff),
|
||||
UINT_MAX32, // copy all input chars,
|
||||
// i.e. ignore nchars parameter
|
||||
&well_formed_error_pos,
|
||||
&cannot_convert_error_pos,
|
||||
&from_end_pos);
|
||||
@ -2210,6 +2227,15 @@ bool select_export::send_data(List<Item> &items)
|
||||
"string", printable_buff,
|
||||
item->name, (ulong) row_count);
|
||||
}
|
||||
else if (from_end_pos < res->ptr() + res->length())
|
||||
{
|
||||
/*
|
||||
result is longer than UINT_MAX32 and doesn't fit into String
|
||||
*/
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED),
|
||||
item->full_name(), row_count);
|
||||
}
|
||||
cvt_str.length(bytes);
|
||||
res= &cvt_str;
|
||||
}
|
||||
@ -3514,6 +3540,23 @@ void THD::set_query(char *query_arg, uint32 query_length_arg)
|
||||
pthread_mutex_unlock(&LOCK_thd_data);
|
||||
}
|
||||
|
||||
void THD::get_definer(LEX_USER *definer)
|
||||
{
|
||||
set_current_user_used();
|
||||
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
|
||||
if (slave_thread && has_invoker())
|
||||
{
|
||||
definer->user = invoker_user;
|
||||
definer->host= invoker_host;
|
||||
definer->password= null_lex_str;
|
||||
definer->plugin= empty_lex_str;
|
||||
definer->auth= empty_lex_str;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
get_default_definer(this, definer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Mark transaction to rollback and mark error as fatal to a sub-statement.
|
||||
@ -3612,9 +3655,13 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state)
|
||||
bool xid_cache_insert(XID_STATE *xid_state)
|
||||
{
|
||||
pthread_mutex_lock(&LOCK_xid_cache);
|
||||
DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(),
|
||||
xid_state->xid.key_length())==0);
|
||||
my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state);
|
||||
if (hash_search(&xid_cache, xid_state->xid.key(), xid_state->xid.key_length()))
|
||||
{
|
||||
pthread_mutex_unlock(&LOCK_xid_cache);
|
||||
my_error(ER_XAER_DUPID, MYF(0));
|
||||
return TRUE;
|
||||
}
|
||||
my_bool res= my_hash_insert(&xid_cache, (uchar*)xid_state);
|
||||
pthread_mutex_unlock(&LOCK_xid_cache);
|
||||
return res;
|
||||
}
|
||||
@ -4008,7 +4055,6 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end)
|
||||
if (stmt_end)
|
||||
{
|
||||
pending->set_flags(Rows_log_event::STMT_END_F);
|
||||
pending->flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
|
||||
binlog_table_maps= 0;
|
||||
}
|
||||
|
||||
@ -4136,7 +4182,6 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
|
||||
{
|
||||
Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use,
|
||||
errcode);
|
||||
qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
|
||||
/*
|
||||
Binlog table maps will be irrelevant after a Query_log_event
|
||||
(they are just removed on the slave side) so after the query
|
||||
|
Reference in New Issue
Block a user