Skip to content

feat: support Redis SQL workbench datasource #2902#638

Closed
LordofAvernus wants to merge 1 commit into
mainfrom
dev/redis-plugin-2902
Closed

feat: support Redis SQL workbench datasource #2902#638
LordofAvernus wants to merge 1 commit into
mainfrom
dev/redis-plugin-2902

Conversation

@LordofAvernus

@LordofAvernus LordofAvernus commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add DBTypeRedis and ParseDBType("Redis") in DMS CE.
  • Map Redis datasources to ODC REDIS with defaultSchema and jdbcUrlParameters for SQL workbench sync.

Related

Test plan

  • go vet ./internal/dms/pkg/constant/... ./internal/sql_workbench/service/...
  • DMS registers Redis datasource and syncs to ODC workbench

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

潜在的空指针风险

在 buildRedisDatasourceOptions 函数中,对一些参数(例如 redisTLSInsecureParam)的获取未作 nil 检查。如果对应的参数不存在,直接调用其方法可能会导致 nil dereference,从而引发 panic。建议在调用 .Bool() 前,先验证参数是否存在。

if dbService.AdditionalParams.GetParam(redisTLSInsecureParam).Bool() {

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
增加 nil 检查以防止 panic

建议在调用 .Bool() 方法前先对获取的参数进行 nil 检查,以防止在参数不存在时发生 nil 指针解引用导致 panic。此问题可能导致系统崩溃,需要及时修正。

internal/sql_workbench/service/sql_workbench_service.go [1077-1078]

-if dbService.AdditionalParams.GetParam(redisTLSInsecureParam).Bool() {
+if param := dbService.AdditionalParams.GetParam(redisTLSInsecureParam); param != nil && param.Bool() {
 		jdbcParams["tlsInsecure"] = true
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly adds a nil check for dbService.AdditionalParams.GetParam(redisTLSInsecureParam) to avoid a potential panic on nil dereference. It improves robustness, though such error handling changes are typically capped at 8.

Medium
检查 nil 防止 panic

请为对 redisScanCountParam、redisKeySeparatorParam 和 redisCommandTimeoutParam 的
.String() 调用添加 nil 检查,以保证在参数缺失时不会触发 nil 调用引发 panic。处理空值可以避免潜在的程序崩溃问题。

internal/sql_workbench/service/sql_workbench_service.go [1080-1087]

-if scanCount := dbService.AdditionalParams.GetParam(redisScanCountParam).String(); scanCount != "" {
-		jdbcParams["scanCount"] = scanCount
+if param := dbService.AdditionalParams.GetParam(redisScanCountParam); param != nil {
+		if scanCount := param.String(); scanCount != "" {
+			jdbcParams["scanCount"] = scanCount
+		}
 }
-if keySeparator := dbService.AdditionalParams.GetParam(redisKeySeparatorParam).String(); keySeparator != "" {
-		jdbcParams["keySeparator"] = keySeparator
+if param := dbService.AdditionalParams.GetParam(redisKeySeparatorParam); param != nil {
+		if keySeparator := param.String(); keySeparator != "" {
+			jdbcParams["keySeparator"] = keySeparator
+		}
 }
-if timeout := dbService.AdditionalParams.GetParam(redisCommandTimeoutParam).String(); timeout != "" {
-		jdbcParams["commandTimeoutMs"] = timeout
+if param := dbService.AdditionalParams.GetParam(redisCommandTimeoutParam); param != nil {
+		if timeout := param.String(); timeout != "" {
+			jdbcParams["commandTimeoutMs"] = timeout
+		}
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion introduces nil checks before calling .String() for redisScanCountParam, redisKeySeparatorParam, and redisCommandTimeoutParam, which prevents potential runtime panics. This change enhances error safety in the code.

Medium

@LordofAvernus LordofAvernus deleted the dev/redis-plugin-2902 branch June 11, 2026 08:18
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.

1 participant