diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-12-07 09:49:38 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-12-07 09:49:38 +0200 |
commit | 3ff4eb07edfd41a61d8283b59c35a29637297b3c (patch) | |
tree | 512e58b367d8c2ff4e9990a72e049c325a9263c4 /sql | |
parent | a27bfb2a872ea48a5083c2558bca58dc4358316f (diff) | |
parent | 23f705f3a2e4125ed7026e1c9f3207088baa5fc0 (diff) | |
download | mariadb-git-3ff4eb07edfd41a61d8283b59c35a29637297b3c.tar.gz |
Merge 10.9 into 10.10
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 2 | ||||
-rw-r--r-- | sql/item.cc | 1 | ||||
-rw-r--r-- | sql/slave.cc | 6 | ||||
-rw-r--r-- | sql/sql_base.cc | 2 | ||||
-rw-r--r-- | sql/sql_const.h | 2 | ||||
-rw-r--r-- | sql/sql_delete.cc | 4 | ||||
-rw-r--r-- | sql/sql_lex.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.h | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/sql_select.h | 5 | ||||
-rw-r--r-- | sql/table.cc | 1 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 16 | ||||
-rw-r--r-- | sql/wsrep_mysqld.h | 1 | ||||
-rw-r--r-- | sql/wsrep_thd.cc | 3 | ||||
-rw-r--r-- | sql/wsrep_var.cc | 9 |
16 files changed, 47 insertions, 18 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 82a4f3968fc..2aeb5a4d9e2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4535,7 +4535,7 @@ void handler::print_error(int error, myf errflag) break; case HA_ERR_AUTOINC_ERANGE: textno= error; - my_error(textno, errflag, table->next_number_field->field_name.str, + my_error(textno, errflag, table->found_next_number_field->field_name.str, table->in_use->get_stmt_da()->current_row_for_warning()); DBUG_VOID_RETURN; break; diff --git a/sql/item.cc b/sql/item.cc index 24cd62c1d44..bb6657ab416 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6141,6 +6141,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) if (!thd->lex->current_select->no_wrap_view_item && thd->lex->in_sum_func && + select && thd->lex == select->parent_lex && thd->lex->in_sum_func->nest_level == select->nest_level) diff --git a/sql/slave.cc b/sql/slave.cc index e39efcc6bbc..eac1326df34 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -7426,9 +7426,9 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, mi->ssl_ca[0]?mi->ssl_ca:0, mi->ssl_capath[0]?mi->ssl_capath:0, mi->ssl_cipher[0]?mi->ssl_cipher:0); - mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, - &mi->ssl_verify_server_cert); - mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, + mysql_options(mysql, MYSQL_OPT_SSL_CRL, + mi->ssl_crl[0] ? mi->ssl_crl : 0); + mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, mi->ssl_crlpath[0] ? mi->ssl_crlpath : 0); mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &mi->ssl_verify_server_cert); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 53999ba4dc2..b067d62663d 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8004,6 +8004,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, thd->lex->current_select->select_list_tables|= item->used_tables(); thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->cur_pos_in_select_list++; + + thd->lex->current_select->rownum_in_field_list |= item->with_rownum_func(); } thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS; diff --git a/sql/sql_const.h b/sql/sql_const.h index bcc556e61f9..490b870d768 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -29,7 +29,7 @@ /* extra 4+4 bytes for slave tmp tables */ #define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4) #define MAX_ALIAS_NAME 256 -#define MAX_FIELD_NAME 34 /* Max colum name length +2 */ +#define MAX_FIELD_NAME (NAME_LEN+1) /* Max colum name length +1 */ #define MAX_SYS_VAR_LENGTH 32 #define MAX_KEY MAX_INDEXES /* Max used keys */ #define MAX_REF_PARTS 32 /* Max parts used as ref */ diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 1f0945b1a2d..d31d0b949ba 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -712,6 +712,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { table->use_all_columns(); table->rpl_write_set= table->write_set; + // Initialize autoinc. + // We don't set next_number_field here, as it is handled manually. + if (table->found_next_number_field) + table->file->info(HA_STATUS_AUTO); } else { diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 1b04ec9bd20..9d16f0dad35 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2976,6 +2976,8 @@ void st_select_lex::init_query() prep_leaf_list_state= UNINIT; bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used)); select_list_tables= 0; + rownum_in_field_list= 0; + window_specs.empty(); window_funcs.empty(); tvc= 0; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index b674bc714e5..942e2075ff1 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1348,6 +1348,9 @@ public: */ table_map select_list_tables; + /* Set to 1 if any field in field list has ROWNUM() */ + bool rownum_in_field_list; + /* namp of nesting SELECT visibility (for aggregate functions check) */ nesting_map name_visibility_map; table_map with_dep; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index bc6f4445bb9..24a4b4a69c7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1136,7 +1136,7 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables) if (get_table_category(&db, &tn) < TABLE_CATEGORY_INFORMATION) return false; } - return true; + return tables != NULL; } static bool wsrep_command_no_result(char command) @@ -3687,6 +3687,8 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) (sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) && !wsrep_tables_accessible_when_detached(all_tables) && lex->sql_command != SQLCOM_SET_OPTION && + lex->sql_command != SQLCOM_CHANGE_DB && + !(lex->sql_command == SQLCOM_SELECT && !all_tables) && !wsrep_is_show_query(lex->sql_command)) { my_message(ER_UNKNOWN_COM_ERROR, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 87899aff74b..9ead04e902a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -460,7 +460,6 @@ void JOIN::init(THD *thd_arg, List<Item> &fields_arg, no_order= 0; simple_order= 0; simple_group= 0; - rand_table_in_field_list= 0; ordered_index_usage= ordered_index_void; need_distinct= 0; skip_sort_order= 0; @@ -1461,7 +1460,6 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num, &all_fields, &select_lex->pre_fix, 1)) DBUG_RETURN(-1); thd->lex->current_select->context_analysis_place= save_place; - rand_table_in_field_list= select_lex->select_list_tables & RAND_TABLE_BIT; if (setup_without_group(thd, ref_ptrs, tables_list, select_lex->leaf_tables, fields_list, @@ -15169,7 +15167,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, and some wrong results so better to leave the code as it was related to ROLLUP. */ - *simple_order= !join->rand_table_in_field_list; + *simple_order= !join->select_lex->rownum_in_field_list; if (join->only_const_tables()) return change_list ? 0 : first_order; // No need to sort diff --git a/sql/sql_select.h b/sql/sql_select.h index 24120f76877..aed58634319 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1441,11 +1441,6 @@ public: GROUP/ORDER BY. */ bool simple_order, simple_group; - /* - Set to 1 if any field in field list has RAND_TABLE set. For example if - if one uses RAND() or ROWNUM() in field list - */ - bool rand_table_in_field_list; /* ordered_index_usage is set if an ordered index access diff --git a/sql/table.cc b/sql/table.cc index 80989ddc0ce..1f1925db93a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -9012,6 +9012,7 @@ int TABLE::update_generated_fields() res= found_next_number_field->set_default(); if (likely(!res)) res= file->update_auto_increment(); + next_number_field= NULL; } if (likely(!res) && vfield) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index d9670dccfab..43e694f6367 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -128,6 +128,7 @@ ulong wsrep_trx_fragment_unit= WSREP_FRAG_BYTES; ulong wsrep_SR_store_type= WSREP_SR_STORE_TABLE; uint wsrep_ignore_apply_errors= 0; +std::atomic <bool> wsrep_thread_create_failed; /* * End configuration options @@ -3565,7 +3566,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len) void* start_wsrep_THD(void *arg) { - THD *thd; + THD *thd= NULL; Wsrep_thd_args* thd_args= (Wsrep_thd_args*) arg; @@ -3596,6 +3597,7 @@ void* start_wsrep_THD(void *arg) mysql_thread_set_psi_id(thd->thread_id); thd->thr_create_utime= microsecond_interval_timer(); + DBUG_EXECUTE_IF("wsrep_simulate_failed_connection_1", goto error; ); // </5.1.17> /* handle_one_connection() is normally the only way a thread would @@ -3702,6 +3704,18 @@ void* start_wsrep_THD(void *arg) error: WSREP_ERROR("Failed to create/initialize system thread"); + if (thd) + { + close_connection(thd, ER_OUT_OF_RESOURCES); + statistic_increment(aborted_connects, &LOCK_status); + server_threads.erase(thd); + delete thd; + my_thread_end(); + } + delete thd_args; + // This will signal error to wsrep_slave_threads_update + wsrep_thread_create_failed.store(true, std::memory_order_relaxed); + /* Abort if its the first applier/rollbacker thread. */ if (!mysqld_server_initialized) unireg_abort(1); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 81d38df5fb5..0d2fcd559ef 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -90,6 +90,7 @@ extern ulong wsrep_running_rollbacker_threads; extern bool wsrep_new_cluster; extern bool wsrep_gtid_mode; extern uint32 wsrep_gtid_domain_id; +extern std::atomic <bool > wsrep_thread_create_failed; extern ulonglong wsrep_mode; enum enum_wsrep_reject_types { diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 770c4657e65..e610d3a6c2b 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -23,8 +23,7 @@ #include "rpl_rli.h" #include "log_event.h" #include "sql_parse.h" -#include "mysqld.h" // start_wsrep_THD(); -#include "wsrep_applier.h" // start_wsrep_THD(); +#include "wsrep_mysqld.h" // start_wsrep_THD(); #include "mysql/service_wsrep.h" #include "debug_sync.h" #include "slave.h" diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 4f4e7817fef..0de1b034953 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -789,18 +789,25 @@ bool wsrep_slave_threads_update (sys_var *self, THD* thd, enum_var_type type) if (wsrep_slave_count_change > 0) { WSREP_DEBUG("Creating %d applier threads, total %ld", wsrep_slave_count_change, wsrep_slave_threads); + wsrep_thread_create_failed.store(false, std::memory_order_relaxed); res= wsrep_create_appliers(wsrep_slave_count_change, true); mysql_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_wsrep_slave_threads); // Thread creation and execution is asyncronous, therefore we need // wait them to be started or error produced - while (wsrep_running_applier_threads != (ulong)wsrep_slave_threads) + while (wsrep_running_applier_threads != (ulong)wsrep_slave_threads && + !wsrep_thread_create_failed.load(std::memory_order_relaxed)) { my_sleep(1000); } mysql_mutex_lock(&LOCK_global_system_variables); + if (wsrep_thread_create_failed.load(std::memory_order_relaxed)) { + wsrep_slave_threads= wsrep_running_applier_threads; + return true; + } + WSREP_DEBUG("Running %lu applier threads", wsrep_running_applier_threads); wsrep_slave_count_change = 0; } |