summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/item.cc1
-rw-r--r--sql/slave.cc6
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_const.h2
-rw-r--r--sql/sql_delete.cc4
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_lex.h3
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/sql_select.h5
-rw-r--r--sql/table.cc1
-rw-r--r--sql/wsrep_mysqld.cc16
-rw-r--r--sql/wsrep_mysqld.h1
-rw-r--r--sql/wsrep_thd.cc3
-rw-r--r--sql/wsrep_var.cc9
16 files changed, 47 insertions, 18 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index d3de74a8451..6487ccd2f92 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4531,7 +4531,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 385016d51b0..535fb1328d2 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -6130,6 +6130,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 cf290fb8a89..361e77f2d04 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -7342,9 +7342,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 b7296395444..4142540fa88 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7738,6 +7738,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 e64dd847dcd..d74b9e8916f 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -704,6 +704,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 dbc38552e76..9cf10bd5b82 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -3002,6 +3002,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 c16947edc5a..85f7da7d09f 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1343,6 +1343,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 3d0809f8785..2b8ea9265de 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 6e914a1529e..be78cad5f7a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -434,7 +434,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;
@@ -1434,7 +1433,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,
@@ -14806,7 +14804,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 c9e0fa25421..3332bc78b6c 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1420,11 +1420,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 52dc78aea28..8773eed9a40 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -8993,6 +8993,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 ccd7693bb09..3dd7a6ef9d4 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -125,6 +125,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
@@ -3513,7 +3514,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;
@@ -3544,6 +3545,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
@@ -3650,6 +3652,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 5ba466a03d3..412b9242d77 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -88,6 +88,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;
}