Commit 62d35a07 authored by Nikita Malyavin's avatar Nikita Malyavin Committed by Oleksandr Byelkin

Add Statement::sql_command_flags() function.

Now one can call thd->sql_command_flags() instead of
sql_command_flags[thd->lex->sql_command].
parent 4246c0fa
......@@ -1341,7 +1341,7 @@ void THD::update_stats(void)
/* A SQL query. */
if (lex->sql_command == SQLCOM_SELECT)
select_commands++;
else if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND)
else if (sql_command_flags() & CF_STATUS_COMMAND)
{
/* Ignore 'SHOW ' commands */
}
......@@ -6651,8 +6651,8 @@ int THD::decide_logging_format(TABLE_LIST *tables)
blackhole_table_found= 1;
if (share->non_determinstic_insert &&
(sql_command_flags[lex->sql_command] & CF_CAN_GENERATE_ROW_EVENTS
&& !(sql_command_flags[lex->sql_command] & CF_SCHEMA_CHANGE)))
(sql_command_flags() & CF_CAN_GENERATE_ROW_EVENTS
&& !(sql_command_flags() & CF_SCHEMA_CHANGE)))
has_write_tables_with_unsafe_statements= true;
trans= table->file->has_transactions();
......@@ -6901,8 +6901,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
if (blackhole_table_found &&
variables.binlog_format == BINLOG_FORMAT_ROW &&
(sql_command_flags[lex->sql_command] &
(CF_UPDATES_DATA | CF_DELETES_DATA)))
(sql_command_flags() & (CF_UPDATES_DATA | CF_DELETES_DATA)))
{
String table_names;
/*
......@@ -6922,8 +6921,7 @@ int THD::decide_logging_format(TABLE_LIST *tables)
}
if (!table_names.is_empty())
{
bool is_update= MY_TEST(sql_command_flags[lex->sql_command] &
CF_UPDATES_DATA);
bool is_update= MY_TEST(sql_command_flags() & CF_UPDATES_DATA);
/*
Replace the last ',' with '.' for table_names
*/
......
......@@ -1489,6 +1489,8 @@ struct send_column_info_state
}
};
extern uint sql_command_flags[];
/**
@class Statement
......@@ -1569,6 +1571,10 @@ class Statement: public ilink, public Query_arena
{
set_query_inner(CSET_STRING());
}
ulong sql_command_flags() const
{
return ::sql_command_flags[lex->sql_command];
}
/**
Name of the current (default) database.
......
......@@ -4451,7 +4451,7 @@ Prepared_statement::execute_loop(String *expanded_query,
the error stack.
*/
if (sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE)
if (sql_command_flags() & CF_REEXECUTION_FRAGILE)
{
reprepare_observer.reset_reprepare_observer();
DBUG_ASSERT(thd->m_reprepare_observer == NULL);
......@@ -4463,7 +4463,7 @@ Prepared_statement::execute_loop(String *expanded_query,
thd->m_reprepare_observer= NULL;
if (unlikely(error) &&
(sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE) &&
(sql_command_flags() & CF_REEXECUTION_FRAGILE) &&
!thd->is_fatal_error && !thd->killed &&
reprepare_observer.is_invalidated() &&
reprepare_observer.can_retry())
......@@ -4578,7 +4578,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
goto err;
}
if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_SAFE))
if (!(sql_command_flags() & CF_PS_ARRAY_BINDING_SAFE))
{
DBUG_PRINT("error", ("Command is not supported in bulk execution."));
my_error(ER_UNSUPPORTED_PS, MYF(0));
......@@ -4588,7 +4588,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
Here second buffer for not optimized commands,
optimized commands do it inside thier internal loop.
*/
if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_OPTIMIZED) &&
if (!(sql_command_flags() & CF_PS_ARRAY_BINDING_OPTIMIZED) &&
this->lex->has_returning())
{
// Above check can be true for SELECT in future
......@@ -4621,7 +4621,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
Here we set parameters for not optimized commands,
optimized commands do it inside thier internal loop.
*/
if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_OPTIMIZED))
if (!(sql_command_flags() & CF_PS_ARRAY_BINDING_OPTIMIZED))
{
if (set_bulk_parameters(TRUE))
{
......@@ -4644,7 +4644,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
the error stack.
*/
if (sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE)
if (sql_command_flags() & CF_REEXECUTION_FRAGILE)
{
reprepare_observer.reset_reprepare_observer();
DBUG_ASSERT(thd->m_reprepare_observer == NULL);
......@@ -4656,8 +4656,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
thd->m_reprepare_observer= NULL;
#ifdef WITH_WSREP
if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_OPTIMIZED) &&
WSREP(thd))
if (!(sql_command_flags() & CF_PS_ARRAY_BINDING_OPTIMIZED) && WSREP(thd))
{
if (wsrep_after_statement(thd))
{
......@@ -4673,7 +4672,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
else
#endif /* WITH_WSREP */
if (unlikely(error) &&
(sql_command_flags[lex->sql_command] & CF_REEXECUTION_FRAGILE) &&
(sql_command_flags() & CF_REEXECUTION_FRAGILE) &&
!thd->is_fatal_error && !thd->killed &&
reprepare_observer.is_invalidated() &&
reprepare_observer.can_retry())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment