在sql执行的过程中会调用 @param end_records true when we need to perform final steps of retrival
sub_select(JOIN *join, QEP_TAB *const qep_tab,bool end_of_records)
在取数据的时候分了2步,一次是0,一次是1,不太清楚为什么分2步,true的时候会执行
if (end_of_records)
{
enum_nested_loop_state nls=
(qep_tab->next_select)(join,qep_tab+1,end_of_records);
DBUG_RETURN(nls);
}
在执行完取数后,针对非update语句释放锁
{
/
The following will unlock all cursors if the command wasn’t an
update command
*/
join->join_free(); // Unlock all cursors
}
sqlparser中在执行了sql后trans_commit_stmt(thd);进行提交事务close_thread_tables(thd);关闭表,thd->mdl_context.release_transactional_locks();释放mdl锁
if (!res && !thd->is_error()) { // if statement succeeded
binlog_gtid_end_transaction(thd); // finalize GTID life-cycle
不管配没配gtid,都是启用的?接着就是清理
thd->end_statement();
thd->cleanup_after_query();
线程环境重置
sql在执行的时候,sql的内容是放到thd里面的,如果thd放不下sql内容报错
case COM_QUERY:
{
DBUG_ASSERT(thd->m_digest == NULL);
thd->m_digest= & thd->m_digest_state;
thd->m_digest->reset(thd->m_token_array, max_digest_length);
if (alloc_query(thd, com_data->com_query.query,
com_data->com_query.length))
break; // fatal error is set
然后在进行sqlparser