Skip to content

Commit e9ffed0

Browse files
committed
MDEV-25973: fixed the test plugins.test_sql_service
Set the data member THD::m_prepare_observer temporary to nullptr to avoid running a handler when a table version in TABLE_LIST differs from a value of version in TABLE_SHARE. It happens for any table when the method Ed_connection::execute_direct() is called from execute_sql_command() since the data members TABLE_LIST::m_table_ref_type and TABLES_LIST::m_table_ref_version have zero values on opening a table but corresponding members of TABLE_SHARE doesn't have. If the function execute_sql_command() is called on handling a Prepared statement it results in issuing the error ER_NEED_REPREPARE that is not issued in case the statement is run in regular way. So, to make fix the issue reset the data member THD::m_prepare_observer before running Ed_connection::execute_direct() and restoring it on return.
1 parent 675b72d commit e9ffed0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sql/sql_prepare.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6093,6 +6093,7 @@ extern "C" int execute_sql_command(const char *command,
60936093
THD *new_thd= 0;
60946094
int result;
60956095
my_bool qc_save= 0;
6096+
Reprepare_observer *save_reprepare_observer= nullptr;
60966097

60976098
if (!thd)
60986099
{
@@ -6113,6 +6114,8 @@ extern "C" int execute_sql_command(const char *command,
61136114

61146115
qc_save= thd->query_cache_is_applicable;
61156116
thd->query_cache_is_applicable= 0;
6117+
save_reprepare_observer= thd->m_reprepare_observer;
6118+
thd->m_reprepare_observer= nullptr;
61166119
}
61176120
sql_text.str= (char *) command;
61186121
sql_text.length= strlen(command);
@@ -6150,7 +6153,10 @@ extern "C" int execute_sql_command(const char *command,
61506153
if (new_thd)
61516154
delete new_thd;
61526155
else
6156+
{
61536157
thd->query_cache_is_applicable= qc_save;
6158+
thd->m_reprepare_observer= save_reprepare_observer;
6159+
}
61546160

61556161
*hosts= 0;
61566162
return result;

0 commit comments

Comments
 (0)