Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(sql-review): fix check-innodb rule (#9707)

rebelice292c9ea2d344
diff --git a/backend/plugin/advisor/mysql/advisor_use_innodb.go b/backend/plugin/advisor/mysql/advisor_use_innodb.go
index aacacd5e8a..fb89d73d3d 100644
--- a/backend/plugin/advisor/mysql/advisor_use_innodb.go
+++ b/backend/plugin/advisor/mysql/advisor_use_innodb.go
@@ -136,6 +136,13 @@ func (c *useInnoDBChecker) EnterSetStatement(ctx *mysql.SetStatementContext) {
return
}
optionValueNoOptionType := startOptionValueList.OptionValueNoOptionType()
+ if optionValueNoOptionType.InternalVariableName() == nil {
+ return
+ }
+ name := optionValueNoOptionType.InternalVariableName().GetText()
+ if strings.ToLower(name) != defaultStorageEngin {
+ return
+ }
if optionValueNoOptionType.SetExprOrDefault() != nil {
engine := optionValueNoOptionType.SetExprOrDefault().GetText()
if strings.ToLower(engine) != innoDB {
diff --git a/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml b/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml
index d7cec5864d..0affbdc302 100644
--- a/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml
+++ b/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml
@@ -29,6 +29,7 @@
FOREIGN KEY fk1(roomId) REFERENCES room(id),
INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;" doesn't use InnoDB engine
line: 12
+ column: 0
details: ""
- statement: |
CREATE TABLE user(
@@ -48,6 +49,7 @@
title: OK
content: ""
line: 0
+ column: 0
details: ""
- statement: CREATE TABLE book(id int) ENGINE = INNODB;
want:
@@ -56,6 +58,7 @@
title: OK
content: ""
line: 0
+ column: 0
details: ""
- statement: CREATE TABLE book(id int);
want:
@@ -64,6 +67,7 @@
title: OK
content: ""
line: 0
+ column: 0
details: ""
- statement: |
CREATE TABLE book(
@@ -80,6 +84,7 @@
price INT
) ENGINE = CSV;" doesn't use InnoDB engine
line: 4
+ column: 0
details: ""
- statement: |
CREATE TABLE teck_book(a INT);
@@ -97,6 +102,7 @@
price INT
) ENGINE = CSV;" doesn't use InnoDB engine
line: 5
+ column: 0
details: ""
- statement: ALTER TABLE tech_book ENGINE = INNODB;
want:
@@ -105,6 +111,7 @@
title: OK
content: ""
line: 0
+ column: 0
details: ""
- statement: |
CREATE TABLE teck_book(a INT);
@@ -114,9 +121,9 @@
- status: WARN
code: 501
title: engine.mysql.use-innodb
- content: |-
- "ALTER TABLE tech_book ENGINE = CSV;" doesn't use InnoDB engine
+ content: '"ALTER TABLE tech_book ENGINE = CSV;" doesn''t use InnoDB engine'
line: 3
+ column: 0
details: ""
- statement: SET default_storage_engine=INNODB;
want:
@@ -125,6 +132,7 @@
title: OK
content: ""
line: 0
+ column: 0
details: ""
- statement: |
CREATE TABLE book(a INT);
@@ -133,7 +141,17 @@
- status: WARN
code: 501
title: engine.mysql.use-innodb
- content: |-
- "SET default_storage_engine=CSV;" doesn't use InnoDB engine
+ content: '"SET default_storage_engine=CSV;" doesn''t use InnoDB engine'
line: 2
+ column: 0
+ details: ""
+- statement: |
+ SET foreign_key_checks=0;
+ want:
+ - status: SUCCESS
+ code: 0
+ title: OK
+ content: ""
+ line: 0
+ column: 0
details: ""