diff options
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c2199ce6ec7..f139cdd6d73 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -31,6 +31,7 @@ #include "transaction.h" #include "sql_prepare.h" #include "probes_mysql.h" +#include "set_var.h" /** @defgroup Runtime_Environment Runtime Environment @@ -344,25 +345,34 @@ bool is_log_table_write_query(enum enum_sql_command command) return (sql_command_flags[command] & CF_WRITE_LOGS_COMMAND) != 0; } -void execute_init_command(THD *thd, sys_var_str *init_command_var, - rw_lock_t *var_mutex) +void execute_init_command(THD *thd, LEX_STRING *init_command, + rw_lock_t *var_lock) { Vio* save_vio; ulong save_client_capabilities; + rw_rdlock(var_lock); + if (!init_command->length) + { + rw_unlock(var_lock); + return; + } + + /* + copy the value under a lock, and release the lock. + init_command has to be executed without a lock held, + as it may try to change itself + */ + size_t len= init_command->length; + char *buf= thd->strmake(init_command->str, len); + rw_unlock(var_lock); + #if defined(ENABLED_PROFILING) thd->profiling.start_new_query(); - thd->profiling.set_query_source(init_command_var->value, - init_command_var->value_length); + thd->profiling.set_query_source(buf, len); #endif thd_proc_info(thd, "Execution of init_command"); - /* - We need to lock init_command_var because - during execution of init_command_var query - values of init_command_var can't be changed - */ - rw_rdlock(var_mutex); save_client_capabilities= thd->client_capabilities; thd->client_capabilities|= CLIENT_MULTI_QUERIES; /* @@ -371,10 +381,7 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var, */ save_vio= thd->net.vio; thd->net.vio= 0; - dispatch_command(COM_QUERY, thd, - init_command_var->value, - init_command_var->value_length); - rw_unlock(var_mutex); + dispatch_command(COM_QUERY, thd, buf, len); thd->client_capabilities= save_client_capabilities; thd->net.vio= save_vio; @@ -397,9 +404,6 @@ static void handle_bootstrap_impl(THD *thd) thd->thread_stack= (char*) &thd; #endif /* EMBEDDED_LIBRARY */ - if (thd->variables.max_join_size == HA_POS_ERROR) - thd->options |= OPTION_BIG_SELECTS; - thd_proc_info(thd, 0); thd->version=refresh_version; thd->security_ctx->priv_user= @@ -624,7 +628,7 @@ bool do_command(THD *thd) This thread will do a blocking read from the client which will be interrupted when the next command is received from the client, the connection is closed or "net_wait_timeout" - number of seconds has passed + number of seconds has passed. */ my_net_set_read_timeout(net, thd->variables.net_wait_timeout); @@ -1737,8 +1741,6 @@ bool sp_process_definer(THD *thd) TODO: this is workaround. right way will be move invalidating in the unlock procedure. - TODO: use check_change_password() - - JOIN is not supported yet. TODO - - SUSPEND and FOR MIGRATE are not supported yet. TODO @retval FALSE OK @@ -2457,7 +2459,8 @@ case SQLCOM_PREPARE: { /* So that CREATE TEMPORARY TABLE gets to binlog at commit/rollback */ if (create_info.options & HA_LEX_CREATE_TMP_TABLE) - thd->options|= OPTION_KEEP_LOG; + thd->variables.option_bits|= OPTION_KEEP_LOG; + /* regular create */ if (create_info.options & HA_LEX_CREATE_TABLE_LIKE) { /* CREATE TABLE ... LIKE ... */ @@ -3126,7 +3129,7 @@ end_with_restore_list: select_lex->where, 0, (ORDER *)NULL, (ORDER *)NULL, (Item *)NULL, (ORDER *)NULL, - select_lex->options | thd->options | + select_lex->options | thd->variables.option_bits | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | OPTION_SETUP_TABLES_DONE, del_result, unit, select_lex); @@ -3165,7 +3168,7 @@ end_with_restore_list: lex->drop_if_exists= 1; /* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */ - thd->options|= OPTION_KEEP_LOG; + thd->variables.option_bits|= OPTION_KEEP_LOG; } /* DDL and binlog write order protected by LOCK_open */ res= mysql_rm_table(thd, first_table, lex->drop_if_exists, @@ -3247,11 +3250,6 @@ end_with_restore_list: if ((check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE) || open_and_lock_tables(thd, all_tables))) goto error; - if (lex->one_shot_set && not_all_support_one_shot(lex_var_list)) - { - my_error(ER_RESERVED_SYNTAX, MYF(0), "SET ONE_SHOT"); - goto error; - } if (!(res= sql_set_variables(thd, lex_var_list))) { /* @@ -3284,11 +3282,11 @@ end_with_restore_list: false, mysqldump will not work. */ thd->locked_tables_list.unlock_locked_tables(thd); - if (thd->options & OPTION_TABLE_LOCK) + if (thd->variables.option_bits & OPTION_TABLE_LOCK) { trans_commit_implicit(thd); thd->mdl_context.release_transactional_locks(); - thd->options&= ~(OPTION_TABLE_LOCK); + thd->variables.option_bits&= ~(OPTION_TABLE_LOCK); } if (thd->global_read_lock.is_acquired()) thd->global_read_lock.unlock_global_read_lock(thd); @@ -3318,7 +3316,7 @@ end_with_restore_list: init_mdl_requests(all_tables); - thd->options|= OPTION_TABLE_LOCK; + thd->variables.option_bits|= OPTION_TABLE_LOCK; thd->in_lock_tables=1; { @@ -3348,7 +3346,7 @@ end_with_restore_list: close_thread_tables(thd); DBUG_ASSERT(!thd->locked_tables_mode); thd->mdl_context.release_transactional_locks(); - thd->options&= ~(OPTION_TABLE_LOCK); + thd->variables.option_bits&= ~(OPTION_TABLE_LOCK); } else { @@ -5070,7 +5068,7 @@ check_routine_access(THD *thd, ulong want_access,char *db, char *name, 0, no_errors, 0)) return TRUE; - return check_grant_routine(thd, want_access, tables, is_proc, no_errors); + return check_grant_routine(thd, want_access, tables, is_proc, no_errors); } @@ -5296,7 +5294,7 @@ void mysql_reset_thd_for_next_command(THD *thd) */ if (!thd->in_multi_stmt_transaction()) { - thd->options&= ~OPTION_KEEP_LOG; + thd->variables.option_bits&= ~OPTION_KEEP_LOG; thd->transaction.all.modified_non_trans_table= FALSE; } DBUG_ASSERT(thd->security_ctx== &thd->main_security_ctx); @@ -6932,7 +6930,7 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables) } thd->lex->query_tables_own_last= save_query_tables_own_last; - if ((thd->options & OPTION_SAFE_UPDATES) && !select_lex->where) + if ((thd->variables.option_bits & OPTION_SAFE_UPDATES) && !select_lex->where) { my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0)); |