Skip to content

Commit

Permalink
Add Statement::sql_command_flags() function.
Browse files Browse the repository at this point in the history
Now one can call thd->sql_command_flags() instead of
sql_command_flags[thd->lex->sql_command].
  • Loading branch information
FooBarrior authored and sanja-byelkin committed Feb 12, 2024
1 parent 4246c0f commit 62d35a0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
12 changes: 5 additions & 7 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
/*
Expand All @@ -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
*/
Expand Down
6 changes: 6 additions & 0 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,8 @@ struct send_column_info_state
}
};

extern uint sql_command_flags[];


/**
@class Statement
Expand Down Expand Up @@ -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.
Expand Down
17 changes: 8 additions & 9 deletions sql/sql_prepare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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())
Expand Down Expand Up @@ -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));
Expand All @@ -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
Expand Down Expand Up @@ -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))
{
Expand All @@ -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);
Expand All @@ -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))
{
Expand All @@ -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())
Expand Down

0 comments on commit 62d35a0

Please sign in to comment.