Skip to content

feat: MySQL CTE positive support via sjjian/parser merge tip - #3368

Merged
iwanghc merged 3 commits into
mainfrom
sqle/feat-3050
Aug 26, 2026
Merged

iwanghc merged 3 commits into
mainfrom
sqle/feat-3050

Conversation

@LordofAvernus

@LordofAvernus LordofAvernus commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

User description

关联的 issue

https://github.com/actiontech/sqle-ee/issues/3050

描述你的变更

  • pingcap/parser replace 钉到 sjjian/parser@v0.0.0-20260825094816-b6aefd90e347(主干 CTE 合并伪版本),并 go mod vendor 再生
  • 审阅提示:父提交曾空 commit 声称钉 tip,本 tip 59844f2 才真正落盘 CTE parser;go mod tidy 旁路剔除未使用的 gohive 传递依赖,属预期而非无关大删
  • 新增 CTE 门禁单测(AST / 空规则集审核无 unsupported / sql_type 三态 / 非回归),不改审核业务开关
  • 取代说明:以 parser 正支持 + 已发布模块引用,取代剥离 WITH 只解析外层(历史 sqle#3355)与业务仓 third_party/parser 终态(sqle#3357 / sqle-ee#3057);本 PR 无 splitter/cte.go、无 ./third_party/parsergo mod tidy 旁路剔除未使用的 gohive 传递依赖

Fixes https://github.com/actiontech/sqle-ee/issues/3050

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 替换依赖至 sjjian/parser 版本,支持CTE正向解析

  • 添加多项CTE单元测试覆盖审计、SQL类型和AST解析

  • 更新 go.mod,剔除未使用依赖并调整版本映射


Diagram Walkthrough

flowchart LR
  A["更新go.mod依赖"] --> B["新增CTE相关测试"]
  B --> C["支持CTE正向解析"]
Loading

File Walkthrough

Relevant files
Tests
cte_audit_test.go
新增 CTE 审计测试                                                                                           

sqle/driver/mysql/cte_audit_test.go

  • 添加合法CTE审计单元测试
  • 验证合法CTE不触发警告消息
  • 结合上下文执行SQL审计
+53/-0   
cte_non_regression_test.go
新增 CTE 非回归测试                                                                                         

sqle/driver/mysql/cte_non_regression_test.go

  • 增加非法SQL和GRANT语句回归测试
  • 确保非法SQL保持合理的警告提示
  • 防止GRANT误解析为CTE
+75/-0   
cte_sql_type_test.go
CTE SQL类型测试                                                                                           

sqle/driver/mysql/cte_sql_type_test.go

  • 检查CTE与DML/DDL SQL类型转换
  • 验证三种SQL状态分类的准确性
+47/-0   
cte_ast_test.go
CTE AST解析测试                                                                                           

sqle/driver/mysql/util/cte_ast_test.go

  • 验证CTE AST正向解析正确性
  • 测试非递归和递归CTE解析
  • 校验CTE中DELETE语句的处理
+105/-0 
Dependencies
go.mod
更新 go.mod 依赖                                                                                         

go.mod

  • 替换 github.com/pingcap/parser 为新版本
  • 移除未使用的 github.com/beltran/gohive 依赖
+1/-6     

Lock AC-004/005/006/009 against parser CTE positive support without changing audit business switches.
Pin replace to sjjian/parser@v0.0.0-20260825094816-b6aefd90e347 (merged CTE support), regenerate vendor via go mod; tidy drops unused gohive transitive chain.
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 59844f2)

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

Retarget pingcap/parser replace to sjjian/parser@v0.0.0-20260825094816-b6aefd90e347
and regenerate vendor so SelectStmt.With exists; restore EnvironmentTag.Color
after vendor; use context.TODO in CTE Audit tests for SA1012.
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 59844f2

@iwanghc
iwanghc merged commit 449fe66 into main Aug 26, 2026
4 checks passed
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.

2 participants