Skip to content

fix(mysql): preserve temporary tables in client session pools#1531

Merged
t8y2 merged 1 commit into
t8y2:mainfrom
chenhbb:codex/fix-mysql-temp-table-session
Jun 21, 2026
Merged

fix(mysql): preserve temporary tables in client session pools#1531
t8y2 merged 1 commit into
t8y2:mainfrom
chenhbb:codex/fix-mysql-temp-table-session

Conversation

@chenhbb

@chenhbb chenhbb commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Disable COM_RESET_CONNECTION for single-connection session pools (max_connections == 1) so that MySQL session state such as TEMPORARY TABLEs is not cleared when a connection is returned to the pool.

Closes #1509

变更说明

在同一个 client session 中分步执行 SQL 时,创建的临时表在后续查询中报不存在。

根因:mysql_async 连接池默认在连接归还时发送 COM_RESET_CONNECTION,该命令会清除所有临时表及 session 状态。即使 session 池已限制 max_connections = 1(确保复用同一物理连接),reset 仍会销毁临时表。

修复:在 create_pool 中,当 max_connections == 1(即 client session 池)时,设置 .with_reset_connection(false) 跳过 COM_RESET_CONNECTION,保留临时表等 session 状态。非 session 池(max_connections > 1)行为不变。

变更类型

  • 新功能
  • Bug 修复
  • 性能优化
  • 代码重构
  • 文档更新
  • CI / 构建

涉及前端

  • 本 PR 不涉及前端改动

验证

  • cargo check --no-default-features 通过
  • 相关测试通过(cargo test -p dbx-core:1037 passed, 0 failed)

关联 Issue

Close #1509

Disable COM_RESET_CONNECTION for single-connection session pools
(max_connections == 1) so that MySQL session state such as TEMPORARY
TABLEs is not cleared when a connection is returned to the pool.

Closes t8y2#1509
@t8y2 t8y2 merged commit 4e07f73 into t8y2:main Jun 21, 2026
4 checks passed
@t8y2

t8y2 commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐞 Bug] 同一个session,创建临时表后再查询会提示不存在。

2 participants