Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: advisor panic error (#14369)
rebelicef6c59fa2ffe9
diff --git a/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go b/backend/plugin/advisor/mysql/advisor_function_disallowed_list.goindex 4d1c63b912..0445d31917 100644--- a/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go+++ b/backend/plugin/advisor/mysql/advisor_function_disallowed_list.go@@ -75,7 +75,7 @@ func (checker *functionDisallowedListChecker) EnterQuery(ctx *mysql.QueryContextfunc (checker *functionDisallowedListChecker) EnterFunctionCall(ctx *mysql.FunctionCallContext) {pi := ctx.PureIdentifier()if pi != nil {- functionName := pi.IDENTIFIER().GetText()+ functionName := mysqlparser.NormalizeMySQLPureIdentifier(pi)if slices.Contains(checker.disallowList, strings.ToUpper(functionName)) {checker.adviceList = append(checker.adviceList, &storepb.Advice{Status: checker.level,diff --git a/backend/plugin/parser/mysql/normalize.go b/backend/plugin/parser/mysql/normalize.goindex 1bf6da7bd3..f38def0322 100644--- a/backend/plugin/parser/mysql/normalize.go+++ b/backend/plugin/parser/mysql/normalize.go@@ -90,6 +90,18 @@ func NormalizeMySQLIdentifier(identifier parser.IIdentifierContext) string {return identifier.GetText()}+func NormalizeMySQLPureIdentifier(pureIdentifier parser.IPureIdentifierContext) string {+ if pureIdentifier.IDENTIFIER() != nil {+ return pureIdentifier.IDENTIFIER().GetText()+ }+ if pureIdentifier.BACK_TICK_QUOTED_ID() == nil {+ // For back tick quoted identifier, we need to remove the back tick.+ text := pureIdentifier.BACK_TICK_QUOTED_ID().GetText()+ return text[1 : len(text)-1]+ }+ return pureIdentifier.GetText()+}+// NormalizeMySQLTextOrIdentifier normalizes the given TextOrIdentifier.func NormalizeMySQLTextOrIdentifier(ctx parser.ITextOrIdentifierContext) string {if ctx.Identifier() != nil {