mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
merge 5.1-> 5.2
This commit is contained in:
122
sql/sql_parse.cc
122
sql/sql_parse.cc
@ -126,6 +126,14 @@ static bool xa_trans_rolled_back(XID_STATE *xid_state)
|
||||
*/
|
||||
static bool xa_trans_rollback(THD *thd)
|
||||
{
|
||||
/*
|
||||
Resource Manager error is meaningless at this point, as we perform
|
||||
explicit rollback request by user. We must reset rm_error before
|
||||
calling ha_rollback(), so thd->transaction.xid structure gets reset
|
||||
by ha_rollback()/THD::transaction::cleanup().
|
||||
*/
|
||||
thd->transaction.xid_state.rm_error= 0;
|
||||
|
||||
bool status= test(ha_rollback(thd));
|
||||
|
||||
thd->options&= ~(ulong) OPTION_BEGIN;
|
||||
@ -133,7 +141,6 @@ static bool xa_trans_rollback(THD *thd)
|
||||
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
|
||||
xid_cache_delete(&thd->transaction.xid_state);
|
||||
thd->transaction.xid_state.xa_state= XA_NOTR;
|
||||
thd->transaction.xid_state.rm_error= 0;
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -419,29 +426,12 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Execute commands from bootstrap_file.
|
||||
|
||||
Used when creating the initial grant tables.
|
||||
*/
|
||||
|
||||
pthread_handler_t handle_bootstrap(void *arg)
|
||||
static void handle_bootstrap_impl(THD *thd)
|
||||
{
|
||||
THD *thd=(THD*) arg;
|
||||
FILE *file=bootstrap_file;
|
||||
char *buff;
|
||||
const char* found_semicolon= NULL;
|
||||
|
||||
/* The following must be called before DBUG_ENTER */
|
||||
thd->thread_stack= (char*) &thd;
|
||||
if (my_thread_init() || thd->store_globals())
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
close_connection(thd, ER_OUT_OF_RESOURCES, 1);
|
||||
#endif
|
||||
thd->fatal_error();
|
||||
goto end;
|
||||
}
|
||||
DBUG_ENTER("handle_bootstrap");
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
@ -468,7 +458,7 @@ pthread_handler_t handle_bootstrap(void *arg)
|
||||
thd->init_for_queries();
|
||||
while (fgets(buff, thd->net.max_packet, file))
|
||||
{
|
||||
char *query, *res;
|
||||
char *query;
|
||||
/* strlen() can't be deleted because fgets() doesn't return length */
|
||||
ulong length= (ulong) strlen(buff);
|
||||
while (buff[length-1] != '\n' && !feof(file))
|
||||
@ -509,10 +499,10 @@ pthread_handler_t handle_bootstrap(void *arg)
|
||||
thd->db_length + 1 +
|
||||
QUERY_CACHE_FLAGS_SIZE);
|
||||
thd->set_query(query, length);
|
||||
DBUG_PRINT("query",("%-.4096s",thd->query));
|
||||
DBUG_PRINT("query",("%-.4096s", thd->query()));
|
||||
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
|
||||
thd->profiling.start_new_query();
|
||||
thd->profiling.set_query_source(thd->query, length);
|
||||
thd->profiling.set_query_source(thd->query(), length);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -521,7 +511,7 @@ pthread_handler_t handle_bootstrap(void *arg)
|
||||
*/
|
||||
thd->query_id=next_query_id();
|
||||
thd->set_time();
|
||||
mysql_parse(thd, thd->query, length, & found_semicolon);
|
||||
mysql_parse(thd, thd->query(), length, & found_semicolon);
|
||||
close_thread_tables(thd); // Free tables
|
||||
|
||||
bootstrap_error= thd->is_error();
|
||||
@ -540,6 +530,33 @@ pthread_handler_t handle_bootstrap(void *arg)
|
||||
#endif
|
||||
}
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Execute commands from bootstrap_file.
|
||||
|
||||
Used when creating the initial grant tables.
|
||||
*/
|
||||
|
||||
pthread_handler_t handle_bootstrap(void *arg)
|
||||
{
|
||||
THD *thd=(THD*) arg;
|
||||
|
||||
/* The following must be called before DBUG_ENTER */
|
||||
thd->thread_stack= (char*) &thd;
|
||||
if (my_thread_init() || thd->store_globals())
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
close_connection(thd, ER_OUT_OF_RESOURCES, 1);
|
||||
#endif
|
||||
thd->fatal_error();
|
||||
goto end;
|
||||
}
|
||||
|
||||
handle_bootstrap_impl(thd);
|
||||
|
||||
end:
|
||||
net_end(&thd->net);
|
||||
thd->cleanup();
|
||||
@ -554,7 +571,8 @@ end:
|
||||
my_thread_end();
|
||||
pthread_exit(0);
|
||||
#endif
|
||||
DBUG_RETURN(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1216,20 +1234,20 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
{
|
||||
if (alloc_query(thd, packet, packet_length))
|
||||
break; // fatal error is set
|
||||
char *packet_end= thd->query + thd->query_length;
|
||||
char *packet_end= thd->query() + thd->query_length();
|
||||
/* 'b' stands for 'buffer' parameter', special for 'my_snprintf' */
|
||||
const char* end_of_stmt= NULL;
|
||||
|
||||
general_log_write(thd, command, thd->query, thd->query_length);
|
||||
DBUG_PRINT("query",("%-.4096s",thd->query));
|
||||
general_log_write(thd, command, thd->query(), thd->query_length());
|
||||
DBUG_PRINT("query",("%-.4096s",thd->query()));
|
||||
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
|
||||
thd->profiling.set_query_source(thd->query, thd->query_length);
|
||||
thd->profiling.set_query_source(thd->query(), thd->query_length());
|
||||
#endif
|
||||
|
||||
if (!(specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_setprio(pthread_self(),QUERY_PRIOR);
|
||||
|
||||
mysql_parse(thd, thd->query, thd->query_length, &end_of_stmt);
|
||||
mysql_parse(thd, thd->query(), thd->query_length(), &end_of_stmt);
|
||||
|
||||
while (!thd->killed && (end_of_stmt != NULL) && ! thd->is_error())
|
||||
{
|
||||
@ -1441,7 +1459,28 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
if (check_global_access(thd,RELOAD_ACL))
|
||||
break;
|
||||
general_log_print(thd, command, NullS);
|
||||
if (!reload_acl_and_cache(thd, options, (TABLE_LIST*) 0, ¬_used))
|
||||
#ifndef DBUG_OFF
|
||||
bool debug_simulate= FALSE;
|
||||
DBUG_EXECUTE_IF("simulate_detached_thread_refresh", debug_simulate= TRUE;);
|
||||
if (debug_simulate)
|
||||
{
|
||||
/*
|
||||
Simulate a reload without a attached thread session.
|
||||
Provides a environment similar to that of when the
|
||||
server receives a SIGHUP signal and reloads caches
|
||||
and flushes tables.
|
||||
*/
|
||||
bool res;
|
||||
my_pthread_setspecific_ptr(THR_THD, NULL);
|
||||
res= reload_acl_and_cache(NULL, options | REFRESH_FAST,
|
||||
NULL, ¬_used);
|
||||
my_pthread_setspecific_ptr(THR_THD, thd);
|
||||
if (!res)
|
||||
my_ok(thd);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if (!reload_acl_and_cache(thd, options, NULL, ¬_used))
|
||||
my_ok(thd);
|
||||
break;
|
||||
}
|
||||
@ -1680,7 +1719,8 @@ void log_slow_statement(THD *thd)
|
||||
{
|
||||
thd_proc_info(thd, "logging slow query");
|
||||
thd->status_var.long_query_count++;
|
||||
slow_log_print(thd, thd->query, thd->query_length, end_utime_of_query);
|
||||
slow_log_print(thd, thd->query(), thd->query_length(),
|
||||
end_utime_of_query);
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
@ -3008,7 +3048,7 @@ end_with_restore_list:
|
||||
/*
|
||||
Presumably, REPAIR and binlog writing doesn't require synchronization
|
||||
*/
|
||||
write_bin_log(thd, TRUE, thd->query, thd->query_length);
|
||||
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
||||
}
|
||||
select_lex->table_list.first= (uchar*) first_table;
|
||||
lex->query_tables=all_tables;
|
||||
@ -3042,7 +3082,7 @@ end_with_restore_list:
|
||||
/*
|
||||
Presumably, ANALYZE and binlog writing doesn't require synchronization
|
||||
*/
|
||||
write_bin_log(thd, TRUE, thd->query, thd->query_length);
|
||||
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
||||
}
|
||||
select_lex->table_list.first= (uchar*) first_table;
|
||||
lex->query_tables=all_tables;
|
||||
@ -3066,7 +3106,7 @@ end_with_restore_list:
|
||||
/*
|
||||
Presumably, OPTIMIZE and binlog writing doesn't require synchronization
|
||||
*/
|
||||
write_bin_log(thd, TRUE, thd->query, thd->query_length);
|
||||
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
||||
}
|
||||
select_lex->table_list.first= (uchar*) first_table;
|
||||
lex->query_tables=all_tables;
|
||||
@ -4018,7 +4058,7 @@ end_with_restore_list:
|
||||
*/
|
||||
if (!lex->no_write_to_binlog && write_to_binlog)
|
||||
{
|
||||
write_bin_log(thd, FALSE, thd->query, thd->query_length);
|
||||
write_bin_log(thd, FALSE, thd->query(), thd->query_length());
|
||||
}
|
||||
my_ok(thd);
|
||||
}
|
||||
@ -4595,7 +4635,7 @@ create_sp_error:
|
||||
case SP_KEY_NOT_FOUND:
|
||||
if (lex->drop_if_exists)
|
||||
{
|
||||
write_bin_log(thd, TRUE, thd->query, thd->query_length);
|
||||
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||
ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
|
||||
SP_COM_STRING(lex), lex->spname->m_name.str);
|
||||
@ -5129,8 +5169,6 @@ bool check_single_table_access(THD *thd, ulong privilege,
|
||||
/* Show only 1 table for check_grant */
|
||||
if (!(all_tables->belong_to_view &&
|
||||
(thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) &&
|
||||
!(all_tables->view &&
|
||||
all_tables->effective_algorithm == VIEW_ALGORITHM_TMPTABLE) &&
|
||||
check_grant(thd, privilege, all_tables, 0, 1, no_errors))
|
||||
goto deny;
|
||||
|
||||
@ -6012,9 +6050,10 @@ void mysql_parse(THD *thd, const char *inBuf, uint length,
|
||||
PROCESSLIST.
|
||||
Note that we don't need LOCK_thread_count to modify query_length.
|
||||
*/
|
||||
if (*found_semicolon &&
|
||||
(thd->query_length= (ulong)(*found_semicolon - thd->query)))
|
||||
thd->query_length--;
|
||||
if (*found_semicolon && (ulong) (*found_semicolon - thd->query()))
|
||||
thd->set_query_inner(thd->query(),
|
||||
(uint32) (*found_semicolon -
|
||||
thd->query() - 1));
|
||||
/* Actually execute the query */
|
||||
if (*found_semicolon)
|
||||
{
|
||||
@ -6322,6 +6361,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
|
||||
ptr->table_name_length=table->table.length;
|
||||
ptr->lock_type= lock_type;
|
||||
ptr->updating= test(table_options & TL_OPTION_UPDATING);
|
||||
/* TODO: remove TL_OPTION_FORCE_INDEX as it looks like it's not used */
|
||||
ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX);
|
||||
ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);
|
||||
ptr->derived= table->sel;
|
||||
|
Reference in New Issue
Block a user