Skip to content

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

fix(mysql-parser): force parsing until EOF (#6583)

rebelice632a5b690526
diff --git a/backend/plugin/advisor/catalog/test/mysql_walk_through.yaml b/backend/plugin/advisor/catalog/test/mysql_walk_through.yaml
index 8530f8cac2..14be99235c 100644
--- a/backend/plugin/advisor/catalog/test/mysql_walk_through.yaml
+++ b/backend/plugin/advisor/catalog/test/mysql_walk_through.yaml
@@ -12,7 +12,7 @@
err:
type: 407
content: BLOB, TEXT, GEOMETRY or JSON column `a` can't have a default value
- line: 2
+ line: 3
payload: null
- statement: ' CREATE TABLE t(a TEXT DEFAULT ''1'')'
want: null
@@ -28,7 +28,7 @@
err:
type: 406
content: Invalid default value for column `a`
- line: 2
+ line: 3
payload: null
- statement: ' CREATE TABLE t(a INT NOT NULL DEFAULT NULL)'
want: null
@@ -49,63 +49,65 @@
err:
type: 404
content: There can be only one auto column for table `t`
- line: 1
+ line: 2
payload: null
- statement: ' CREATE TABLE t as select * from t1;'
want: null
err:
type: 303
- content: Disallow the CREATE TABLE AS statement but "CREATE TABLE t as select * from t1;" uses
- line: 1
+ content: |-
+ Disallow the CREATE TABLE AS statement but "CREATE TABLE t as select * from t1
+ ;" uses
+ line: 2
payload: null
- statement: "\n\t\t\t\tCREATE TABLE t(a int, b int); \n\t\t\t\tCREATE INDEX idx_c on t(c);\n\t\t\t"
want: null
err:
type: 402
content: Column `c` does not exist in table `t`
- line: 3
+ line: 4
payload: null
- statement: "\n\t\t\t\tCREATE TABLE t(a int, b int); \n\t\t\t\tALTER TABLE t MODIFY COLUMN c int;\n\t\t\t"
want: null
err:
type: 402
content: Column `c` does not exist in table `t`
- line: 3
+ line: 4
payload: null
- statement: "\n\t\t\t\tCREATE TABLE t(a int, b int); \n\t\t\t\tALTER TABLE t CHANGE COLUMN c aa int;\n\t\t\t"
want: null
err:
type: 402
content: Column `c` does not exist in table `t`
- line: 3
+ line: 4
payload: null
- statement: "\n\t\t\t\tCREATE TABLE t(a int, b int); \n\t\t\t\tALTER TABLE t DROP COLUMN c;\n\t\t\t"
want: null
err:
type: 402
content: Column `c` does not exist in table `t`
- line: 3
+ line: 4
payload: null
- statement: "\n\t\t\t\tCREATE TABLE t(a int, b int); \n\t\t\t\tALTER TABLE t RENAME COLUMN c TO cc;\n\t\t\t"
want: null
err:
type: 402
content: Column `c` does not exist in table `t`
- line: 3
+ line: 4
payload: null
- statement: "\n\t\t\t\tCREATE TABLE t(a int, b int); \n\t\t\t\tALTER TABLE t RENAME COLUMN c TO cc;\n\t\t\t"
want: null
err:
type: 402
content: Column `c` does not exist in table `t`
- line: 3
+ line: 4
payload: null
- statement: "\n\t\t\t\tCREATE TABLE t(a int, b int); \n\t\t\t\tALTER TABLE t ALTER COLUMN c DROP DEFAULT;\n\t\t\t"
want: null
err:
type: 402
content: Column `c` does not exist in table `t`
- line: 3
+ line: 4
payload: null
- statement: |-
ALTER DATABASE CHARACTER SET = utf8mb4;
@@ -120,6 +122,7 @@
characterset: utf8mb4
collation: utf8mb4_polish_ci
extensions: []
+ datashare: false
err: null
- statement: |-
CREATE TABLE t(
@@ -337,6 +340,7 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
- statement: |-
CREATE TABLE t(
@@ -456,6 +460,7 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
- statement: |-
CREATE TABLE t(
@@ -510,6 +515,7 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
- statement: |-
CREATE TABLE t1(a int, b int, c int);
@@ -525,13 +531,14 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
- statement: ' DROP TABLE t1, t2'
want: null
err:
type: 302
content: Table `t1` does not exist
- line: 1
+ line: 2
payload: null
- statement: |-
CREATE TABLE t(a int);
@@ -546,6 +553,7 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
- statement: |-
CREATE TABLE t(a int);
@@ -580,6 +588,7 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
- statement: |-
-- this is comment
@@ -589,7 +598,7 @@
err:
type: 202
content: Database `test` is deleted
- line: 3
+ line: 4
payload: null
- statement: |-
CREATE TABLE t(
@@ -721,6 +730,7 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
- statement: |-
CREATE TABLE t(
@@ -840,6 +850,7 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
- statement: |-
CREATE TABLE t(
@@ -894,4 +905,5 @@
characterset: ""
collation: ""
extensions: []
+ datashare: false
err: null
diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml
index e6b9f972e2..c84eb6f231 100644
--- a/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml
+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_initial_value.yaml
@@ -20,5 +20,5 @@
code: 416
title: column.auto-increment-initial-value
content: The initial auto-increment value in table `t` is 2, which doesn't equal 20
- line: 1
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml
index 3685dbf6db..d23d0b34d5 100644
--- a/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml
+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_must_integer.yaml
@@ -12,7 +12,7 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- line: 1
+ line: 2
details: ""
- statement: |-
CREATE TABLE t(b int);
@@ -22,7 +22,7 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -32,7 +32,7 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(b int);
@@ -42,5 +42,5 @@
code: 410
title: column.auto-increment-must-integer
content: Auto-increment column `t`.`a` requires integer type
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml b/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml
index 07fa3166a1..7c72ff8355 100644
--- a/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml
+++ b/backend/plugin/advisor/mysql/test/column_auto_increment_must_unsigned.yaml
@@ -12,7 +12,7 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- line: 1
+ line: 2
details: ""
- statement: |-
CREATE TABLE t(b int);
@@ -22,7 +22,7 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -32,7 +32,7 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(b int);
@@ -42,5 +42,5 @@
code: 417
title: column.auto-increment-must-unsigned
content: Auto-increment column `t`.`a` is not UNSIGNED type
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_comment.yaml b/backend/plugin/advisor/mysql/test/column_comment.yaml
index 0bacb51ad3..1e764ba49f 100644
--- a/backend/plugin/advisor/mysql/test/column_comment.yaml
+++ b/backend/plugin/advisor/mysql/test/column_comment.yaml
@@ -38,7 +38,7 @@
code: 408
title: column.comment
content: Column `t`.`b` requires comments
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int COMMENT 'this is comment');
@@ -54,7 +54,7 @@
code: 408
title: column.comment
content: Column `t`.`b` requires comments
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(b int COMMENT 'It is comment');
@@ -70,7 +70,7 @@
code: 408
title: column.comment
content: Column `t`.`b` requires comments
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(b int COMMENT 'It is COMMENT');
@@ -86,5 +86,5 @@
code: 409
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml b/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml
index 08b3c5ded7..f5b200b722 100644
--- a/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/column_current_time_count_limit.yaml
@@ -17,7 +17,7 @@
code: 418
title: column.current-time-count-limit
content: Table `t` has 3 DEFAULT CURRENT_TIMESTAMP() columns. The count greater than 2.
- line: 5
+ line: 6
details: ""
- statement: |-
CREATE TABLE t(
@@ -29,7 +29,7 @@
code: 419
title: column.current-time-count-limit
content: Table `t` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.
- line: 4
+ line: 5
details: ""
- statement: |-
ALTER TABLE tech_book ADD COLUMN a timestamp default now() on update localtime;
@@ -39,5 +39,5 @@
code: 419
title: column.current-time-count-limit
content: Table `tech_book` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_change.yaml b/backend/plugin/advisor/mysql/test/column_disallow_change.yaml
index 0cac3ff8d6..b25f8ce70a 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_change.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_change.yaml
@@ -15,6 +15,8 @@
- status: WARN
code: 406
title: column.disallow-change
- content: '"ALTER TABLE t CHANGE COLUMN b a int" contains CHANGE COLUMN statement'
- line: 2
+ content: |-
+ "ALTER TABLE t CHANGE COLUMN b a int
+ ;" contains CHANGE COLUMN statement
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml b/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml
index d2e7fa820d..54ccb860b1 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_change_type.yaml
@@ -3,8 +3,10 @@
- status: WARN
code: 403
title: column.disallow-change-type
- content: '"ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED" changes column type'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED
+ ;" changes column type
+ line: 2
details: ""
- statement: ALTER TABLE tech_book MODIFY id int
want:
@@ -19,14 +21,18 @@
- status: WARN
code: 403
title: column.disallow-change-type
- content: '"ALTER TABLE tech_book MODIFY id bigint" changes column type'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book MODIFY id bigint
+ ;" changes column type
+ line: 2
details: ""
- statement: ALTER TABLE tech_book CHANGE name uname varchar(20)
want:
- status: WARN
code: 403
title: column.disallow-change-type
- content: '"ALTER TABLE tech_book CHANGE name uname varchar(20)" changes column type'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book CHANGE name uname varchar(20)
+ ;" changes column type
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml b/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml
index fe5c5f252f..8d7fd61c6e 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_changing_order.yaml
@@ -15,8 +15,10 @@
- status: WARN
code: 407
title: column.disallow-changing-order
- content: '"ALTER TABLE t MODIFY COLUMN a int FIRST" changes column order'
- line: 2
+ content: |-
+ "ALTER TABLE t MODIFY COLUMN a int FIRST
+ ;" changes column order
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(b int, a1 int);
@@ -25,8 +27,10 @@
- status: WARN
code: 407
title: column.disallow-changing-order
- content: '"ALTER TABLE t CHANGE COLUMN a1 a int FIRST" changes column order'
- line: 2
+ content: |-
+ "ALTER TABLE t CHANGE COLUMN a1 a int FIRST
+ ;" changes column order
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int, b int);
@@ -35,8 +39,10 @@
- status: WARN
code: 407
title: column.disallow-changing-order
- content: '"ALTER TABLE t MODIFY COLUMN a int AFTER b" changes column order'
- line: 2
+ content: |-
+ "ALTER TABLE t MODIFY COLUMN a int AFTER b
+ ;" changes column order
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a1 int, b int);
@@ -45,6 +51,8 @@
- status: WARN
code: 407
title: column.disallow-changing-order
- content: '"ALTER TABLE t CHANGE COLUMN a1 a int AFTER b" changes column order'
- line: 2
+ content: |-
+ "ALTER TABLE t CHANGE COLUMN a1 a int AFTER b
+ ;" changes column order
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml b/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml
index 781d8e6431..7125519720 100644
--- a/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml
+++ b/backend/plugin/advisor/mysql/test/column_disallow_set_charset.yaml
@@ -21,30 +21,38 @@
- status: WARN
code: 414
title: column.disallow-set-charset
- content: Disallow set column charset but "CREATE TABLE t(a varchar(20) CHARSET ascii)" does
- line: 1
+ content: |-
+ Disallow set column charset but "CREATE TABLE t(a varchar(20) CHARSET ascii)
+ ;" does
+ line: 2
details: ""
- statement: ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET ascii
want:
- status: WARN
code: 414
title: column.disallow-set-charset
- content: Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET ascii" does
- line: 1
+ content: |-
+ Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET ascii
+ ;" does
+ line: 2
details: ""
- statement: ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii
want:
- status: WARN
code: 414
title: column.disallow-set-charset
- content: Disallow set column charset but "ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii" does
- line: 1
+ content: |-
+ Disallow set column charset but "ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii
+ ;" does
+ line: 2
details: ""
- statement: ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii
want:
- status: WARN
code: 414
title: column.disallow-set-charset
- content: Disallow set column charset but "ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii" does
- line: 1
+ content: |-
+ Disallow set column charset but "ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii
+ ;" does
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml b/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml
index 7aa1b02db1..a826b65ac6 100644
--- a/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml
+++ b/backend/plugin/advisor/mysql/test/column_maximum_character_length.yaml
@@ -28,7 +28,7 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `name_2` is bigger than 20, please use VARCHAR instead
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book CHANGE COLUMN name name char(225)
want:
@@ -36,7 +36,7 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `name` is bigger than 20, please use VARCHAR instead
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book MODIFY COLUMN name char(225)
want:
@@ -44,5 +44,5 @@
code: 415
title: column.maximum-character-length
content: The length of the CHAR column `name` is bigger than 20, please use VARCHAR instead
- line: 1
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_no_null.yaml b/backend/plugin/advisor/mysql/test/column_no_null.yaml
index 38e3dd70f4..c91a3aa86d 100644
--- a/backend/plugin/advisor/mysql/test/column_no_null.yaml
+++ b/backend/plugin/advisor/mysql/test/column_no_null.yaml
@@ -47,7 +47,7 @@
code: 402
title: column.no-null
content: '`book`.`id` cannot have NULL value'
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE book(a int NOT NULL);
@@ -67,7 +67,7 @@
code: 402
title: column.no-null
content: '`book`.`name` cannot have NULL value'
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE book(id int NOT NULL);
diff --git a/backend/plugin/advisor/mysql/test/column_require_default.yaml b/backend/plugin/advisor/mysql/test/column_require_default.yaml
index 342755ca06..ed80fca205 100644
--- a/backend/plugin/advisor/mysql/test/column_require_default.yaml
+++ b/backend/plugin/advisor/mysql/test/column_require_default.yaml
@@ -33,5 +33,5 @@
code: 420
title: column.require-default
content: Column `tech_book`.`a` doesn't have DEFAULT.
- line: 3
+ line: 4
details: ""
diff --git a/backend/plugin/advisor/mysql/test/column_required.yaml b/backend/plugin/advisor/mysql/test/column_required.yaml
index 09ae6cf94d..fe2b0c2998 100644
--- a/backend/plugin/advisor/mysql/test/column_required.yaml
+++ b/backend/plugin/advisor/mysql/test/column_required.yaml
@@ -4,7 +4,7 @@
code: 401
title: column.required
content: 'Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id'
- line: 1
+ line: 2
details: ""
- statement: |-
CREATE TABLE book(
@@ -33,7 +33,7 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- line: 7
+ line: 8
details: ""
- statement: |-
CREATE TABLE book(
@@ -63,7 +63,7 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- line: 7
+ line: 8
details: ""
- statement: |-
CREATE TABLE book(
@@ -93,7 +93,7 @@
code: 401
title: column.required
content: 'Table `book` requires columns: creator_id'
- line: 7
+ line: 8
details: ""
- statement: |-
CREATE TABLE book(
@@ -161,7 +161,7 @@
code: 401
title: column.required
content: 'Table `student` requires columns: creator_id, updater_id'
- line: 9
+ line: 10
details: ""
- statement: |-
CREATE TABLE book(
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.yaml
index 3a4b70ffd8..169e70d0fc 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
@@ -61,7 +61,7 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE book(id int);
@@ -71,7 +71,7 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE book(id int);
@@ -101,7 +101,7 @@
code: 404
title: column.set-default-for-not-null
content: Column `book`.`id` is NOT NULL but doesn't have DEFAULT
- line: 2
+ line: 3
details: ""
- statement: "\n\t\t\t\tCREATE TABLE book(uid int, id int);\n\t\t\t\tALTER TABLE book \n\t\t\t\t\tCHANGE COLUMN uid uid int NOT NULL DEFAULT 0,\n\t\t\t\t\tMODIFY COLUMN id int PRIMARY KEY DEFAULT 0,\n\t\t\t\t\tADD COLUMN name varchar(20) NOT NULL DEFAULT ''\n\t\t\t\t"
want:
diff --git a/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml b/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml
index 2f6fb9e6d6..aa3d6dc244 100644
--- a/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml
+++ b/backend/plugin/advisor/mysql/test/column_type_disallow_list.yaml
@@ -22,7 +22,7 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(c int, b int);
@@ -32,5 +32,5 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml b/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml
index ddaa830fbb..c5b2d15f6a 100644
--- a/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml
+++ b/backend/plugin/advisor/mysql/test/database_drop_empty_database.yaml
@@ -4,5 +4,5 @@
code: 701
title: database.drop-empty-database
content: Database `test` is not allowed to drop if not empty
- line: 1
+ line: 2
details: ""
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 94eba64411..70190f0dda 100644
--- a/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml
+++ b/backend/plugin/advisor/mysql/test/engine_mysql_use_innodb.yaml
@@ -19,8 +19,10 @@
- status: WARN
code: 501
title: engine.mysql.use-innodb
- content: '"CREATE TABLE book(id int) ENGINE = CSV" doesn''t use InnoDB engine'
- line: 1
+ content: |-
+ "CREATE TABLE book(id int) ENGINE = CSV
+ ;" doesn't use InnoDB engine
+ line: 2
details: ""
- statement: ALTER TABLE tech_book ENGINE = INNODB
want:
@@ -35,8 +37,10 @@
- status: WARN
code: 501
title: engine.mysql.use-innodb
- content: '"ALTER TABLE tech_book ENGINE = CSV" doesn''t use InnoDB engine'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book ENGINE = CSV
+ ;" doesn't use InnoDB engine
+ line: 2
details: ""
- statement: SET default_storage_engine=INNODB
want:
@@ -51,6 +55,8 @@
- status: WARN
code: 501
title: engine.mysql.use-innodb
- content: '"SET default_storage_engine=CSV" doesn''t use InnoDB engine'
- line: 1
+ content: |-
+ "SET default_storage_engine=CSV
+ ;" doesn't use InnoDB engine
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml b/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml
index fed362f8a2..bab83ee30a 100644
--- a/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/index_key_number_limit.yaml
@@ -26,7 +26,7 @@
code: 802
title: index.key-number-limit
content: The number of index `idx` in table `t` should be not greater than 5
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);
@@ -36,7 +36,7 @@
code: 802
title: index.key-number-limit
content: The number of index `uk` in table `t` should be not greater than 5
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);
@@ -46,5 +46,5 @@
code: 802
title: index.key-number-limit
content: The number of index `uk` in table `t` should be not greater than 5
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml
index 8daa2383fe..c16e93b8f3 100644
--- a/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml
+++ b/backend/plugin/advisor/mysql/test/index_no_duplicate_column.yaml
@@ -25,7 +25,7 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -35,7 +35,7 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -45,7 +45,7 @@
code: 812
title: index.no-duplicate-column
content: PRIMARY KEY `pk_a` has duplicate column `t`.`a`
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -55,7 +55,7 @@
code: 812
title: index.no-duplicate-column
content: UNIQUE KEY `uk_a` has duplicate column `t`.`a`
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -65,5 +65,5 @@
code: 812
title: index.no-duplicate-column
content: FOREIGN KEY `fk_a` has duplicate column `t`.`a`
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml b/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml
index 24627976e5..96e9f4f70c 100644
--- a/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/index_pk_type_limit.yaml
@@ -60,7 +60,7 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -80,7 +80,7 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -90,13 +90,13 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- line: 2
+ line: 3
details: ""
- status: WARN
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -126,7 +126,7 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5));
@@ -136,13 +136,13 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- line: 2
+ line: 3
details: ""
- status: WARN
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id3` is varchar(5)
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id INT, id2 BIGINT);
@@ -172,7 +172,7 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id int);
@@ -192,7 +192,7 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id int);
diff --git a/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml
index f146fb554a..6b7fc068ea 100644
--- a/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml
+++ b/backend/plugin/advisor/mysql/test/index_primary_key_type_allowlist.yaml
@@ -60,7 +60,7 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -80,7 +80,7 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -90,13 +90,13 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- status: WARN
code: 803
title: index.primary-key-type-allowlist
content: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -126,7 +126,7 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5));
@@ -136,13 +136,13 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- status: WARN
code: 803
title: index.primary-key-type-allowlist
content: The column `id3` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id INT, id2 BIGINT);
@@ -172,7 +172,7 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id int);
@@ -192,7 +192,7 @@
code: 803
title: index.primary-key-type-allowlist
content: The column `id2` in table `t` is one of the primary key, but its type "varchar" is not in allowlist
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id int);
diff --git a/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml b/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml
index ddb832a98c..70ba0fc71d 100644
--- a/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/index_total_number_limit.yaml
@@ -25,7 +25,7 @@
code: 813
title: index.total-number-limit
content: The count of index in table `tech_book` should be no more than 5, but found 8
- line: 5
+ line: 6
details: ""
- statement: |-
CREATE TABLE t(a int PRIMARY KEY, b int, c int);
@@ -39,7 +39,7 @@
code: 813
title: index.total-number-limit
content: The count of index in table `t` should be no more than 5, but found 6
- line: 6
+ line: 7
details: ""
- statement: |-
CREATE TABLE t(
@@ -56,5 +56,5 @@
code: 813
title: index.total-number-limit
content: The count of index in table `t` should be no more than 5, but found 6
- line: 9
+ line: 10
details: ""
diff --git a/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml b/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml
index 0442d9a067..184a472765 100644
--- a/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml
+++ b/backend/plugin/advisor/mysql/test/index_type_no_blob.yaml
@@ -82,7 +82,7 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -92,19 +92,19 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- line: 2
+ line: 3
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- line: 2
+ line: 3
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -114,19 +114,19 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- line: 2
+ line: 3
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- line: 2
+ line: 3
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
diff --git a/backend/plugin/advisor/mysql/test/naming_column.yaml b/backend/plugin/advisor/mysql/test/naming_column.yaml
index 1ce2ecf64c..97e0bc8a28 100644
--- a/backend/plugin/advisor/mysql/test/naming_column.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_column.yaml
@@ -30,7 +30,7 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 2
+ line: 3
details: ""
- statement: ALTER TABLE tech_book RENAME COLUMN id TO creator_id;
want:
@@ -53,7 +53,7 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 7
+ line: 8
details: ""
- statement: ALTER TABLE tech_book CHANGE COLUMN id creator_id int;
want:
@@ -83,7 +83,7 @@
code: 302
title: naming.column
content: '`book`.`contentString` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 6
+ line: 7
details: ""
- statement: |-
CREATE TABLE book(
diff --git a/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml b/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml
index 3201a6a383..29e0a0dc10 100644
--- a/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_column_auto_increment.yaml
@@ -20,7 +20,7 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book CHANGE COLUMN id a int AUTO_INCREMENT
want:
@@ -28,7 +28,7 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book MODIFY COLUMN name int AUTO_INCREMENT
want:
@@ -36,5 +36,5 @@
code: 307
title: naming.column.auto-increment
content: '`tech_book`.`name` mismatches auto_increment column naming convention, naming format should be "^id$"'
- line: 1
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/naming_index_fk.yaml b/backend/plugin/advisor/mysql/test/naming_index_fk.yaml
index 112616d4c5..10a69d82d3 100644
--- a/backend/plugin/advisor/mysql/test/naming_index_fk.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_index_fk.yaml
@@ -12,7 +12,7 @@
code: 305
title: naming.index.fk
content: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `fk_author_id`
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book ADD CONSTRAINT rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk FOREIGN KEY (author_id) REFERENCES author (id)
want:
@@ -20,13 +20,13 @@
code: 305
title: naming.index.fk
content: Foreign key in table `tech_book` mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk`
- line: 1
+ line: 2
details: ""
- status: WARN
code: 305
title: naming.index.fk
content: Foreign key `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id))
want:
diff --git a/backend/plugin/advisor/mysql/test/naming_index_idx.yaml b/backend/plugin/advisor/mysql/test/naming_index_idx.yaml
index 79a89fa586..378d44a3b5 100644
--- a/backend/plugin/advisor/mysql/test/naming_index_idx.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_index_idx.yaml
@@ -12,7 +12,7 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`
- line: 1
+ line: 2
details: ""
- statement: CREATE INDEX afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw ON tech_book(id, name)
want:
@@ -20,13 +20,13 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw`
- line: 1
+ line: 2
details: ""
- status: WARN
code: 303
title: naming.index.idx
content: Index `afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book RENAME INDEX old_index TO idx_tech_book_id_name
want:
@@ -42,7 +42,7 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `idx_tech_book`
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book ADD INDEX idx_tech_book_id_name (id, name)
want:
@@ -58,7 +58,7 @@
code: 303
title: naming.index.idx
content: Index in table `tech_book` mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found `tech_book_id_name`
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE tech_book_copy(id INT PRIMARY KEY, name VARCHAR(20), INDEX idx_tech_book_copy_name (name))
want:
diff --git a/backend/plugin/advisor/mysql/test/naming_index_uk.yaml b/backend/plugin/advisor/mysql/test/naming_index_uk.yaml
index bb03ac33e9..9c02353147 100644
--- a/backend/plugin/advisor/mysql/test/naming_index_uk.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_index_uk.yaml
@@ -12,7 +12,7 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`
- line: 1
+ line: 2
details: ""
- statement: CREATE UNIQUE INDEX qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy ON tech_book(id, name)
want:
@@ -20,13 +20,13 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy`
- line: 1
+ line: 2
details: ""
- status: WARN
code: 304
title: naming.index.uk
content: Unique key `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book ADD UNIQUE uk_tech_book_id_name (id, name)
want:
@@ -42,7 +42,7 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `tech_book_id_name`
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book RENAME INDEX old_uk TO uk_tech_book_id_name
want:
@@ -58,7 +58,7 @@
code: 304
title: naming.index.uk
content: Unique key in table `tech_book` mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found `uk_tech_book`
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE INDEX uk_book_name (name))
want:
diff --git a/backend/plugin/advisor/mysql/test/naming_table.yaml b/backend/plugin/advisor/mysql/test/naming_table.yaml
index a7e411fef3..d7678b4175 100644
--- a/backend/plugin/advisor/mysql/test/naming_table.yaml
+++ b/backend/plugin/advisor/mysql/test/naming_table.yaml
@@ -4,7 +4,7 @@
code: 301
title: naming.table
content: '`techBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE tech_book_copy(id int, name varchar(255))
want:
@@ -20,7 +20,7 @@
code: 301
title: naming.table
content: '`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters'
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book RENAME TO TechBook
want:
@@ -28,7 +28,7 @@
code: 301
title: naming.table
content: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book RENAME TO tech_book_copy
want:
@@ -44,7 +44,7 @@
code: 301
title: naming.table
content: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE literary_book(a int);RENAME TABLE tech_book TO TechBook, literary_book TO LiteraryBook
want:
@@ -52,13 +52,13 @@
code: 301
title: naming.table
content: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 1
+ line: 2
details: ""
- status: WARN
code: 301
title: naming.table
content: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE literary_book(a int);RENAME TABLE tech_book TO tech_book_copy, literary_book TO literary_book_copy
want:
diff --git a/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml
index c75a85a891..4513d1535f 100644
--- a/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml
+++ b/backend/plugin/advisor/mysql/test/schema_backward_compatibility.yaml
@@ -3,38 +3,48 @@
- status: WARN
code: 111
title: schema.backward-compatibility
- content: '"ALTER TABLE tech_book CHANGE name f2 TEXT" may cause incompatibility with the existing data and code'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book CHANGE name f2 TEXT
+ ;" may cause incompatibility with the existing data and code
+ line: 2
details: ""
- statement: ALTER TABLE tech_book MODIFY name TEXT
want:
- status: WARN
code: 111
title: schema.backward-compatibility
- content: '"ALTER TABLE tech_book MODIFY name TEXT" may cause incompatibility with the existing data and code'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book MODIFY name TEXT
+ ;" may cause incompatibility with the existing data and code
+ line: 2
details: ""
- statement: ALTER TABLE tech_book MODIFY name TEXT NULL
want:
- status: WARN
code: 111
title: schema.backward-compatibility
- content: '"ALTER TABLE tech_book MODIFY name TEXT NULL" may cause incompatibility with the existing data and code'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book MODIFY name TEXT NULL
+ ;" may cause incompatibility with the existing data and code
+ line: 2
details: ""
- statement: ALTER TABLE tech_book MODIFY name TEXT NOT NULL
want:
- status: WARN
code: 111
title: schema.backward-compatibility
- content: '"ALTER TABLE tech_book MODIFY name TEXT NOT NULL" may cause incompatibility with the existing data and code'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book MODIFY name TEXT NOT NULL
+ ;" may cause incompatibility with the existing data and code
+ line: 2
details: ""
- statement: ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla'
want:
- status: WARN
code: 111
title: schema.backward-compatibility
- content: '"ALTER TABLE tech_book MODIFY name TEXT COMMENT ''bla''" may cause incompatibility with the existing data and code'
- line: 1
+ content: |-
+ "ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla'
+ ;" may cause incompatibility with the existing data and code
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml
index fcf79a651d..07b523e8d7 100644
--- a/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_disallow_commit.yaml
@@ -6,8 +6,10 @@
- status: WARN
code: 206
title: statement.disallow-commit
- content: 'Commit is not allowed, related statement: "COMMIT;"'
- line: 3
+ content: |-
+ Commit is not allowed, related statement: "COMMIT
+ ;"
+ line: 4
details: ""
- statement: |-
START TRANSACTION;
@@ -27,6 +29,8 @@
- status: WARN
code: 206
title: statement.disallow-commit
- content: 'Commit is not allowed, related statement: "COMMIT;"'
- line: 7
+ content: |-
+ Commit is not allowed, related statement: "COMMIT
+ ;"
+ line: 8
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml
index d136ed57ac..71b6916a92 100644
--- a/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_disallow_limit.yaml
@@ -11,30 +11,38 @@
- status: WARN
code: 1103
title: statement.disallow-limit
- content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1" uses
- line: 1
+ content: |-
+ LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1
+ ;" uses
+ line: 2
details: ""
- statement: INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1
want:
- status: WARN
code: 1103
title: statement.disallow-limit
- content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1" uses
- line: 1
+ content: |-
+ LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1
+ ;" uses
+ line: 2
details: ""
- statement: UPDATE tech_book SET name = 'my name' LIMIT 10
want:
- status: WARN
code: 1102
title: statement.disallow-limit
- content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "UPDATE tech_book SET name = 'my name' LIMIT 10" uses
- line: 1
+ content: |-
+ LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "UPDATE tech_book SET name = 'my name' LIMIT 10
+ ;" uses
+ line: 2
details: ""
- statement: DELETE FROM tech_book LIMIT 10
want:
- status: WARN
code: 1106
title: statement.disallow-limit
- content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "DELETE FROM tech_book LIMIT 10" uses
- line: 1
+ content: |-
+ LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "DELETE FROM tech_book LIMIT 10
+ ;" uses
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml b/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml
index e9f45b9e6a..06853d65b6 100644
--- a/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_disallow_order_by.yaml
@@ -11,14 +11,18 @@
- status: WARN
code: 1104
title: statement.disallow-order-by
- content: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "UPDATE tech_book SET name = 'my name' ORDER BY id" uses
- line: 1
+ content: |-
+ ORDER BY clause is forbidden in DELETE and UPDATE statements, but "UPDATE tech_book SET name = 'my name' ORDER BY id
+ ;" uses
+ line: 2
details: ""
- statement: DELETE FROM tech_book ORDER BY id
want:
- status: WARN
code: 1105
title: statement.disallow-order-by
- content: ORDER BY clause is forbidden in DELETE and UPDATE statements, but "DELETE FROM tech_book ORDER BY id" uses
- line: 1
+ content: |-
+ ORDER BY clause is forbidden in DELETE and UPDATE statements, but "DELETE FROM tech_book ORDER BY id
+ ;" uses
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml
index 79a825f657..2180032bc7 100644
--- a/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_insert_disallow_order_by_rand.yaml
@@ -11,6 +11,8 @@
- status: WARN
code: 1108
title: statement.insert.disallow-order-by-rand
- content: '"INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand()" uses ORDER BY RAND in the INSERT statement'
- line: 1
+ content: |-
+ "INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand()
+ ;" uses ORDER BY RAND in the INSERT statement
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml
index ed3beaefcf..c6a5a25d87 100644
--- a/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_insert_must_specify_column.yaml
@@ -11,6 +11,8 @@
- status: WARN
code: 1107
title: statement.insert.must-specify-column
- content: The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1')" does not
- line: 1
+ content: |-
+ The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1')
+ ;" does not
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml b/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml
index eadd625df6..82dc610691 100644
--- a/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_insert_row_limit.yaml
@@ -11,8 +11,10 @@
- status: WARN
code: 1101
title: statement.insert.row-limit
- content: '"INSERT INTO tech_book values(1, ''a''), (2, ''b''), (3, ''c''), (4, ''d''), (5, ''e''), (6, ''f'')" inserts 6 rows. The count exceeds 5.'
- line: 1
+ content: |-
+ "INSERT INTO tech_book values(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')
+ ;" inserts 6 rows. The count exceeds 5.
+ line: 2
details: ""
- statement: INSERT INTO tech_book SELECT * FROM tech_book
want:
diff --git a/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml
index bd31e8960c..5f32202d5d 100644
--- a/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_merge_alter_table.yaml
@@ -14,7 +14,7 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -32,7 +32,7 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- line: 4
+ line: 5
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -50,5 +50,5 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `t`
- line: 4
+ line: 5
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml
index 4f12df0613..79fd5cf005 100644
--- a/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_select_no_select_all.yaml
@@ -3,8 +3,10 @@
- status: WARN
code: 203
title: statement.select.no-select-all
- content: '"SELECT * FROM t" uses SELECT all'
- line: 1
+ content: |-
+ "SELECT * FROM t
+ ;" uses SELECT all
+ line: 2
details: ""
- statement: SELECT a, b FROM t
want:
@@ -19,6 +21,8 @@
- status: WARN
code: 203
title: statement.select.no-select-all
- content: '"SELECT a, b FROM (SELECT * from t1 JOIN t2) t" uses SELECT all'
- line: 1
+ content: |-
+ "SELECT a, b FROM (SELECT * from t1 JOIN t2) t
+ ;" uses SELECT all
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml
index 0765d6e4d9..9827bafcfa 100644
--- a/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_where_no_leading_wildcard_like.yaml
@@ -11,30 +11,38 @@
- status: WARN
code: 204
title: statement.where.no-leading-wildcard-like
- content: '"SELECT * FROM t WHERE a LIKE ''%abc''" uses leading wildcard LIKE'
- line: 1
+ content: |-
+ "SELECT * FROM t WHERE a LIKE '%abc'
+ ;" uses leading wildcard LIKE
+ line: 2
details: ""
- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'
want:
- status: WARN
code: 204
title: statement.where.no-leading-wildcard-like
- content: '"SELECT * FROM t WHERE a LIKE ''abc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'
- line: 1
+ content: |-
+ "SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'
+ ;" uses leading wildcard LIKE
+ line: 2
details: ""
- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'
want:
- status: WARN
code: 204
title: statement.where.no-leading-wildcard-like
- content: '"SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'
- line: 1
+ content: |-
+ "SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'
+ ;" uses leading wildcard LIKE
+ line: 2
details: ""
- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1
want:
- status: WARN
code: 204
title: statement.where.no-leading-wildcard-like
- content: '"SELECT * FROM (SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc'') t1" uses leading wildcard LIKE'
- line: 1
+ content: |-
+ "SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1
+ ;" uses leading wildcard LIKE
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/statement_where_require.yaml b/backend/plugin/advisor/mysql/test/statement_where_require.yaml
index af4064bd2c..71011e6780 100644
--- a/backend/plugin/advisor/mysql/test/statement_where_require.yaml
+++ b/backend/plugin/advisor/mysql/test/statement_where_require.yaml
@@ -11,16 +11,20 @@
- status: WARN
code: 202
title: statement.where.require
- content: '"DELETE FROM tech_book" requires WHERE clause'
- line: 1
+ content: |-
+ "DELETE FROM tech_book
+ ;" requires WHERE clause
+ line: 2
details: ""
- statement: UPDATE tech_book SET id = 1
want:
- status: WARN
code: 202
title: statement.where.require
- content: '"UPDATE tech_book SET id = 1" requires WHERE clause'
- line: 1
+ content: |-
+ "UPDATE tech_book SET id = 1
+ ;" requires WHERE clause
+ line: 2
details: ""
- statement: DELETE FROM tech_book WHERE id > 0
want:
@@ -43,8 +47,10 @@
- status: WARN
code: 202
title: statement.where.require
- content: '"SELECT id FROM tech_book" requires WHERE clause'
- line: 1
+ content: |-
+ "SELECT id FROM tech_book
+ ;" requires WHERE clause
+ line: 2
details: ""
- statement: SELECT id FROM tech_book WHERE id > 0
want:
@@ -59,6 +65,8 @@
- status: WARN
code: 202
title: statement.where.require
- content: '"SELECT id FROM tech_book WHERE id > (SELECT max(id) FROM tech_book)" requires WHERE clause'
- line: 1
+ content: |-
+ "SELECT id FROM tech_book WHERE id > (SELECT max(id) FROM tech_book)
+ ;" requires WHERE clause
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml b/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml
index a2569b3553..4576406ec7 100644
--- a/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml
+++ b/backend/plugin/advisor/mysql/test/system_charset_allowlist.yaml
@@ -19,8 +19,10 @@
- status: WARN
code: 1001
title: system.charset.allowlist
- content: '"CREATE TABLE t(a int) CHARSET ascii" used disabled charset ''ascii'''
- line: 1
+ content: |-
+ "CREATE TABLE t(a int) CHARSET ascii
+ ;" used disabled charset 'ascii'
+ line: 2
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -29,23 +31,29 @@
- status: WARN
code: 1001
title: system.charset.allowlist
- content: '"ALTER TABLE t CHARSET ascii" used disabled charset ''ascii'''
- line: 2
+ content: |-
+ "ALTER TABLE t CHARSET ascii
+ ;" used disabled charset 'ascii'
+ line: 3
details: ""
- statement: ALTER DATABASE test CHARSET ascii
want:
- status: WARN
code: 1001
title: system.charset.allowlist
- content: '"ALTER DATABASE test CHARSET ascii" used disabled charset ''ascii'''
- line: 1
+ content: |-
+ "ALTER DATABASE test CHARSET ascii
+ ;" used disabled charset 'ascii'
+ line: 2
details: ""
- statement: CREATE TABLE t(a varchar(255) CHARSET ascii)
want:
- status: WARN
code: 1001
title: system.charset.allowlist
- content: '"CREATE TABLE t(a varchar(255) CHARSET ascii)" used disabled charset ''ascii'''
+ content: |-
+ "CREATE TABLE t(a varchar(255) CHARSET ascii)
+ ;" used disabled charset 'ascii'
line: 1
details: ""
- statement: |-
@@ -55,8 +63,10 @@
- status: WARN
code: 1001
title: system.charset.allowlist
- content: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii" used disabled charset ''ascii'''
- line: 2
+ content: |-
+ "ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii
+ ;" used disabled charset 'ascii'
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -65,8 +75,10 @@
- status: WARN
code: 1001
title: system.charset.allowlist
- content: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii" used disabled charset ''ascii'''
- line: 2
+ content: |-
+ "ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii
+ ;" used disabled charset 'ascii'
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -75,8 +87,10 @@
- status: WARN
code: 1001
title: system.charset.allowlist
- content: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii" used disabled charset ''ascii'''
- line: 2
+ content: |-
+ "ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii
+ ;" used disabled charset 'ascii'
+ line: 3
details: ""
- statement: /* this is a comment */
want:
diff --git a/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml b/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml
index bdc6be1159..54e92ad233 100644
--- a/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml
+++ b/backend/plugin/advisor/mysql/test/system_collation_allowlist.yaml
@@ -3,8 +3,10 @@
- status: WARN
code: 1201
title: system.collation.allowlist
- content: '"CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci" used disabled collation ''utf8mb4_polish_ci'''
- line: 1
+ content: |-
+ "CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci
+ ;" used disabled collation 'utf8mb4_polish_ci'
+ line: 2
details: ""
- statement: CREATE TABLE t(a varchar(255))
want:
@@ -19,8 +21,10 @@
- status: WARN
code: 1201
title: system.collation.allowlist
- content: '"CREATE TABLE t(a int) COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- line: 1
+ content: |-
+ "CREATE TABLE t(a int) COLLATE latin1_bin
+ ;" used disabled collation 'latin1_bin'
+ line: 2
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -29,23 +33,29 @@
- status: WARN
code: 1201
title: system.collation.allowlist
- content: '"ALTER TABLE t COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- line: 2
+ content: |-
+ "ALTER TABLE t COLLATE latin1_bin
+ ;" used disabled collation 'latin1_bin'
+ line: 3
details: ""
- statement: ALTER DATABASE test COLLATE latin1_bin
want:
- status: WARN
code: 1201
title: system.collation.allowlist
- content: '"ALTER DATABASE test COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- line: 1
+ content: |-
+ "ALTER DATABASE test COLLATE latin1_bin
+ ;" used disabled collation 'latin1_bin'
+ line: 2
details: ""
- statement: CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)
want:
- status: WARN
code: 1201
title: system.collation.allowlist
- content: '"CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)" used disabled collation ''latin1_bin'''
+ content: |-
+ "CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)
+ ;" used disabled collation 'latin1_bin'
line: 1
details: ""
- statement: |-
@@ -55,8 +65,10 @@
- status: WARN
code: 1201
title: system.collation.allowlist
- content: '"ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- line: 2
+ content: |-
+ "ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin
+ ;" used disabled collation 'latin1_bin'
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -65,8 +77,10 @@
- status: WARN
code: 1201
title: system.collation.allowlist
- content: '"ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- line: 2
+ content: |-
+ "ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin
+ ;" used disabled collation 'latin1_bin'
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -75,6 +89,8 @@
- status: WARN
code: 1201
title: system.collation.allowlist
- content: '"ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- line: 2
+ content: |-
+ "ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin
+ ;" used disabled collation 'latin1_bin'
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/mysql/test/table_comment.yaml b/backend/plugin/advisor/mysql/test/table_comment.yaml
index e9f1263ebd..6a2833b108 100644
--- a/backend/plugin/advisor/mysql/test/table_comment.yaml
+++ b/backend/plugin/advisor/mysql/test/table_comment.yaml
@@ -4,7 +4,7 @@
code: 606
title: table.comment
content: The length of table `t` comment should be within 10 characters
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE t(a int)
want:
@@ -12,7 +12,7 @@
code: 605
title: table.comment
content: Table `t` requires comments
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE t(a int) COMMENT 'sdlfkjalkseblkjduafelbnlsdfkljayue'
want:
@@ -20,5 +20,5 @@
code: 606
title: table.comment
content: The length of table `t` comment should be within 10 characters
- line: 1
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml b/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml
index 58fe721c39..0d5307a0ae 100644
--- a/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml
+++ b/backend/plugin/advisor/mysql/test/table_disallow_partition.yaml
@@ -19,8 +19,9 @@
Table partition is forbidden, but "CREATE TABLE t(a int) PARTITION BY RANGE (a) (
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
- )" creates
- line: 4
+ )
+ ;" creates
+ line: 5
details: ""
- statement: |-
ALTER TABLE tech_book PARTITION BY RANGE (a) (
@@ -35,6 +36,7 @@
Table partition is forbidden, but "ALTER TABLE tech_book PARTITION BY RANGE (a) (
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
- )" creates
- line: 4
+ )
+ ;" creates
+ line: 5
details: ""
diff --git a/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml
index a54ba29f54..0394c75b06 100644
--- a/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml
+++ b/backend/plugin/advisor/mysql/test/table_drop_naming_convention.yaml
@@ -12,7 +12,7 @@
code: 603
title: table.drop-naming-convention
content: '`foo` mismatches drop table naming convention, naming format should be "_delete$"'
- line: 1
+ line: 2
details: ""
- statement: DROP TABLE IF EXISTS foo_delete, bar
want:
@@ -20,5 +20,5 @@
code: 603
title: table.drop-naming-convention
content: '`bar` mismatches drop table naming convention, naming format should be "_delete$"'
- line: 1
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml b/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml
index a612f5c79d..2657588ef9 100644
--- a/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml
+++ b/backend/plugin/advisor/mysql/test/table_no_foreign_key.yaml
@@ -4,7 +4,7 @@
code: 602
title: table.no-foreign-key
content: Foreign key is not allowed in the table `tech_book`
- line: 1
+ line: 2
details: ""
- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id))
want:
diff --git a/backend/plugin/advisor/mysql/test/table_require_pk.yaml b/backend/plugin/advisor/mysql/test/table_require_pk.yaml
index edcd895663..26a04ea666 100644
--- a/backend/plugin/advisor/mysql/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/mysql/test/table_require_pk.yaml
@@ -20,7 +20,7 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- line: 1
+ line: 2
details: ""
- statement: |-
CREATE TABLE t(id INT);
@@ -50,7 +50,7 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id INT PRIMARY KEY);
@@ -60,7 +60,7 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- line: 2
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(id INT);
@@ -126,7 +126,7 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- line: 2
+ line: 3
details: ""
- statement: ALTER TABLE tech_book ADD COLUMN a int, DROP COLUMN id, DROP COLUMN name
want:
@@ -134,7 +134,7 @@
code: 601
title: table.require-pk
content: Table `tech_book` requires PRIMARY KEY
- line: 1
+ line: 2
details: ""
- statement: ALTER TABLE tech_book DROP COLUMN name
want:
@@ -152,5 +152,5 @@
code: 601
title: table.require-pk
content: Table `tech_book` requires PRIMARY KEY
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/oracle/test/column_required.yaml b/backend/plugin/advisor/oracle/test/column_required.yaml
index d1570ab96b..bca7ad4708 100644
--- a/backend/plugin/advisor/oracle/test/column_required.yaml
+++ b/backend/plugin/advisor/oracle/test/column_required.yaml
@@ -4,7 +4,7 @@
code: 401
title: column.required
content: 'Table "BOOK" requires columns: "created_ts", "creator_id", "updated_ts", "updater_id"'
- line: 1
+ line: 2
details: ""
- statement: |-
CREATE TABLE book(
@@ -28,7 +28,7 @@
code: 401
title: column.required
content: 'Table "TECH_BOOK" requires columns: "creator_id"'
- line: 2
+ line: 3
details: ""
- statement: |-
ALTER TABLE tech_book ADD "creator_id" int;
@@ -38,5 +38,5 @@
code: 401
title: column.required
content: 'Table "TECH_BOOK" requires columns: "creator_id"'
- line: 2
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/oracle/test/table_require_pk.yaml b/backend/plugin/advisor/oracle/test/table_require_pk.yaml
index 6e4560e81f..86477bb71c 100644
--- a/backend/plugin/advisor/oracle/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/oracle/test/table_require_pk.yaml
@@ -20,7 +20,7 @@
code: 601
title: table.require-pk
content: Table "SYS"."T" requires PRIMARY KEY.
- line: 1
+ line: 2
details: ""
- statement: |-
CREATE TABLE t(id INT);
diff --git a/backend/plugin/db/mysql/mysql_test.go b/backend/plugin/db/mysql/mysql_test.go
index c07d060132..2e199ac638 100644
--- a/backend/plugin/db/mysql/mysql_test.go
+++ b/backend/plugin/db/mysql/mysql_test.go
@@ -14,7 +14,7 @@ func TestTransformDelimiter(t *testing.T) {
}{
{
statement: "CREATE TABLE t1(id INT PRIMARY KEY);",
- want: "CREATE TABLE t1(id INT PRIMARY KEY);",
+ want: "CREATE TABLE t1(id INT PRIMARY KEY)\n;",
},
{
statement: `
@@ -103,5 +103,6 @@ func TestTransformDelimiter_Truncate(t *testing.T) {
}
require.Equal(t, 12, len(got))
// Make sure all trunks add up.
- require.Equal(t, total, len(statements))
+ // 12 trunks + 1 delimiter
+ require.Equal(t, total, len(statements)+1)
}
diff --git a/backend/plugin/parser/sql/differ/mysql/utils_test.go b/backend/plugin/parser/sql/differ/mysql/utils_test.go
index afce46725d..02ad128b72 100644
--- a/backend/plugin/parser/sql/differ/mysql/utils_test.go
+++ b/backend/plugin/parser/sql/differ/mysql/utils_test.go
@@ -13,7 +13,7 @@ func TestTrigger(t *testing.T) {
"CREATE DEFINER=`root`@`%` TRIGGER `ins_sum` BEFORE INSERT ON account FOR EACH ROW SET @sum = sum + NEW.amount * NEW.price;",
want: "ALTER TABLE `account` ADD COLUMN `price` INT AFTER `amount`;\n\n" +
"DROP TRIGGER IF EXISTS `ins_sum`;\n\n" +
- "CREATE DEFINER=`root`@`%` TRIGGER `ins_sum` BEFORE INSERT ON account FOR EACH ROW SET @sum = sum + NEW.amount * NEW.price;\n\n",
+ "CREATE DEFINER=`root`@`%` TRIGGER `ins_sum` BEFORE INSERT ON account FOR EACH ROW SET @sum = sum + NEW.amount * NEW.price\n;\n\n",
},
}
testDiffWithoutDisableForeignKeyCheck(t, tests)
@@ -28,7 +28,7 @@ func TestFunction(t *testing.T) {
"BEGIN DECLARE a INT; SET a = v; SET a = a * 1 + 1; RETURN a; END ;\n",
want: "DROP FUNCTION IF EXISTS `AddOne`;\n\n" +
"CREATE DEFINER=`root`@`%` FUNCTION `AddOne`(v INT) RETURNS int\n" +
- "BEGIN DECLARE a INT; SET a = v; SET a = a * 1 + 1; RETURN a; END ;\n\n",
+ "BEGIN DECLARE a INT; SET a = v; SET a = a * 1 + 1; RETURN a; END\n;\n\n",
},
}
testDiffWithoutDisableForeignKeyCheck(t, tests)
@@ -52,7 +52,7 @@ func TestProcedure(t *testing.T) {
"SQL SECURITY INVOKER\n" +
"BEGIN\n" +
"SELECT 'Number of accounts:', (COUNT(*)-1) FROM mysql.user;\n" +
- "END ;\n\n",
+ "END\n;\n\n",
},
}
testDiffWithoutDisableForeignKeyCheck(t, tests)
@@ -74,7 +74,8 @@ func TestEvent(t *testing.T) {
`CREATE EVENT purge_old_users
ON SCHEDULE EVERY 1 DAY STARTS '2023-07-01 00:00:00'
DO
- DELETE FROM users WHERE age > 110;
+ DELETE FROM users WHERE age > 110
+;
`,
},
diff --git a/backend/plugin/parser/sql/mysql.go b/backend/plugin/parser/sql/mysql.go
index ab0d2e27cb..2078d9c642 100644
--- a/backend/plugin/parser/sql/mysql.go
+++ b/backend/plugin/parser/sql/mysql.go
@@ -15,6 +15,7 @@ import (
// ParseMySQL parses the given SQL statement and returns the AST.
func ParseMySQL(statement string) (antlr.Tree, *antlr.CommonTokenStream, error) {
// deal with delimiter if needed
+ statement = strings.TrimRight(statement, " \r\n\t\f;") + "\n;"
has, list, err := hasDelimiter(statement)
if err != nil {
return nil, nil, err
diff --git a/backend/plugin/parser/sql/mysql_test.go b/backend/plugin/parser/sql/mysql_test.go
index f87e94ebc3..7bf48b8261 100644
--- a/backend/plugin/parser/sql/mysql_test.go
+++ b/backend/plugin/parser/sql/mysql_test.go
@@ -11,6 +11,13 @@ func TestMySQLParser(t *testing.T) {
statement string
errorMessage string
}{
+ {
+ statement: "aaa",
+ errorMessage: "line 1:0 extraneous input 'aaa' expecting {<EOF>, ALTER_SYMBOL, ANALYZE_SYMBOL, BEGIN_SYMBOL, BINLOG_SYMBOL, CACHE_SYMBOL, CALL_SYMBOL, CHANGE_SYMBOL, CHECKSUM_SYMBOL, CHECK_SYMBOL, COMMIT_SYMBOL, CREATE_SYMBOL, DEALLOCATE_SYMBOL, DELETE_SYMBOL, DESC_SYMBOL, DESCRIBE_SYMBOL, DO_SYMBOL, DROP_SYMBOL, EXECUTE_SYMBOL, EXPLAIN_SYMBOL, FLUSH_SYMBOL, FOR_SYMBOL, GET_SYMBOL, GRANT_SYMBOL, HANDLER_SYMBOL, HELP_SYMBOL, IMPORT_SYMBOL, INSERT_SYMBOL, INSTALL_SYMBOL, KILL_SYMBOL, LOAD_SYMBOL, LOCK_SYMBOL, OPTIMIZE_SYMBOL, PREPARE_SYMBOL, PURGE_SYMBOL, RELEASE_SYMBOL, RENAME_SYMBOL, REPAIR_SYMBOL, REPLACE_SYMBOL, RESET_SYMBOL, RESIGNAL_SYMBOL, REVOKE_SYMBOL, ROLLBACK_SYMBOL, SAVEPOINT_SYMBOL, SELECT_SYMBOL, SET_SYMBOL, SHOW_SYMBOL, SHUTDOWN_SYMBOL, SIGNAL_SYMBOL, START_SYMBOL, STOP_SYMBOL, TABLE_SYMBOL, TRUNCATE_SYMBOL, UNINSTALL_SYMBOL, UNLOCK_SYMBOL, UPDATE_SYMBOL, USE_SYMBOL, VALUES_SYMBOL, WITH_SYMBOL, XA_SYMBOL, CLONE_SYMBOL, RESTART_SYMBOL, ';', '('}",
+ },
+ {
+ statement: "select * from t;\n -- comments",
+ },
{
statement: "SELECT count(t.a) as TID from t1 as t;",
},
diff --git a/backend/plugin/parser/sql/plsql.go b/backend/plugin/parser/sql/plsql.go
index f1d764ad19..b0eaed080f 100644
--- a/backend/plugin/parser/sql/plsql.go
+++ b/backend/plugin/parser/sql/plsql.go
@@ -411,7 +411,7 @@ func (*ParseErrorListener) ReportContextSensitivity(recognizer antlr.Parser, dfa
// ParsePLSQL parses the given PLSQL.
func ParsePLSQL(sql string) (antlr.Tree, error) {
// The antlr parser requires a semicolon at the end of the SQL.
- sql = strings.TrimRight(sql, " \t\n\r\f;") + ";"
+ sql = strings.TrimRight(sql, " \t\n\r\f;") + "\n;"
lexer := parser.NewPlSqlLexer(antlr.NewInputStream(sql))
steam := antlr.NewCommonTokenStream(lexer, 0)
p := parser.NewPlSqlParser(steam)
diff --git a/backend/plugin/parser/sql/split_multi_sql_test.go b/backend/plugin/parser/sql/split_multi_sql_test.go
index 08d611bfef..fdceaaae41 100644
--- a/backend/plugin/parser/sql/split_multi_sql_test.go
+++ b/backend/plugin/parser/sql/split_multi_sql_test.go
@@ -343,8 +343,8 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
LastLine: 1,
},
{
- Text: `select * from t;`,
- LastLine: 3,
+ Text: "select * from t\n;",
+ LastLine: 4,
},
},
},
@@ -380,8 +380,9 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
RETURN income;
- END ;`,
- LastLine: 14,
+ END
+;`,
+ LastLine: 15,
},
},
},
@@ -391,8 +392,8 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []SingleSQL{
{
- Text: bigSQL,
- LastLine: 1,
+ Text: bigSQL + "\n;",
+ LastLine: 2,
},
},
},
@@ -406,8 +407,8 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
LastLine: 1,
},
{
- Text: "CREATE TABLE t1(a int)",
- LastLine: 1,
+ Text: "CREATE TABLE t1(a int)\n;",
+ LastLine: 2,
},
},
},
@@ -422,8 +423,8 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
LastLine: 1,
},
{
- Text: "INSERT INTO `tech_Book` VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\\'jdfl;\"ka');",
- LastLine: 2,
+ Text: "INSERT INTO `tech_Book` VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\\'jdfl;\"ka')\n;",
+ LastLine: 3,
},
},
},
@@ -447,8 +448,9 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
LastLine: 5,
},
{
- Text: `INSERT INTO tech_Book VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\'jdfl;"ka');`,
- LastLine: 7,
+ Text: `INSERT INTO tech_Book VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\'jdfl;"ka')
+;`,
+ LastLine: 8,
},
},
},
@@ -480,8 +482,9 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
LastLine: 8,
},
{
- Text: `SELECT @x;`,
- LastLine: 9,
+ Text: `SELECT @x
+;`,
+ LastLine: 10,
},
},
},
@@ -515,8 +518,8 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
LastLine: 9,
},
{
- Text: `SELECT @x;`,
- LastLine: 10,
+ Text: "SELECT @x\n;",
+ LastLine: 11,
},
},
},
@@ -531,8 +534,8 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
LastLine: 2,
},
{
- Text: "CREATE TABLE t1(b int);",
- LastLine: 3,
+ Text: "CREATE TABLE t1(b int)\n;",
+ LastLine: 4,
},
},
},
@@ -619,8 +622,9 @@ func TestMySQLSplitMultiSQLAndNormalize(t *testing.T) {
Text: `CREATE PROCEDURE p2()
BEGIN
SELECT count(*) from t;
- END;`,
- LastLine: 14,
+ END
+;`,
+ LastLine: 15,
},
},
},
diff --git a/backend/plugin/parser/sql/transform/mysql/transform_test.go b/backend/plugin/parser/sql/transform/mysql/transform_test.go
index 41f30c5090..67c7d2f2af 100644
--- a/backend/plugin/parser/sql/transform/mysql/transform_test.go
+++ b/backend/plugin/parser/sql/transform/mysql/transform_test.go
@@ -59,7 +59,7 @@ func TestTransform(t *testing.T) {
"CREATE PROCEDURE p1()" + "\n" +
" BEGIN" + "\n" +
" SELECT * FROM t;" + "\n" +
- " END;" + "\n" +
+ " END\n;" + "\n" +
"\n"
a := require.New(t)
diff --git a/backend/plugin/parser/sql/utils_test.go b/backend/plugin/parser/sql/utils_test.go
index cf17e3ad19..1ee5ed64d0 100644
--- a/backend/plugin/parser/sql/utils_test.go
+++ b/backend/plugin/parser/sql/utils_test.go
@@ -29,7 +29,8 @@ func TestExtractTiDBUnsupportStmts(t *testing.T) {
BEGIN
INSERT INTO orders_audit(order_id, order_date, customer_id, order_amount)
VALUES (NEW.order_id, NEW.order_date, NEW.customer_id, NEW.order_amount);
- END;`,
+ END
+;`,
},
wantSupport: "CREATE TABLE t1(id INT);\n",
wantErr: false,
diff --git a/backend/runner/taskcheck/statement_type_executor_test.go b/backend/runner/taskcheck/statement_type_executor_test.go
index 0fe74ffd90..02702597d6 100644
--- a/backend/runner/taskcheck/statement_type_executor_test.go
+++ b/backend/runner/taskcheck/statement_type_executor_test.go
@@ -23,7 +23,7 @@ type testData struct {
func TestStatementTypeCheck(t *testing.T) {
tests := []testData{
{
- stmt: "CREATE DATABASE db",
+ stmt: "CREATE DATABASE db\n;",
taskType: api.TaskDatabaseSchemaUpdate,
want: []api.TaskCheckResult{
{
@@ -31,13 +31,13 @@ func TestStatementTypeCheck(t *testing.T) {
Namespace: api.BBNamespace,
Code: common.TaskTypeCreateDatabase.Int(),
Title: "Cannot create database",
- Content: "The statement \"CREATE DATABASE db\" creates database",
+ Content: "The statement \"CREATE DATABASE db\n;\" creates database",
},
},
},
{
- stmt: "DROP DATABASE db",
+ stmt: "DROP DATABASE db\n;",
taskType: api.TaskDatabaseSchemaUpdate,
want: []api.TaskCheckResult{
{
@@ -45,12 +45,12 @@ func TestStatementTypeCheck(t *testing.T) {
Namespace: api.BBNamespace,
Code: common.TaskTypeDropDatabase.Int(),
Title: "Cannot drop database",
- Content: "The statement \"DROP DATABASE db\" drops database",
+ Content: "The statement \"DROP DATABASE db\n;\" drops database",
},
},
},
{
- stmt: "CREATE DATABASE db",
+ stmt: "CREATE DATABASE db\n;",
taskType: api.TaskDatabaseDataUpdate,
want: []api.TaskCheckResult{
{
@@ -58,19 +58,19 @@ func TestStatementTypeCheck(t *testing.T) {
Namespace: api.BBNamespace,
Code: common.TaskTypeCreateDatabase.Int(),
Title: "Cannot create database",
- Content: "The statement \"CREATE DATABASE db\" creates database",
+ Content: "The statement \"CREATE DATABASE db\n;\" creates database",
},
{
Status: api.TaskCheckStatusWarn,
Namespace: api.BBNamespace,
Code: common.TaskTypeNotDML.Int(),
Title: "Data change can only run DML",
- Content: "\"CREATE DATABASE db\" is not DML",
+ Content: "\"CREATE DATABASE db\n;\" is not DML",
},
},
},
{
- stmt: "DROP DATABASE db",
+ stmt: "DROP DATABASE db\n;",
taskType: api.TaskDatabaseDataUpdate,
want: []api.TaskCheckResult{
{
@@ -78,19 +78,19 @@ func TestStatementTypeCheck(t *testing.T) {
Namespace: api.BBNamespace,
Code: common.TaskTypeDropDatabase.Int(),
Title: "Cannot drop database",
- Content: "The statement \"DROP DATABASE db\" drops database",
+ Content: "The statement \"DROP DATABASE db\n;\" drops database",
},
{
Status: api.TaskCheckStatusWarn,
Namespace: api.BBNamespace,
Code: common.TaskTypeNotDML.Int(),
Title: "Data change can only run DML",
- Content: "\"DROP DATABASE db\" is not DML",
+ Content: "\"DROP DATABASE db\n;\" is not DML",
},
},
},
{
- stmt: "CREATE TABLE t(a int, b int)",
+ stmt: "CREATE TABLE t(a int, b int)\n;",
taskType: api.TaskDatabaseDataUpdate,
want: []api.TaskCheckResult{
{
@@ -98,12 +98,12 @@ func TestStatementTypeCheck(t *testing.T) {
Namespace: api.BBNamespace,
Code: common.TaskTypeNotDML.Int(),
Title: "Data change can only run DML",
- Content: "\"CREATE TABLE t(a int, b int)\" is not DML",
+ Content: "\"CREATE TABLE t(a int, b int)\n;\" is not DML",
},
},
},
{
- stmt: "ALTER TABLE t ADD COLUMN a int",
+ stmt: "ALTER TABLE t ADD COLUMN a int\n;",
taskType: api.TaskDatabaseDataUpdate,
want: []api.TaskCheckResult{
{
@@ -111,12 +111,12 @@ func TestStatementTypeCheck(t *testing.T) {
Namespace: api.BBNamespace,
Code: common.TaskTypeNotDML.Int(),
Title: "Data change can only run DML",
- Content: "\"ALTER TABLE t ADD COLUMN a int\" is not DML",
+ Content: "\"ALTER TABLE t ADD COLUMN a int\n;\" is not DML",
},
},
},
{
- stmt: "INSERT INTO t values(1, 2, 3)",
+ stmt: "INSERT INTO t values(1, 2, 3)\n;",
taskType: api.TaskDatabaseDataUpdate,
want: []api.TaskCheckResult(nil),
},
@@ -131,17 +131,17 @@ func TestStatementTypeCheck(t *testing.T) {
want: []api.TaskCheckResult(nil),
},
{
- stmt: "CREATE TABLE t(a int, b int)",
+ stmt: "CREATE TABLE t(a int, b int)\n;",
taskType: api.TaskDatabaseSchemaUpdate,
want: []api.TaskCheckResult(nil),
},
{
- stmt: "ALTER TABLE t ADD COLUMN a int",
+ stmt: "ALTER TABLE t ADD COLUMN a int\n;",
taskType: api.TaskDatabaseSchemaUpdate,
want: []api.TaskCheckResult(nil),
},
{
- stmt: "INSERT INTO t values(1, 2, 3)",
+ stmt: "INSERT INTO t values(1, 2, 3)\n;",
taskType: api.TaskDatabaseSchemaUpdate,
want: []api.TaskCheckResult{
{
@@ -149,7 +149,7 @@ func TestStatementTypeCheck(t *testing.T) {
Namespace: api.BBNamespace,
Code: common.TaskTypeNotDDL.Int(),
Title: "Alter schema can only run DDL",
- Content: "\"INSERT INTO t values(1, 2, 3)\" is not DDL",
+ Content: "\"INSERT INTO t values(1, 2, 3)\n;\" is not DDL",
},
},
},
@@ -160,12 +160,12 @@ func TestStatementTypeCheck(t *testing.T) {
},
}
- for _, test := range tests {
+ for i, test := range tests {
res, err := mysqlStatementTypeCheck(test.stmt, "", "", test.taskType)
require.NoError(t, err)
require.Equal(t, test.want, res)
res, err = postgresqlStatementTypeCheck(test.stmt, test.taskType)
require.NoError(t, err)
- require.Equal(t, test.want, res)
+ require.Equal(t, test.want, res, i)
}
}
diff --git a/backend/tests/test-data/sql_review_mysql.yaml b/backend/tests/test-data/sql_review_mysql.yaml
index 0f994ba301..f92e4c5ee0 100644
--- a/backend/tests/test-data/sql_review_mysql.yaml
+++ b/backend/tests/test-data/sql_review_mysql.yaml
@@ -6,6 +6,7 @@
title: OK
content: ""
line: 0
+ details: ""
run: false
- statement: CREATE TABLE user(id);
result:
@@ -13,8 +14,9 @@
code: 201
status: ERROR
title: Syntax error
- content: "line 1:20 mismatched input ')' expecting {BIGINT_SYMBOL, BINARY_SYMBOL, BIT_SYMBOL, BLOB_SYMBOL, BOOLEAN_SYMBOL, BOOL_SYMBOL, CHAR_SYMBOL, DATETIME_SYMBOL, DATE_SYMBOL, DECIMAL_SYMBOL, DOUBLE_SYMBOL, ENUM_SYMBOL, FIXED_SYMBOL, FLOAT_SYMBOL, GEOMETRYCOLLECTION_SYMBOL, GEOMETRY_SYMBOL, INT_SYMBOL, JSON_SYMBOL, LINESTRING_SYMBOL, LONGBLOB_SYMBOL, LONGTEXT_SYMBOL, LONG_SYMBOL, MEDIUMBLOB_SYMBOL, MEDIUMINT_SYMBOL, MEDIUMTEXT_SYMBOL, MULTILINESTRING_SYMBOL, MULTIPOINT_SYMBOL, MULTIPOLYGON_SYMBOL, NATIONAL_SYMBOL, NCHAR_SYMBOL, NUMERIC_SYMBOL, NVARCHAR_SYMBOL, POINT_SYMBOL, POLYGON_SYMBOL, REAL_SYMBOL, SERIAL_SYMBOL, SET_SYMBOL, SMALLINT_SYMBOL, TEXT_SYMBOL, TIMESTAMP_SYMBOL, TIME_SYMBOL, TINYBLOB_SYMBOL, TINYINT_SYMBOL, TINYTEXT_SYMBOL, VARBINARY_SYMBOL, VARCHAR_SYMBOL, YEAR_SYMBOL}"
+ content: line 1:20 mismatched input ')' expecting {BIGINT_SYMBOL, BINARY_SYMBOL, BIT_SYMBOL, BLOB_SYMBOL, BOOLEAN_SYMBOL, BOOL_SYMBOL, CHAR_SYMBOL, DATETIME_SYMBOL, DATE_SYMBOL, DECIMAL_SYMBOL, DOUBLE_SYMBOL, ENUM_SYMBOL, FIXED_SYMBOL, FLOAT_SYMBOL, GEOMETRYCOLLECTION_SYMBOL, GEOMETRY_SYMBOL, INT_SYMBOL, JSON_SYMBOL, LINESTRING_SYMBOL, LONGBLOB_SYMBOL, LONGTEXT_SYMBOL, LONG_SYMBOL, MEDIUMBLOB_SYMBOL, MEDIUMINT_SYMBOL, MEDIUMTEXT_SYMBOL, MULTILINESTRING_SYMBOL, MULTIPOINT_SYMBOL, MULTIPOLYGON_SYMBOL, NATIONAL_SYMBOL, NCHAR_SYMBOL, NUMERIC_SYMBOL, NVARCHAR_SYMBOL, POINT_SYMBOL, POLYGON_SYMBOL, REAL_SYMBOL, SERIAL_SYMBOL, SET_SYMBOL, SMALLINT_SYMBOL, TEXT_SYMBOL, TIMESTAMP_SYMBOL, TIME_SYMBOL, TINYBLOB_SYMBOL, TINYINT_SYMBOL, TINYTEXT_SYMBOL, VARBINARY_SYMBOL, VARCHAR_SYMBOL, YEAR_SYMBOL}
line: 0
+ details: ""
run: false
- statement: CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin
result:
@@ -22,152 +24,185 @@
code: 501
status: ERROR
title: engine.mysql.use-innodb
- content: '"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT ''comment'',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT ''comment'',content BLOB NOT NULL COMMENT ''comment'',json_content JSON NOT NULL COMMENT ''comment'',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin" doesn''t use InnoDB engine'
- line: 1
+ content: |-
+ "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin
+ ;" doesn't use InnoDB engine
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 601
status: ERROR
title: table.require-pk
content: Table `userTable` requires PRIMARY KEY
- line: 1
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 602
status: ERROR
title: table.no-foreign-key
content: Foreign key is not allowed in the table `userTable`
line: 1
+ details: ""
- namespace: bb.advisor
code: 411
status: ERROR
title: column.type-disallow-list
content: Disallow column type JSON but column `userTable`.`json_content` is
line: 1
+ details: ""
- namespace: bb.advisor
code: 301
status: WARN
title: naming.table
content: '`userTable` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 1
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 302
status: WARN
title: naming.column
content: '`userTable`.`roomId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
line: 1
+ details: ""
- namespace: bb.advisor
code: 303
status: WARN
title: naming.index.idx
content: Index in table `userTable` mismatches the naming convention, expect "^$|^idx_userTable_name$" but found `idx1`
line: 1
+ details: ""
- namespace: bb.advisor
code: 304
status: WARN
title: naming.index.uk
content: Unique key in table `userTable` mismatches the naming convention, expect "^$|^uk_userTable_id_name$" but found `uk1`
line: 1
+ details: ""
- namespace: bb.advisor
code: 305
status: WARN
title: naming.index.fk
content: Foreign key in table `userTable` mismatches the naming convention, expect "^$|^fk_userTable_roomId_room_id$" but found `fk1`
line: 1
+ details: ""
- namespace: bb.advisor
code: 605
status: WARN
title: table.comment
content: Table `userTable` requires comments
- line: 1
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 401
status: WARN
title: column.required
- content: "Table `userTable` requires columns: created_ts, creator_id, updated_ts, updater_id"
- line: 1
+ content: 'Table `userTable` requires columns: created_ts, creator_id, updated_ts, updater_id'
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 402
status: WARN
title: column.no-null
- content: "`userTable`.`name` cannot have NULL value"
+ content: '`userTable`.`name` cannot have NULL value'
line: 1
+ details: ""
- namespace: bb.advisor
code: 402
status: WARN
title: column.no-null
- content: "`userTable`.`roomId` cannot have NULL value"
+ content: '`userTable`.`roomId` cannot have NULL value'
line: 1
+ details: ""
- namespace: bb.advisor
code: 404
status: WARN
title: column.set-default-for-not-null
content: Column `userTable`.`id` is NOT NULL but doesn't have DEFAULT
line: 1
+ details: ""
- namespace: bb.advisor
code: 408
status: WARN
title: column.comment
content: Column `userTable`.`id` requires comments
line: 1
+ details: ""
- namespace: bb.advisor
code: 408
status: WARN
title: column.comment
content: Column `userTable`.`name` requires comments
line: 1
+ details: ""
- namespace: bb.advisor
code: 408
status: WARN
title: column.comment
content: Column `userTable`.`roomId` requires comments
line: 1
+ details: ""
- namespace: bb.advisor
code: 414
status: WARN
title: column.disallow-set-charset
- content: Disallow set column charset but "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin" does
- line: 1
+ content: |-
+ Disallow set column charset but "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin
+ ;" does
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 419
status: WARN
title: column.current-time-count-limit
content: Table `userTable` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.
- line: 1
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 420
status: WARN
title: column.require-default
content: Column `userTable`.`id` doesn't have DEFAULT.
line: 1
+ details: ""
- namespace: bb.advisor
code: 420
status: WARN
title: column.require-default
content: Column `userTable`.`name` doesn't have DEFAULT.
line: 1
+ details: ""
- namespace: bb.advisor
code: 420
status: WARN
title: column.require-default
content: Column `userTable`.`roomId` doesn't have DEFAULT.
line: 1
+ details: ""
- namespace: bb.advisor
code: 804
status: WARN
title: index.type-no-blob
content: Columns in index must not be BLOB but `userTable`.`content` is blob
line: 1
+ details: ""
- namespace: bb.advisor
code: 1001
status: WARN
title: system.charset.allowlist
- content: '"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT ''comment'',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT ''comment'',content BLOB NOT NULL COMMENT ''comment'',json_content JSON NOT NULL COMMENT ''comment'',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin" used disabled charset ''ascii'''
+ content: |-
+ "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin
+ ;" used disabled charset 'ascii'
line: 1
+ details: ""
- namespace: bb.advisor
code: 1201
status: WARN
title: system.collation.allowlist
- content: '"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT ''comment'',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT ''comment'',content BLOB NOT NULL COMMENT ''comment'',json_content JSON NOT NULL COMMENT ''comment'',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin" used disabled collation ''latin1_bin'''
- line: 1
+ content: |-
+ "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin
+ ;" used disabled collation 'latin1_bin'
+ line: 2
+ details: ""
run: false
- statement: CREATE TABLE t_auto(auto_id varchar(20) AUTO_INCREMENT PRIMARY KEY COMMENT 'COMMENT') auto_increment = 2 COMMENT 'comment'
result:
@@ -176,58 +211,73 @@
status: ERROR
title: column.auto-increment-must-integer
content: Auto-increment column `t_auto`.`auto_id` requires integer type
- line: 1
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 307
status: WARN
title: naming.column.auto-increment
content: '`t_auto`.`auto_id` mismatches auto_increment column naming convention, naming format should be "^id$"'
line: 1
+ details: ""
- namespace: bb.advisor
code: 401
status: WARN
title: column.required
- content: "Table `t_auto` requires columns: created_ts, creator_id, id, updated_ts, updater_id"
- line: 1
+ content: 'Table `t_auto` requires columns: created_ts, creator_id, id, updated_ts, updater_id'
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 416
status: WARN
title: column.auto-increment-initial-value
content: The initial auto-increment value in table `t_auto` is 2, which doesn't equal 20
- line: 1
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 417
status: WARN
title: column.auto-increment-must-unsigned
content: Auto-increment column `t_auto`.`auto_id` is not UNSIGNED type
- line: 1
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 803
status: WARN
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t_auto`.`auto_id` is varchar(20)
line: 1
+ details: ""
run: false
-- statement: " DELETE FROM tech_book"
+- statement: ' DELETE FROM tech_book'
result:
- namespace: bb.advisor
code: 202
status: ERROR
title: statement.where.require
- content: '"DELETE FROM tech_book" requires WHERE clause'
- line: 1
+ content: |-
+ "DELETE FROM tech_book
+ ;" requires WHERE clause
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"DELETE FROM tech_book" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
- line: 1
+ content: |-
+ "DELETE FROM tech_book
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 209
status: WARN
title: statement.affected-row-limit
- content: '"DELETE FROM tech_book" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
- line: 1
+ content: |-
+ "DELETE FROM tech_book
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist
+ line: 2
+ details: ""
run: false
- statement: DELETE FROM tech_book WHERE name like `%abc`
result:
@@ -235,68 +285,98 @@
code: 204
status: ERROR
title: statement.where.no-leading-wildcard-like
- content: '"DELETE FROM tech_book WHERE name like `%abc`" uses leading wildcard LIKE'
- line: 1
+ content: |-
+ "DELETE FROM tech_book WHERE name like `%abc`
+ ;" uses leading wildcard LIKE
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"DELETE FROM tech_book WHERE name like `%abc`" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
- line: 1
+ content: |-
+ "DELETE FROM tech_book WHERE name like `%abc`
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 209
status: WARN
title: statement.affected-row-limit
- content: '"DELETE FROM tech_book WHERE name like `%abc`" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
- line: 1
+ content: |-
+ "DELETE FROM tech_book WHERE name like `%abc`
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist
+ line: 2
+ details: ""
run: false
-- statement: " INSERT INTO t_copy SELECT * FROM t"
+- statement: ' INSERT INTO t_copy SELECT * FROM t'
result:
- namespace: bb.advisor
code: 203
status: ERROR
title: statement.select.no-select-all
- content: '"INSERT INTO t_copy SELECT * FROM t" uses SELECT all'
- line: 1
+ content: |-
+ "INSERT INTO t_copy SELECT * FROM t
+ ;" uses SELECT all
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 202
status: ERROR
title: statement.where.require
- content: '"INSERT INTO t_copy SELECT * FROM t" requires WHERE clause'
- line: 1
+ content: |-
+ "INSERT INTO t_copy SELECT * FROM t
+ ;" requires WHERE clause
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"INSERT INTO t_copy SELECT * FROM t" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.t_copy'' doesn''t exist'
- line: 1
+ content: |-
+ "INSERT INTO t_copy SELECT * FROM t
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t_copy' doesn't exist
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 1101
status: WARN
title: statement.insert.row-limit
- content: '"INSERT INTO t_copy SELECT * FROM t" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.t_copy'' doesn''t exist'
- line: 1
+ content: |-
+ "INSERT INTO t_copy SELECT * FROM t
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t_copy' doesn't exist
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 1107
status: WARN
title: statement.insert.must-specify-column
- content: The INSERT statement must specify columns but "INSERT INTO t_copy SELECT * FROM t" does not
- line: 1
+ content: |-
+ The INSERT statement must specify columns but "INSERT INTO t_copy SELECT * FROM t
+ ;" does not
+ line: 2
+ details: ""
run: false
-- statement: " INSERT INTO t VALUES (1, 1, now(), 1, now())"
+- statement: ' INSERT INTO t VALUES (1, 1, now(), 1, now())'
result:
- namespace: bb.advisor
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"INSERT INTO t VALUES (1, 1, now(), 1, now())" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.t'' doesn''t exist'
- line: 1
+ content: |-
+ "INSERT INTO t VALUES (1, 1, now(), 1, now())
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t' doesn't exist
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 1107
status: WARN
title: statement.insert.must-specify-column
- content: The INSERT statement must specify columns but "INSERT INTO t VALUES (1, 1, now(), 1, now())" does not
- line: 1
+ content: |-
+ The INSERT statement must specify columns but "INSERT INTO t VALUES (1, 1, now(), 1, now())
+ ;" does not
+ line: 2
+ details: ""
run: false
- statement: DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')
result:
@@ -304,14 +384,20 @@
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = ''bytebase'')" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
- line: 1
+ content: |-
+ "DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 209
status: WARN
title: statement.affected-row-limit
- content: '"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = ''bytebase'')" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
- line: 1
+ content: |-
+ "DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')
+ ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist
+ line: 2
+ details: ""
run: false
- statement: COMMIT;
result:
@@ -319,8 +405,11 @@
code: 206
status: ERROR
title: statement.disallow-commit
- content: 'Commit is not allowed, related statement: "COMMIT;"'
- line: 1
+ content: |-
+ Commit is not allowed, related statement: "COMMIT
+ ;"
+ line: 2
+ details: ""
run: false
- statement: CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'comment',room_id INT NOT NULL DEFAULT 0 COMMENT 'comment',creator_id INT NOT NULL DEFAULT 0 COMMENT 'comment',created_ts TIMESTAMP NOT NULL DEFAULT NOW() COMMENT 'comment',updater_id INT NOT NULL DEFAULT 0 COMMENT 'comment',updated_ts TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',INDEX idx_user_name(name),UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment'
result:
@@ -330,6 +419,7 @@
title: OK
content: ""
line: 0
+ details: ""
run: true
- statement: INSERT INTO user(id, name) values (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')
result:
@@ -339,6 +429,7 @@
title: OK
content: ""
line: 0
+ details: ""
run: true
- statement: DELETE FROM user WHERE id < 10
result:
@@ -348,6 +439,7 @@
title: OK
content: ""
line: 0
+ details: ""
run: false
- statement: INSERT INTO user(id, name) values (6, 'f'), (7, 'g'), (8, 'h'), (9, 'i'), (10, 'j')
result:
@@ -357,6 +449,7 @@
title: OK
content: ""
line: 0
+ details: ""
run: true
- statement: DELETE FROM user WHERE id <= 10
result:
@@ -364,8 +457,11 @@
code: 209
status: WARN
title: statement.affected-row-limit
- content: '"DELETE FROM user WHERE id <= 10" affected 10 rows. The count exceeds 5.'
- line: 1
+ content: |-
+ "DELETE FROM user WHERE id <= 10
+ ;" affected 10 rows. The count exceeds 5.
+ line: 2
+ details: ""
run: false
- statement: |-
INSERT INTO user(id, name) SELECT id, name FROM (SELECT 1 AS id, 'a' AS name WHERE 1=1 UNION ALL
@@ -393,8 +489,10 @@
SELECT 7 AS id, 'g' AS name WHERE 1=1 UNION ALL
SELECT 8 AS id, 'h' AS name WHERE 1=1 UNION ALL
SELECT 9 AS id, 'i' AS name WHERE 1=1 UNION ALL
- SELECT 10 AS id, 'j' AS name WHERE 1=1) value_table WHERE 1=1" inserts 10 rows. The count exceeds 5.
- line: 10
+ SELECT 10 AS id, 'j' AS name WHERE 1=1) value_table WHERE 1=1
+ ;" inserts 10 rows. The count exceeds 5.
+ line: 11
+ details: ""
run: false
- statement: INSERT INTO user(id, name) SELECT id, name FROM user WHERE id=1 LIMIT 1
result:
@@ -402,65 +500,80 @@
code: 1103
status: WARN
title: statement.disallow-limit
- content: LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO user(id, name) SELECT id, name FROM user WHERE id=1 LIMIT 1" uses
- line: 1
+ content: |-
+ LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO user(id, name) SELECT id, name FROM user WHERE id=1 LIMIT 1
+ ;" uses
+ line: 2
+ details: ""
run: false
-- statement: " ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8;"
+- statement: ' ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8;'
result:
- namespace: bb.advisor
code: 608
status: WARN
title: table.disallow-partition
- content: Table partition is forbidden, but "ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8;" creates
- line: 1
+ content: |-
+ Table partition is forbidden, but "ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8
+ ;" creates
+ line: 2
+ details: ""
run: false
- statement: |4-
- ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;
- ALTER TABLE user ADD COLUMN c_column int NOT NULL DEFAULT 0 COMMENT 'comment';
+ ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;
+ ALTER TABLE user ADD COLUMN c_column int NOT NULL DEFAULT 0 COMMENT 'comment';
result:
- namespace: bb.advisor
code: 207
status: WARN
title: statement.merge-alter-table
content: There are 2 statements to modify table `user`
- line: 2
+ line: 3
+ details: ""
- namespace: bb.advisor
code: 403
status: WARN
title: column.disallow-change-type
content: '"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '''' COMMENT ''COMMENT'' FIRST;" changes column type'
line: 1
+ details: ""
- namespace: bb.advisor
code: 406
status: WARN
title: column.disallow-change
content: '"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '''' COMMENT ''COMMENT'' FIRST;" contains CHANGE COLUMN statement'
line: 1
+ details: ""
- namespace: bb.advisor
code: 407
status: WARN
title: column.disallow-changing-order
content: '"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '''' COMMENT ''COMMENT'' FIRST;" changes column order'
line: 1
+ details: ""
- namespace: bb.advisor
code: 111
status: WARN
title: schema.backward-compatibility
content: '"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '''' COMMENT ''COMMENT'' FIRST;" may cause incompatibility with the existing data and code'
line: 1
+ details: ""
run: false
-- statement: " DROP TABLE user;"
+- statement: ' DROP TABLE user;'
result:
- namespace: bb.advisor
code: 603
status: ERROR
title: table.drop-naming-convention
content: '`user` mismatches drop table naming convention, naming format should be "_delete$"'
- line: 1
+ line: 2
+ details: ""
- namespace: bb.advisor
code: 103
status: WARN
title: schema.backward-compatibility
- content: '"DROP TABLE user;" may cause incompatibility with the existing data and code'
- line: 1
+ content: |-
+ "DROP TABLE user
+ ;" may cause incompatibility with the existing data and code
+ line: 2
+ details: ""
run: false
diff --git a/go.mod b/go.mod
index f0876af57e..ecdb0b6fd8 100644
--- a/go.mod
+++ b/go.mod
@@ -12,8 +12,8 @@ require (
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.60
github.com/aws/aws-sdk-go-v2/service/s3 v1.31.1
github.com/blang/semver/v4 v4.0.0
- github.com/bytebase/mysql-parser v0.0.0-20230608081517-18ca6de4af0d
- github.com/bytebase/plsql-parser v0.0.0-20230605065610-558b30eea9da
+ github.com/bytebase/mysql-parser v0.0.0-20230612050356-4592d9ba30da
+ github.com/bytebase/plsql-parser v0.0.0-20230612081829-80675dfad134
github.com/bytebase/snowsql-parser v0.0.0-20230609063735-32997ba8276c
github.com/casbin/casbin/v2 v2.66.2
github.com/cenkalti/backoff/v4 v4.2.0
diff --git a/go.sum b/go.sum
index 2a6f253ceb..cf5a1dc7de 100644
--- a/go.sum
+++ b/go.sum
@@ -137,12 +137,12 @@ github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao=
github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
github.com/bytebase/gh-ost v1.1.3-0.20220728080340-11d9c9027651 h1:NpoTuRY6Ckj37zTlEax/UTfvHCOdanI5/5dVCarOD18=
github.com/bytebase/gh-ost v1.1.3-0.20220728080340-11d9c9027651/go.mod h1:/HsnX0+34LXVz3MxtZoW15GiwEOXz/PrEhutjb3icfE=
-github.com/bytebase/mysql-parser v0.0.0-20230608081517-18ca6de4af0d h1:G5SX1AuJgWoe1lksSFeZaJFfAYyWqHnhm13cbabgkng=
-github.com/bytebase/mysql-parser v0.0.0-20230608081517-18ca6de4af0d/go.mod h1:n22yoTeLcphIYQlV6nbufQbHMxNceOjeGDOrpaRIhiY=
+github.com/bytebase/mysql-parser v0.0.0-20230612050356-4592d9ba30da h1:DlK8ipp+tzhEPNBmOLG0wBhM+cYX3leGTh+8lomML2U=
+github.com/bytebase/mysql-parser v0.0.0-20230612050356-4592d9ba30da/go.mod h1:n22yoTeLcphIYQlV6nbufQbHMxNceOjeGDOrpaRIhiY=
github.com/bytebase/pg_query_go/v2 v2.0.0-20221123093650-17425d1d18b7 h1:RDN6UnjTq4HR4LKrN8Yav4XfwUoGRjTocvWmzGr6Usc=
github.com/bytebase/pg_query_go/v2 v2.0.0-20221123093650-17425d1d18b7/go.mod h1:XAxmVqz1tEGqizcQ3YSdN90vCOHBWjJi8URL1er5+cA=
-github.com/bytebase/plsql-parser v0.0.0-20230605065610-558b30eea9da h1:xZB0WhAyVS5aQKPoNkutxcSGE9AUnTatJkgcKvW+S3k=
-github.com/bytebase/plsql-parser v0.0.0-20230605065610-558b30eea9da/go.mod h1:kL1Tk89SNE7wPnUzkVMJ9v012an5z8as7OUmkapJQGs=
+github.com/bytebase/plsql-parser v0.0.0-20230612081829-80675dfad134 h1:4NWP76NVYstvWPtZu4JwRmKDHK+1PudmODEdCQLfU8g=
+github.com/bytebase/plsql-parser v0.0.0-20230612081829-80675dfad134/go.mod h1:kL1Tk89SNE7wPnUzkVMJ9v012an5z8as7OUmkapJQGs=
github.com/bytebase/snowsql-parser v0.0.0-20230609063735-32997ba8276c h1:jZVqlqqBt5obROzTJ848jfzXhKcX9bLyn8f88xbGkak=
github.com/bytebase/snowsql-parser v0.0.0-20230609063735-32997ba8276c/go.mod h1:gJ1aclz1e9xLArQTbCpDjL+A79Jt3Ro9+/QEw8A6vMM=
github.com/bytebase/tidb v0.0.0-20230329095902-fe196d3c77d0 h1:h0LzCFbiCKWy/TbnE5amjDf+/j+06chImQwEhe+TbHc=