diff options
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 123 |
1 files changed, 73 insertions, 50 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 6265d8060ce..c5085590511 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -87,6 +87,7 @@ enum wsrep_consistency_check_mode { class Reprepare_observer; class Relay_log_info; struct rpl_group_info; +struct rpl_parallel_thread; class Rpl_filter; class Query_log_event; class Load_log_event; @@ -319,9 +320,9 @@ class Key_part_spec :public Sql_alloc { public: LEX_CSTRING field_name; uint length; - bool generated; + bool generated, asc; Key_part_spec(const LEX_CSTRING *name, uint len, bool gen= false) - : field_name(*name), length(len), generated(gen) + : field_name(*name), length(len), generated(gen), asc(1) {} bool operator==(const Key_part_spec& other) const; /** @@ -589,7 +590,8 @@ typedef enum enum_diag_condition_item_name DIAG_CURSOR_NAME= 9, DIAG_MESSAGE_TEXT= 10, DIAG_MYSQL_ERRNO= 11, - LAST_DIAG_SET_PROPERTY= DIAG_MYSQL_ERRNO + DIAG_ROW_NUMBER= 12, + LAST_DIAG_SET_PROPERTY= DIAG_ROW_NUMBER } Diag_condition_item_name; /** @@ -881,6 +883,7 @@ typedef struct system_variables vers_asof_timestamp_t vers_asof_timestamp; ulong vers_alter_history; + my_bool binlog_alter_two_phase; } SV; /** @@ -1160,6 +1163,7 @@ struct THD_count { static Atomic_counter<uint32_t> count; static uint value() { return static_cast<uint>(count); } + static uint connection_thd_count(); THD_count() { count++; } ~THD_count() { count--; } }; @@ -3070,6 +3074,11 @@ public: } bool binlog_table_should_be_logged(const LEX_CSTRING *db); + // Accessors and setters of two-phase loggable ALTER binlog properties + uchar get_binlog_flags_for_alter(); + void set_binlog_flags_for_alter(uchar); + uint64 get_binlog_start_alter_seq_no(); + void set_binlog_start_alter_seq_no(uint64); #endif /* MYSQL_CLIENT */ public: @@ -3125,8 +3134,8 @@ public: { bzero((char*)this, sizeof(*this)); implicit_xid.null(); - init_sql_alloc(key_memory_thd_transactions, &mem_root, - ALLOC_ROOT_MIN_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC)); + init_sql_alloc(key_memory_thd_transactions, &mem_root, 256, + 0, MYF(MY_THREAD_SPECIFIC)); } } default_transaction, *transaction; Global_read_lock global_read_lock; @@ -3296,6 +3305,13 @@ public: auto_inc_intervals_forced.empty(); // in case of multiple SET INSERT_ID auto_inc_intervals_forced.append(next_id, ULONGLONG_MAX, 0); } + inline void set_binlog_bit() + { + if (variables.sql_log_bin) + variables.option_bits |= OPTION_BIN_LOG; + else + variables.option_bits &= ~OPTION_BIN_LOG; + } ulonglong limit_found_rows; @@ -3992,6 +4008,11 @@ public: user_time= t; set_time(); } + inline void force_set_time(my_time_t t, ulong sec_part) + { + start_time= system_time.sec= t; + start_time_sec_part= system_time.sec_part= sec_part; + } /* this is only used by replication and BINLOG command. usecs > TIME_MAX_SECOND_PART means "was not in binlog" @@ -4003,15 +4024,9 @@ public: else { if (sec_part <= TIME_MAX_SECOND_PART) - { - start_time= system_time.sec= t; - start_time_sec_part= system_time.sec_part= sec_part; - } + force_set_time(t, sec_part); else if (t != system_time.sec) - { - start_time= system_time.sec= t; - start_time_sec_part= system_time.sec_part= 0; - } + force_set_time(t, 0); else { start_time= t; @@ -4879,45 +4894,17 @@ private: @param msg the condition message text @return The condition raised, or NULL */ - Sql_condition* - raise_condition(uint sql_errno, - const char* sqlstate, - Sql_condition::enum_warning_level level, - const char* msg) + Sql_condition* raise_condition(uint sql_errno, const char* sqlstate, + Sql_condition::enum_warning_level level, const char* msg) { - return raise_condition(sql_errno, sqlstate, level, - Sql_user_condition_identity(), msg); + Sql_condition cond(NULL, // don't strdup the msg + Sql_condition_identity(sql_errno, sqlstate, level, + Sql_user_condition_identity()), + msg, get_stmt_da()->current_row_for_warning()); + return raise_condition(&cond); } - /** - Raise a generic or a user defined SQL condition. - @param ucid - the user condition identity - (or an empty identity if not a user condition) - @param sql_errno - the condition error number - @param sqlstate - the condition SQLSTATE - @param level - the condition level - @param msg - the condition message text - @return The condition raised, or NULL - */ - Sql_condition* - raise_condition(uint sql_errno, - const char* sqlstate, - Sql_condition::enum_warning_level level, - const Sql_user_condition_identity &ucid, - const char* msg); - - Sql_condition* - raise_condition(const Sql_condition *cond) - { - Sql_condition *raised= raise_condition(cond->get_sql_errno(), - cond->get_sqlstate(), - cond->get_level(), - *cond/*Sql_user_condition_identity*/, - cond->get_message_text()); - if (raised) - raised->copy_opt_attributes(cond); - return raised; - } + Sql_condition* raise_condition(const Sql_condition *cond); private: void push_warning_truncated_priv(Sql_condition::enum_warning_level level, @@ -5559,7 +5546,8 @@ public: bool restore_from_local_lex_to_old_lex(LEX *oldlex); Item *sp_fix_func_item(Item **it_addr); - Item *sp_prepare_func_item(Item **it_addr, uint cols= 1); + Item *sp_fix_func_item_for_assignment(const Field *to, Item **it_addr); + Item *sp_prepare_func_item(Item **it_addr, uint cols); bool sp_eval_expr(Field *result_field, Item **expr_item_ptr); bool sql_parser(LEX *old_lex, LEX *lex, @@ -7945,6 +7933,41 @@ extern THD_list server_threads; void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps, uint field_count); +#ifdef WITH_WSREP +extern void wsrep_to_isolation_end(THD*); +#endif +/* + RAII utility class to ease binlogging with temporary setting + THD etc context and restoring the original one upon logger execution. +*/ +class Write_log_with_flags +{ + THD* m_thd; +#ifdef WITH_WSREP + bool wsrep_to_isolation; +#endif + +public: +~Write_log_with_flags() + { + m_thd->set_binlog_flags_for_alter(0); + m_thd->set_binlog_start_alter_seq_no(0); +#ifdef WITH_WSREP + if (wsrep_to_isolation) + wsrep_to_isolation_end(m_thd); +#endif + } + + Write_log_with_flags(THD *thd, uchar flags, + bool do_wsrep_iso __attribute__((unused))= false) : + m_thd(thd) + { + m_thd->set_binlog_flags_for_alter(flags); +#ifdef WITH_WSREP + wsrep_to_isolation= do_wsrep_iso && WSREP(m_thd); +#endif + } +}; #endif /* MYSQL_SERVER */ #endif /* SQL_CLASS_INCLUDED */ |