mysql readview错误?

发布于 2025-01-20 13:21:49 字数 668 浏览 5 评论 0原文

这是一个关于 MySQL 8.0 源代码中 InnoDB 存储引擎内部代码的问题。

在 'ReadView::prepare' 方法(文件 read/read0read.c)中:

m_up_limit_id = !m_ids.empty() ? m_ids.front() : m_low_limit_id;

在 'changes_visible' 方法(文件 include/read0types.h)中:

if (id < m_up_limit_id || id == m_creator_trx_id) {
  return (true);
}
...
if (id >= m_low_limit_id) {
 return (false);
} else if (m_ids.empty()) {
  return (true);
}

m_ids.empty() 的逻辑没有用,id 不能小于 m_up_limit_id 且大于或等于 m_low_limit_id,因为m_ids.empty(),然后m_up_limit_id == m_low_limit_id,不知道我的理解是否准确,希望得到答案

This is a question about code internal to the InnoDB storage engine in MySQL 8.0 source.

In the 'ReadView::prepare' method (file read/read0read.c):

m_up_limit_id = !m_ids.empty() ? m_ids.front() : m_low_limit_id;

in the 'changes_visible' method (file include/read0types.h):

if (id < m_up_limit_id || id == m_creator_trx_id) {
  return (true);
}
...
if (id >= m_low_limit_id) {
 return (false);
} else if (m_ids.empty()) {
  return (true);
}

The logic of m_ids.empty() is useless, id cannot be less than m_up_limit_id and greater than or equal to m_low_limit_id, because m_ids.empty(), then m_up_limit_id == m_low_limit_id, I don't know if my understanding is accurate, I hope to get an answer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小糖芽 2025-01-27 13:21:49

我认为调用empty()很重要。一组活动交易可能是空的。换句话说,在没有主动交易的时候准备了ReadView。

如果是这种情况,则front()函数无法返回有效的事务ID。 front()中的代码如果在空集中调用了调试声明。

I think the call to empty() is important. The set of active transactions might be empty. In other words, the ReadView is prepared at a time when there are no active transactions.

If that is the case, the front() function cannot return a valid transaction id. The code in front() throws a debug assertion if it is called on an empty set.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文