mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
cleanup: introduce CF_SKIP_WSREP_CHECK
remove if() over many COM_xxx values
This commit is contained in:
@ -4894,6 +4894,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
#define CF_SKIP_QUESTIONS (1U << 1)
|
#define CF_SKIP_QUESTIONS (1U << 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do not check that wsrep snapshot is ready before allowing this command
|
||||||
|
*/
|
||||||
|
#define CF_SKIP_WSREP_CHECK (1U << 2)
|
||||||
|
|
||||||
void mark_transaction_to_rollback(THD *thd, bool all);
|
void mark_transaction_to_rollback(THD *thd, bool all);
|
||||||
|
|
||||||
/* Inline functions */
|
/* Inline functions */
|
||||||
|
@ -265,11 +265,26 @@ void init_update_queries(void)
|
|||||||
/* Initialize the server command flags array. */
|
/* Initialize the server command flags array. */
|
||||||
memset(server_command_flags, 0, sizeof(server_command_flags));
|
memset(server_command_flags, 0, sizeof(server_command_flags));
|
||||||
|
|
||||||
server_command_flags[COM_STATISTICS]= CF_SKIP_QUERY_ID | CF_SKIP_QUESTIONS;
|
server_command_flags[COM_STATISTICS]= CF_SKIP_QUERY_ID | CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
|
||||||
server_command_flags[COM_PING]= CF_SKIP_QUERY_ID | CF_SKIP_QUESTIONS;
|
server_command_flags[COM_PING]= CF_SKIP_QUERY_ID | CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
|
||||||
server_command_flags[COM_STMT_PREPARE]= CF_SKIP_QUESTIONS;
|
server_command_flags[COM_STMT_PREPARE]= CF_SKIP_QUESTIONS;
|
||||||
server_command_flags[COM_STMT_CLOSE]= CF_SKIP_QUESTIONS;
|
server_command_flags[COM_STMT_CLOSE]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
|
||||||
server_command_flags[COM_STMT_RESET]= CF_SKIP_QUESTIONS;
|
server_command_flags[COM_STMT_RESET]= CF_SKIP_QUESTIONS | CF_SKIP_WSREP_CHECK;
|
||||||
|
|
||||||
|
server_command_flags[COM_QUIT]= CF_SKIP_WSREP_CHECK;
|
||||||
|
server_command_flags[COM_PROCESS_INFO]= CF_SKIP_WSREP_CHECK;
|
||||||
|
server_command_flags[COM_PROCESS_KILL]= CF_SKIP_WSREP_CHECK;
|
||||||
|
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_END]= CF_SKIP_WSREP_CHECK;
|
||||||
|
|
||||||
|
/*
|
||||||
|
COM_QUERY and COM_SET_OPTION are allowed to pass the early COM_xxx filter,
|
||||||
|
they're checked later in mysql_execute_command().
|
||||||
|
*/
|
||||||
|
server_command_flags[COM_QUERY]= CF_SKIP_WSREP_CHECK;
|
||||||
|
server_command_flags[COM_SET_OPTION]= CF_SKIP_WSREP_CHECK;
|
||||||
|
|
||||||
/* Initialize the sql command flags array. */
|
/* Initialize the sql command flags array. */
|
||||||
memset(sql_command_flags, 0, sizeof(sql_command_flags));
|
memset(sql_command_flags, 0, sizeof(sql_command_flags));
|
||||||
@ -874,9 +889,11 @@ void cleanup_items(Item *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef WITH_WSREP
|
#ifndef EMBEDDED_LIBRARY
|
||||||
|
|
||||||
static bool wsrep_node_is_ready(THD *thd)
|
static bool wsrep_node_is_ready(THD *thd)
|
||||||
{
|
{
|
||||||
|
#ifdef WITH_WSREP
|
||||||
if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready)
|
if (thd->variables.wsrep_on && !thd->wsrep_applier && !wsrep_ready)
|
||||||
{
|
{
|
||||||
my_message(ER_UNKNOWN_COM_ERROR,
|
my_message(ER_UNKNOWN_COM_ERROR,
|
||||||
@ -884,12 +901,9 @@ static bool wsrep_node_is_ready(THD *thd)
|
|||||||
MYF(0));
|
MYF(0));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef EMBEDDED_LIBRARY
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read one command from connection and execute it (query or simple command).
|
Read one command from connection and execute it (query or simple command).
|
||||||
@ -1069,29 +1083,13 @@ bool do_command(THD *thd)
|
|||||||
vio_description(net->vio), command,
|
vio_description(net->vio), command,
|
||||||
command_name[command].str));
|
command_name[command].str));
|
||||||
|
|
||||||
if (WSREP(thd))
|
/* bail out if DB snapshot has not been installed. */
|
||||||
|
if (!(server_command_flags[command] & CF_SKIP_WSREP_CHECK) &&
|
||||||
|
!wsrep_node_is_ready(thd))
|
||||||
{
|
{
|
||||||
/*
|
thd->protocol->end_statement();
|
||||||
* bail out if DB snapshot has not been installed. We however,
|
return_value= FALSE;
|
||||||
* allow queries "SET" and "SHOW", they are trapped later in execute_command
|
goto out;
|
||||||
*/
|
|
||||||
if (command != COM_QUERY &&
|
|
||||||
command != COM_PING &&
|
|
||||||
command != COM_QUIT &&
|
|
||||||
command != COM_PROCESS_INFO &&
|
|
||||||
command != COM_PROCESS_KILL &&
|
|
||||||
command != COM_SET_OPTION &&
|
|
||||||
command != COM_SHUTDOWN &&
|
|
||||||
command != COM_SLEEP &&
|
|
||||||
command != COM_STATISTICS &&
|
|
||||||
command != COM_TIME &&
|
|
||||||
command != COM_END &&
|
|
||||||
!wsrep_node_is_ready(thd))
|
|
||||||
{
|
|
||||||
thd->protocol->end_statement();
|
|
||||||
return_value= FALSE;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* Restore read timeout value */
|
/* Restore read timeout value */
|
||||||
my_net_set_read_timeout(net, thd->variables.net_read_timeout);
|
my_net_set_read_timeout(net, thd->variables.net_read_timeout);
|
||||||
|
Reference in New Issue
Block a user