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(sql-review): fix line number for MySQL sql review rule (#14191)
rebeliceca846a008cc8
diff --git a/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.goindex 6c51bfc80b..ea88490eea 100644--- a/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go@@ -59,7 +59,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([Content: "Prior backup cannot deal with mixed DDL and DML statements",Code: advisor.BuiltinPriorBackupCheck.Int32(),StartPosition: &storepb.Position{- Line: int32(stmt.BaseLine),+ Line: int32(stmt.BaseLine) + 1,},})}@@ -72,7 +72,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([Content: fmt.Sprintf("Need database %q to do prior backup but it does not exist", ctx.PreUpdateBackupDetail.Database),Code: advisor.DatabaseNotExists.Int32(),StartPosition: &storepb.Position{- Line: 0,+ Line: 1,},})}@@ -90,7 +90,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx advisor.Context, _ string) ([Content: fmt.Sprintf("Prior backup is feasible only with up to %d statements that are either UPDATE or DELETE, or if all UPDATEs target the same table with a PRIMARY or UNIQUE KEY in the WHERE clause", maxMixedDMLCount),Code: advisor.BuiltinPriorBackupCheck.Int32(),StartPosition: &storepb.Position{- Line: 0,+ Line: 1,},})}diff --git a/backend/plugin/advisor/mysql/advisor_naming_identifier_no_keyword.go b/backend/plugin/advisor/mysql/advisor_naming_identifier_no_keyword.goindex 98d098bca1..77409ef054 100644--- a/backend/plugin/advisor/mysql/advisor_naming_identifier_no_keyword.go+++ b/backend/plugin/advisor/mysql/advisor_naming_identifier_no_keyword.go@@ -70,7 +70,9 @@ func (checker *namingIdentifierNoKeywordChecker) EnterPureIdentifier(ctx *mysql.identifier := trimBackTicks(textNode.GetText())advice := checker.checkIdentifier(identifier)if advice != nil {- advice.StartPosition = &storepb.Position{Line: int32(ctx.GetStart().GetLine())}+ advice.StartPosition = &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ }checker.adviceList = append(checker.adviceList, advice)}}@@ -80,7 +82,9 @@ func (checker *namingIdentifierNoKeywordChecker) EnterIdentifierKeyword(ctx *mysidentifier := ctx.GetText()advice := checker.checkIdentifier(identifier)if advice != nil {- advice.StartPosition = &storepb.Position{Line: int32(ctx.GetStart().GetLine())}+ advice.StartPosition = &storepb.Position{+ Line: int32(checker.baseLine + ctx.GetStart().GetLine()),+ }checker.adviceList = append(checker.adviceList, advice)}}diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_ddl.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_ddl.goindex 02530703f2..7d7b3f5ca1 100644--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_ddl.go+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_ddl.go@@ -52,7 +52,7 @@ func (*StatementDisallowMixInDDLAdvisor) Check(ctx advisor.Context, _ string) ([Content: fmt.Sprintf("Alter schema can only run DDL, \"%s\" is not DDL", checker.Text),Code: advisor.StatementDisallowMixDDLDML.Int32(),StartPosition: &storepb.Position{- Line: int32(stmt.BaseLine),+ Line: int32(stmt.BaseLine) + 1,},})}diff --git a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_dml.go b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_dml.goindex ac5e0b79a3..4368728a61 100644--- a/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_dml.go+++ b/backend/plugin/advisor/mysql/advisor_statement_disallow_mix_in_dml.go@@ -52,7 +52,7 @@ func (*StatementDisallowMixInDMLAdvisor) Check(ctx advisor.Context, _ string) ([Content: fmt.Sprintf("Data change can only run DML, \"%s\" is not DML", checker.Text),Code: advisor.StatementDisallowMixDDLDML.Int32(),StartPosition: &storepb.Position{- Line: int32(stmt.BaseLine),+ Line: int32(stmt.BaseLine) + 1,},})}diff --git a/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go b/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.goindex e5d2e5268d..97126de037 100644--- a/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go+++ b/backend/plugin/advisor/mysql/advisor_statement_join_strict_column_attrs.go@@ -204,7 +204,7 @@ func (checker *statementJoinStrictColumnAttrsChecker) checkColumnAttrs(leftColumTitle: checker.title,Content: fmt.Sprintf("%s.%s and %s.%s column fields do not match", leftColumnAttr.Table, leftColumnAttr.Column, rightColumnAttr.Table, rightColumnAttr.Column),StartPosition: &storepb.Position{- Line: int32(checker.baseLine),+ Line: int32(checker.baseLine) + 1,},})}diff --git a/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml b/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yamlindex cc96fb778d..82beac2865 100644--- a/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml+++ b/backend/plugin/advisor/mysql/test/column_set_default_for_not_null.yaml@@ -123,6 +123,6 @@c9 json not null,c10 serial not null,c11 long varbinary not null,- c12 long varchar not null+ c12 long varchar not null);changeType: 0diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_ddl.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_ddl.yamlindex b3e5f2d80f..c3fd0f30ad 100644--- a/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_ddl.yaml+++ b/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_ddl.yaml@@ -7,7 +7,7 @@content: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDLdetail: ""startposition:- line: 0+ line: 1column: 0endposition: null- statement: UPDATE tech_book SET id = 1;@@ -19,7 +19,7 @@content: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDLdetail: ""startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ADD COLUMN author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;@@ -31,7 +31,7 @@content: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDLdetail: ""startposition:- line: 0+ line: 1column: 0endposition: null- status: 2@@ -40,6 +40,6 @@content: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDLdetail: ""startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_dml.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_dml.yamlindex b32729628f..51ccbeb2e8 100644--- a/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_dml.yaml+++ b/backend/plugin/advisor/mysql/test/statement_disallow_mix_in_dml.yaml@@ -11,6 +11,6 @@content: Data change can only run DML, "ALTER TABLE tech_book ADD COLUMN author TEXT;" is not DMLdetail: ""startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/mysql/test/statement_max_execution_time.yaml b/backend/plugin/advisor/mysql/test/statement_max_execution_time.yamlindex 733c5ad18f..e229cf34af 100644--- a/backend/plugin/advisor/mysql/test/statement_max_execution_time.yaml+++ b/backend/plugin/advisor/mysql/test/statement_max_execution_time.yaml@@ -1,14 +1,24 @@- statement: SET MAX_EXECUTION_TIME = 1000; SELECT * FROM employee;+ changeType: 0- statement: SET GLOBAL max_execution_time = 10; SELECT * FROM employee;+ changeType: 0- statement: SELECT * FROM employee; SET max_execution_time = 1000;+ changeType: 0want:- status: 2code: 235title: statement.max-execution-time- content: "The max_execution_time is not set"+ content: The max_execution_time is not set+ detail: ""+ startposition: null+ endposition: null- statement: SELECT * FROM t;+ changeType: 0want:- status: 2code: 235title: statement.max-execution-time- content: "The max_execution_time is not set"+ content: The max_execution_time is not set+ detail: ""+ startposition: null+ endposition: nulldiff --git a/backend/plugin/advisor/mysql/test/statement_require_algorithm_option.yaml b/backend/plugin/advisor/mysql/test/statement_require_algorithm_option.yamlindex a084651fff..f3d6a5eb61 100644--- a/backend/plugin/advisor/mysql/test/statement_require_algorithm_option.yaml+++ b/backend/plugin/advisor/mysql/test/statement_require_algorithm_option.yaml@@ -1,13 +1,18 @@- statement: |- CREATE TABLE t(b int);+ CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN c INT, ALGORITHM=INSTANT, LOCK=NONE;+ changeType: 0- statement: |- CREATE TABLE t(b int);+ CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN c INT;+ changeType: 0want:- status: 2code: 236title: statement.require-algorithm-option- content: "ALTER TABLE statement should include ALGORITHM option"+ content: ALTER TABLE statement should include ALGORITHM option+ detail: ""startposition:line: 2+ column: 0+ endposition: nulldiff --git a/backend/plugin/advisor/mysql/test/statement_require_lock_option.yaml b/backend/plugin/advisor/mysql/test/statement_require_lock_option.yamlindex 14f0389a0c..643162b872 100644--- a/backend/plugin/advisor/mysql/test/statement_require_lock_option.yaml+++ b/backend/plugin/advisor/mysql/test/statement_require_lock_option.yaml@@ -1,24 +1,33 @@- statement: |- CREATE TABLE t(b int);+ CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN c INT, ALGORITHM=INSTANT, LOCK=NONE;+ changeType: 0- statement: |- CREATE TABLE t(b int);+ CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN c INT;+ changeType: 0want:- status: 2code: 237title: statement.require-lock-option- content: "ALTER TABLE statement should include LOCK option"+ content: ALTER TABLE statement should include LOCK option+ detail: ""startposition:line: 2+ column: 0+ endposition: null- statement: |- CREATE TABLE t(b int);+ CREATE TABLE t(b int);ALTER TABLE t ADD COLUMN c INT, LOCK=NONE;ALTER TABLE t ADD COLUMN d INT;+ changeType: 0want:- status: 2code: 237title: statement.require-lock-option- content: "ALTER TABLE statement should include LOCK option"+ content: ALTER TABLE statement should include LOCK option+ detail: ""startposition:line: 3+ column: 0+ endposition: null