Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(advisor): remove unused NormalizeStatement function (#18621)
h3n4l511fe2359328
diff --git a/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go b/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.goindex 7cedfbbd74..f03b0414b6 100644--- a/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go+++ b/backend/plugin/advisor/pg/advisor_statement_affected_row_limit.go@@ -156,7 +156,6 @@ func (r *statementAffectedRowLimitRule) checkAffectedRows(ctx antlr.ParserRuleCo// Get the statement textstatementText := getTextFromTokens(r.tokens, ctx)- normalizedStmt := advisor.NormalizeStatement(statementText)// Run EXPLAIN to get estimated row countres, err := advisor.Query(r.ctx, advisor.QueryContext{@@ -169,7 +168,7 @@ func (r *statementAffectedRowLimitRule) checkAffectedRows(ctx antlr.ParserRuleCoStatus: r.level,Code: code.InsertTooManyRows.Int32(),Title: r.title,- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", normalizedStmt, err.Error()),+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", statementText, err.Error()),StartPosition: &storepb.Position{Line: int32(ctx.GetStart().GetLine()),Column: 0,@@ -184,7 +183,7 @@ func (r *statementAffectedRowLimitRule) checkAffectedRows(ctx antlr.ParserRuleCoStatus: r.level,Code: code.Internal.Int32(),Title: r.title,- Content: fmt.Sprintf("failed to get row count for \"%s\": %s", normalizedStmt, err.Error()),+ Content: fmt.Sprintf("failed to get row count for \"%s\": %s", statementText, err.Error()),StartPosition: &storepb.Position{Line: int32(ctx.GetStart().GetLine()),Column: 0,@@ -198,7 +197,7 @@ func (r *statementAffectedRowLimitRule) checkAffectedRows(ctx antlr.ParserRuleCoStatus: r.level,Code: code.StatementAffectedRowExceedsLimit.Int32(),Title: r.title,- Content: fmt.Sprintf("The statement \"%s\" affected %d rows (estimated). The count exceeds %d.", normalizedStmt, rowCount, r.maxRow),+ Content: fmt.Sprintf("The statement \"%s\" affected %d rows (estimated). The count exceeds %d.", statementText, rowCount, r.maxRow),StartPosition: &storepb.Position{Line: int32(ctx.GetStart().GetLine()),Column: 0,diff --git a/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go b/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.goindex 6a67562539..f8f96ba81e 100644--- a/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go+++ b/backend/plugin/advisor/pg/advisor_statement_dml_dry_run.go@@ -153,7 +153,6 @@ func (r *statementDMLDryRunRule) checkDMLDryRun(ctx antlr.ParserRuleContext) {r.explainCount++statementText := getTextFromTokens(r.tokens, ctx)- normalizedStmt := advisor.NormalizeStatement(statementText)// Run EXPLAIN to perform dry run_, err := advisor.Query(r.ctx, advisor.QueryContext{@@ -166,7 +165,7 @@ func (r *statementDMLDryRunRule) checkDMLDryRun(ctx antlr.ParserRuleContext) {Status: r.level,Code: code.StatementDMLDryRunFailed.Int32(),Title: r.title,- Content: fmt.Sprintf("\"%s\" dry runs failed: %s", normalizedStmt, err.Error()),+ Content: fmt.Sprintf("\"%s\" dry runs failed: %s", statementText, err.Error()),StartPosition: &storepb.Position{Line: int32(ctx.GetStart().GetLine()),Column: 0,diff --git a/backend/plugin/advisor/utils.go b/backend/plugin/advisor/utils.goindex 14b1a994e5..b0fb9a9ae9 100644--- a/backend/plugin/advisor/utils.go+++ b/backend/plugin/advisor/utils.go@@ -13,15 +13,6 @@ import (storepb "github.com/bytebase/bytebase/backend/generated-go/store")-// NormalizeStatement limit the max length of the statements.-func NormalizeStatement(statement string) string {- maxLength := 1000- if len(statement) > maxLength {- return statement[:maxLength] + "..."- }- return statement-}-type QueryContext struct {TenantMode boolPreExecutions []string