Skip to content

Conversation

@Song-Quan
Copy link
Collaborator

当前使用了 InfoSchema 但是其实不需要的:

  • Grant/Revoke
  • Create/Drop Database
  • Create/Drop Table
  • Show columns / Describe
  • Drop/Alter User

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Song-Quan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在通过消除各种DDL和DCL操作以及SHOW COLUMNS/DESCRIBE语句对InfoSchema的不必要依赖,来优化其性能并降低开销。通过允许这些操作直接查询存储或使用其自身的验证机制,系统可以避免加载可能庞大的InfoSchema对象,从而实现更高效的执行。

Highlights

  • 减少InfoSchema依赖: 多个DDL(如CREATE/DROP DATABASE, CREATE/DROP TABLE, ALTER/DROP USER)和DCL(GRANT/REVOKE)操作不再需要InfoSchema来执行,而是直接依赖存储查询或内部验证逻辑。
  • 优化SHOW COLUMNS/DESCRIBE语句: SHOW COLUMNS和DESCRIBE语句现在已优化,可以直接从存储中获取列信息,从而在预处理阶段绕过InfoSchema查找。
  • 引入新的预处理器标志: 预处理器中新增了一个inShowColumns标志,用于正确识别SHOW COLUMNS和DESCRIBE语句,使其能够跳过InfoSchema检查。
  • 增强测试覆盖率: 新增了submit_handler_test.go测试文件,包含全面的测试用例,以验证isQueryNeedInfoSchema函数能够正确识别不需要InfoSchema的查询。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Song-Quan Song-Quan marked this pull request as ready for review December 30, 2025 02:31
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次代码审查主要关注了为优化 DDL 操作而进行的修改,这些修改旨在减少对 InfoSchema 的依赖。整体来看,PR 的目标明确,实现方式合理。主要改动包括:

  1. preprocess.go 中为 SHOW COLUMNS 语句添加了新的标志,以在预处理阶段跳过表名解析。
  2. executor/show.go 中,修改了 fetchShowColumns 函数,使其直接从底层存储查询列的元数据,而不是依赖 InfoSchema。
  3. server/submit_handler.go 中,扩展了 isQueryNeedInfoSchema 函数,以识别更多可以绕过加载 InfoSchema 的 DDL 语句。
  4. isQueryNeedInfoSchema 函数添加了全面的单元测试,确保了逻辑的正确性。

这些改动是有效的,并且有对应的测试覆盖。我提出了一些小的建议,主要涉及代码风格和错误处理,以期提高代码的可读性和健壮性。

Song-Quan and others added 2 commits December 30, 2025 11:16
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
if showStmt, ok := s.Stmt.(*ast.ShowStmt); ok && showStmt.Tp == ast.ShowColumns {
return false, nil
}
return true, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

针对其它需要infoSchema的场景,如果db/table过多,应该还是会很慢,会有业务影响吗?以及有改进思路吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

会有影响,可以考虑增加 cache 或者在加载 infoschema 的时候,如果 db 过多,就选择全表扫描。
这个可以后面再提 pr

@Song-Quan Song-Quan requested a review from a team January 5, 2026 03:10
@Song-Quan Song-Quan mentioned this pull request Jan 6, 2026
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.

3 participants