Skip to content

FillingSQLWithParamMarker 添加对非MySQL数据库类型的错误处理,确保遇到其他数据库类型快速返回 #3096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

waterdrink
Copy link
Collaborator

@waterdrink waterdrink commented Jul 24, 2025

User description

FillingSQLWithParamMarker 添加对非MySQL数据库类型的错误处理,确保遇到其他数据库类型快速返回

关联的 issue

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

描述你的变更

确认项(pr提交后操作)

Tip

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


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


Description

  • 为非 MySQL 数据库快速返回错误

  • 添加错误提示机制

  • 提升 SQL 解析逻辑健壮性


Diagram Walkthrough

flowchart LR
  A["原始 SQL 解析流程"] --> B["判断数据库类型"]
  B -- "非 MySQL" --> C["返回错误提示"]
Loading

File Walkthrough

Relevant files
Bug fix
fill_sql.go
添加非 MySQL 错误返回处理                                                                                 

sqle/server/fillsql/fill_sql.go

  • 新增数据库类型判断逻辑
  • 针对非 MySQL 返回错误
+3/-0     

FillingSQLWithParamMarker 添加对非MySQL数据库类型的错误处理,确保遇到其他数据库类型快速返回
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
添加空指针检查

建议在访问 task.DBType 之前先检查 task 是否为 nil,以防止因空指针引用而导致应用崩溃。这是一个关键性问题,及时增强判断逻辑可以提高程序的健壮性。

sqle/server/fillsql/fill_sql.go [30-32]

+if task == nil {
+	return sqlContent, fmt.Errorf("task is nil")
+}
 if task.DBType != v2.DriverTypeMySQL {
 	return sqlContent, fmt.Errorf("fill sql with param marker unsupported database type: %s, only MySQL is supported", task.DBType)
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly enhances code robustness by introducing a nil check for task to prevent potential nil pointer dereferences before accessing task.DBType. Given the critical nature of error handling, this is an important improvement.

Medium

@winfredLIN winfredLIN merged commit dd9842d into main Jul 24, 2025
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