mysql中的sql执行

在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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值