mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
10.0-base merge
This commit is contained in:
180
sql/sql_class.cc
180
sql/sql_class.cc
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
|
||||
Copyright (c) 2008, 2012, Monty Program Ab
|
||||
Copyright (c) 2008, 2013, Monty Program Ab
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -112,7 +112,8 @@ Key::Key(const Key &rhs, MEM_ROOT *mem_root)
|
||||
columns(rhs.columns, mem_root),
|
||||
name(rhs.name),
|
||||
option_list(rhs.option_list),
|
||||
generated(rhs.generated)
|
||||
generated(rhs.generated),
|
||||
create_if_not_exists(rhs.create_if_not_exists)
|
||||
{
|
||||
list_copy_and_replace_each_value(columns, mem_root);
|
||||
}
|
||||
@@ -349,29 +350,6 @@ void thd_set_thread_stack(THD *thd, char *stack_start)
|
||||
thd->thread_stack= stack_start;
|
||||
}
|
||||
|
||||
/**
|
||||
Lock connection data for the set of connections this connection
|
||||
belongs to
|
||||
|
||||
@param thd THD object
|
||||
*/
|
||||
void thd_lock_thread_count(THD *)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
}
|
||||
|
||||
/**
|
||||
Lock connection data for the set of connections this connection
|
||||
belongs to
|
||||
|
||||
@param thd THD object
|
||||
*/
|
||||
void thd_unlock_thread_count(THD *)
|
||||
{
|
||||
mysql_cond_broadcast(&COND_thread_count);
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
}
|
||||
|
||||
/**
|
||||
Close the socket used by this connection
|
||||
|
||||
@@ -908,6 +886,7 @@ THD::THD()
|
||||
col_access=0;
|
||||
is_slave_error= thread_specific_used= FALSE;
|
||||
my_hash_clear(&handler_tables_hash);
|
||||
my_hash_clear(&ull_hash);
|
||||
tmp_table=0;
|
||||
cuted_fields= 0L;
|
||||
m_sent_row_count= 0L;
|
||||
@@ -947,7 +926,6 @@ THD::THD()
|
||||
net.vio=0;
|
||||
net.buff= 0;
|
||||
client_capabilities= 0; // minimalistic client
|
||||
ull=0;
|
||||
system_thread= NON_SYSTEM_THREAD;
|
||||
cleanup_done= abort_on_warning= 0;
|
||||
peer_port= 0; // For SHOW PROCESSLIST
|
||||
@@ -1005,7 +983,14 @@ THD::THD()
|
||||
protocol_binary.init(this);
|
||||
|
||||
tablespace_op=FALSE;
|
||||
tmp= sql_rnd_with_mutex();
|
||||
|
||||
/*
|
||||
Initialize the random generator. We call my_rnd() without a lock as
|
||||
it's not really critical if two threads modifies the structure at the
|
||||
same time. We ensure that we have an unique number foreach thread
|
||||
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);
|
||||
substitute_null_with_insert_id = FALSE;
|
||||
thr_lock_info_init(&lock_info); /* safety: will be reset after start */
|
||||
@@ -1260,8 +1245,8 @@ LEX_STRING *thd_make_lex_string(THD *thd, LEX_STRING *lex_str,
|
||||
const char *str, unsigned int size,
|
||||
int allocate_lex_string)
|
||||
{
|
||||
return thd->make_lex_string(lex_str, str, size,
|
||||
(bool) allocate_lex_string);
|
||||
return allocate_lex_string ? thd->make_lex_string(str, size)
|
||||
: thd->make_lex_string(lex_str, str, size);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@@ -1452,11 +1437,12 @@ void THD::cleanup(void)
|
||||
#error xid_state in the cache should be replaced by the allocated value
|
||||
}
|
||||
#endif
|
||||
{
|
||||
transaction.xid_state.xa_state= XA_NOTR;
|
||||
trans_rollback(this);
|
||||
xid_cache_delete(&transaction.xid_state);
|
||||
}
|
||||
|
||||
close_temporary_tables(this);
|
||||
|
||||
transaction.xid_state.xa_state= XA_NOTR;
|
||||
trans_rollback(this);
|
||||
xid_cache_delete(&transaction.xid_state);
|
||||
|
||||
locked_tables_list.unlock_locked_tables(this);
|
||||
mysql_ha_cleanup(this);
|
||||
@@ -1474,8 +1460,6 @@ void THD::cleanup(void)
|
||||
if (global_read_lock.is_acquired())
|
||||
global_read_lock.unlock_global_read_lock(this);
|
||||
|
||||
/* All metadata locks must have been released by now. */
|
||||
DBUG_ASSERT(!mdl_context.has_locks());
|
||||
if (user_connect)
|
||||
{
|
||||
decrease_user_connections(user_connect);
|
||||
@@ -1490,17 +1474,12 @@ void THD::cleanup(void)
|
||||
|
||||
delete_dynamic(&user_var_events);
|
||||
my_hash_free(&user_vars);
|
||||
close_temporary_tables(this);
|
||||
sp_cache_clear(&sp_proc_cache);
|
||||
sp_cache_clear(&sp_func_cache);
|
||||
|
||||
if (ull)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_user_locks);
|
||||
item_user_lock_release(ull);
|
||||
mysql_mutex_unlock(&LOCK_user_locks);
|
||||
ull= NULL;
|
||||
}
|
||||
mysql_ull_cleanup(this);
|
||||
/* All metadata locks must have been released by now. */
|
||||
DBUG_ASSERT(!mdl_context.has_locks());
|
||||
|
||||
apc_target.destroy();
|
||||
cleanup_done=1;
|
||||
@@ -1935,6 +1914,19 @@ void THD::cleanup_after_query()
|
||||
stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0;
|
||||
auto_inc_intervals_in_cur_stmt_for_binlog.empty();
|
||||
rand_used= 0;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
/*
|
||||
Clean possible unused INSERT_ID events by current statement.
|
||||
is_update_query() is needed to ignore SET statements:
|
||||
Statements that don't update anything directly and don't
|
||||
used stored functions. This is mostly necessary to ignore
|
||||
statements in binlog between SET INSERT_ID and DML statement
|
||||
which is intended to consume its event (there can be other
|
||||
SET statements between them).
|
||||
*/
|
||||
if ((rli_slave || rli_fake) && is_update_query(lex->sql_command))
|
||||
auto_inc_intervals_forced.empty();
|
||||
#endif
|
||||
}
|
||||
if (first_successful_insert_id_in_cur_stmt > 0)
|
||||
{
|
||||
@@ -1962,30 +1954,6 @@ void THD::cleanup_after_query()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a LEX_STRING in this connection.
|
||||
|
||||
@param lex_str pointer to LEX_STRING object to be initialized
|
||||
@param str initializer to be copied into lex_str
|
||||
@param length length of str, in bytes
|
||||
@param allocate_lex_string if TRUE, allocate new LEX_STRING object,
|
||||
instead of using lex_str value
|
||||
@return NULL on failure, or pointer to the LEX_STRING object
|
||||
*/
|
||||
LEX_STRING *THD::make_lex_string(LEX_STRING *lex_str,
|
||||
const char* str, uint length,
|
||||
bool allocate_lex_string)
|
||||
{
|
||||
if (allocate_lex_string)
|
||||
if (!(lex_str= (LEX_STRING *)alloc_root(mem_root, sizeof(LEX_STRING))))
|
||||
return 0;
|
||||
if (!(lex_str->str= strmake_root(mem_root, str, length)))
|
||||
return 0;
|
||||
lex_str->length= length;
|
||||
return lex_str;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Convert a string to another character set
|
||||
|
||||
@@ -3196,42 +3164,13 @@ int select_exists_subselect::send_data(List<Item> &items)
|
||||
int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
|
||||
{
|
||||
unit= u;
|
||||
List_iterator_fast<my_var> var_li(var_list);
|
||||
List_iterator_fast<Item> it(list);
|
||||
Item *item;
|
||||
my_var *mv;
|
||||
Item_func_set_user_var **suv;
|
||||
|
||||
if (var_list.elements != list.elements)
|
||||
{
|
||||
my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,
|
||||
ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
Iterate over the destination variables and mark them as being
|
||||
updated in this query.
|
||||
We need to do this at JOIN::prepare time to ensure proper
|
||||
const detection of Item_func_get_user_var that is determined
|
||||
by the presence of Item_func_set_user_vars
|
||||
*/
|
||||
|
||||
suv= set_var_items= (Item_func_set_user_var **)
|
||||
sql_alloc(sizeof(Item_func_set_user_var *) * list.elements);
|
||||
|
||||
while ((mv= var_li++) && (item= it++))
|
||||
{
|
||||
if (!mv->local)
|
||||
{
|
||||
*suv= new Item_func_set_user_var(mv->s, item);
|
||||
(*suv)->fix_fields(thd, 0);
|
||||
}
|
||||
else
|
||||
*suv= NULL;
|
||||
suv++;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3561,7 +3500,6 @@ int select_dumpvar::send_data(List<Item> &items)
|
||||
List_iterator<Item> it(items);
|
||||
Item *item;
|
||||
my_var *mv;
|
||||
Item_func_set_user_var **suv;
|
||||
DBUG_ENTER("select_dumpvar::send_data");
|
||||
|
||||
if (unit->offset_limit_cnt)
|
||||
@@ -3574,19 +3512,20 @@ int select_dumpvar::send_data(List<Item> &items)
|
||||
my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
for (suv= set_var_items; ((mv= var_li++) && (item= it++)); suv++)
|
||||
while ((mv= var_li++) && (item= it++))
|
||||
{
|
||||
if (mv->local)
|
||||
{
|
||||
DBUG_ASSERT(!*suv);
|
||||
if (thd->spcont->set_variable(thd, mv->offset, &item))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBUG_ASSERT(*suv);
|
||||
(*suv)->save_item_result(item);
|
||||
if ((*suv)->update())
|
||||
Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item);
|
||||
suv->save_item_result(item);
|
||||
if (suv->fix_fields(thd, 0))
|
||||
DBUG_RETURN (1);
|
||||
if (suv->update())
|
||||
DBUG_RETURN (1);
|
||||
}
|
||||
}
|
||||
@@ -4117,6 +4056,15 @@ extern "C" unsigned long thd_get_thread_id(const MYSQL_THD thd)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check if THD socket is still connected.
|
||||
*/
|
||||
extern "C" int thd_is_connected(MYSQL_THD thd)
|
||||
{
|
||||
return thd->is_connected();
|
||||
}
|
||||
|
||||
|
||||
#ifdef INNODB_COMPATIBILITY_HOOKS
|
||||
extern "C" const struct charset_info_st *thd_charset(MYSQL_THD thd)
|
||||
{
|
||||
@@ -4541,17 +4489,8 @@ void THD::set_query_and_id(char *query_arg, uint32 query_length_arg,
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
set_query_inner(query_arg, query_length_arg, cs);
|
||||
query_id= new_query_id;
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
}
|
||||
|
||||
/** Assign a new value to thd->query_id. */
|
||||
|
||||
void THD::set_query_id(query_id_t new_query_id)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
query_id= new_query_id;
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
}
|
||||
|
||||
/** Assign a new value to thd->mysys_var. */
|
||||
@@ -4585,6 +4524,8 @@ void THD::leave_locked_tables_mode()
|
||||
/* Also ensure that we don't release metadata locks for open HANDLERs. */
|
||||
if (handler_tables_hash.records)
|
||||
mysql_ha_set_explicit_lock_duration(this);
|
||||
if (ull_hash.records)
|
||||
mysql_ull_set_explicit_lock_duration(this);
|
||||
}
|
||||
locked_tables_mode= LTM_NONE;
|
||||
}
|
||||
@@ -4721,9 +4662,14 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state)
|
||||
bool xid_cache_insert(XID_STATE *xid_state)
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_xid_cache);
|
||||
DBUG_ASSERT(my_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 (my_hash_search(&xid_cache, xid_state->xid.key(),
|
||||
xid_state->xid.key_length()))
|
||||
{
|
||||
mysql_mutex_unlock(&LOCK_xid_cache);
|
||||
my_error(ER_XAER_DUPID, MYF(0));
|
||||
return true;
|
||||
}
|
||||
bool res= my_hash_insert(&xid_cache, (uchar*)xid_state);
|
||||
mysql_mutex_unlock(&LOCK_xid_cache);
|
||||
return res;
|
||||
}
|
||||
@@ -4838,7 +4784,7 @@ void xid_cache_delete(XID_STATE *xid_state)
|
||||
int THD::decide_logging_format(TABLE_LIST *tables)
|
||||
{
|
||||
DBUG_ENTER("THD::decide_logging_format");
|
||||
DBUG_PRINT("info", ("query: %s", query()));
|
||||
DBUG_PRINT("info", ("Query: %s", query()));
|
||||
DBUG_PRINT("info", ("variables.binlog_format: %lu",
|
||||
variables.binlog_format));
|
||||
DBUG_PRINT("info", ("lex->get_stmt_unsafe_flags(): 0x%x",
|
||||
|
Reference in New Issue
Block a user