mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge branch '10.1' into 10.2
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
|
||||
Copyright (c) 2008, 2017, MariaDB
|
||||
Copyright (c) 2008, 2018, MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -506,6 +506,7 @@ void init_update_queries(void)
|
||||
server_command_flags[COM_SHUTDOWN]= CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_SLEEP]= CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_TIME]= CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_INIT_DB]= CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_END]= CF_SKIP_WSREP_CHECK;
|
||||
for (uint i= COM_MDB_GAP_BEG; i <= COM_MDB_GAP_END; i++)
|
||||
{
|
||||
@ -519,6 +520,8 @@ void init_update_queries(void)
|
||||
server_command_flags[COM_QUERY]= CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_SET_OPTION]= CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_STMT_PREPARE]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_STMT_EXECUTE]= CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_STMT_FETCH]= CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_STMT_CLOSE]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_STMT_RESET]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
|
||||
server_command_flags[COM_STMT_EXECUTE]= CF_SKIP_WSREP_CHECK;
|
||||
@ -1146,21 +1149,28 @@ static enum enum_server_command fetch_command(THD *thd, char *packet)
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
static bool wsrep_node_is_ready(THD *thd)
|
||||
static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables)
|
||||
{
|
||||
if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready)
|
||||
bool has_tables = false;
|
||||
for (const TABLE_LIST *table= tables; table; table= table->next_global)
|
||||
{
|
||||
my_message(ER_UNKNOWN_COM_ERROR,
|
||||
"WSREP has not yet prepared node for application use",
|
||||
MYF(0));
|
||||
return false;
|
||||
TABLE_CATEGORY c;
|
||||
LEX_STRING db, tn;
|
||||
lex_string_set(&db, table->db);
|
||||
lex_string_set(&tn, table->table_name);
|
||||
c= get_table_category(&db, &tn);
|
||||
if (c != TABLE_CATEGORY_INFORMATION &&
|
||||
c != TABLE_CATEGORY_PERFORMANCE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
has_tables = true;
|
||||
}
|
||||
return true;
|
||||
return has_tables;
|
||||
}
|
||||
#endif
|
||||
#endif /* WITH_WSREP */
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
|
||||
/**
|
||||
Read one command from connection and execute it (query or simple command).
|
||||
@ -1336,8 +1346,9 @@ bool do_command(THD *thd)
|
||||
/*
|
||||
Bail out if DB snapshot has not been installed.
|
||||
*/
|
||||
if (!(server_command_flags[command] & CF_SKIP_WSREP_CHECK) &&
|
||||
!wsrep_node_is_ready(thd))
|
||||
if (thd->variables.wsrep_on && !thd->wsrep_applier &&
|
||||
(!wsrep_ready || wsrep_reject_queries != WSREP_REJECT_NONE) &&
|
||||
(server_command_flags[command] & CF_SKIP_WSREP_CHECK) == 0)
|
||||
{
|
||||
thd->protocol->end_statement();
|
||||
|
||||
@ -3143,20 +3154,23 @@ mysql_execute_command(THD *thd)
|
||||
}
|
||||
|
||||
/*
|
||||
Bail out if DB snapshot has not been installed. SET and SHOW commands,
|
||||
however, are always allowed.
|
||||
Select query is also allowed if it does not access any table.
|
||||
We additionally allow all other commands that do not change data in
|
||||
case wsrep_dirty_reads is enabled.
|
||||
*/
|
||||
if (lex->sql_command != SQLCOM_SET_OPTION &&
|
||||
!wsrep_is_show_query(lex->sql_command) &&
|
||||
!(thd->variables.wsrep_dirty_reads &&
|
||||
!is_update_query(lex->sql_command)) &&
|
||||
!(lex->sql_command == SQLCOM_SELECT &&
|
||||
!all_tables) &&
|
||||
!wsrep_node_is_ready(thd))
|
||||
* Bail out if DB snapshot has not been installed. We however,
|
||||
* allow SET and SHOW queries and reads from information schema
|
||||
* and dirty reads (if configured)
|
||||
*/
|
||||
if (thd->variables.wsrep_on &&
|
||||
!thd->wsrep_applier &&
|
||||
!(wsrep_ready && wsrep_reject_queries == WSREP_REJECT_NONE) &&
|
||||
!(thd->variables.wsrep_dirty_reads &&
|
||||
(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) &&
|
||||
!wsrep_tables_accessible_when_detached(all_tables) &&
|
||||
lex->sql_command != SQLCOM_SET_OPTION &&
|
||||
!wsrep_is_show_query(lex->sql_command))
|
||||
{
|
||||
my_message(ER_UNKNOWN_COM_ERROR,
|
||||
"WSREP has not yet prepared node for application use", MYF(0));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
status_var_increment(thd->status_var.com_stat[lex->sql_command]);
|
||||
|
Reference in New Issue
Block a user