Skip to content

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

feat: display right column and line (#9529)

rebelicec06d5c1ac874
diff --git a/backend/api/v1/rollout_service_test.go b/backend/api/v1/rollout_service_test.go
index 39f62f4bb2..b4bb206f57 100644
--- a/backend/api/v1/rollout_service_test.go
+++ b/backend/api/v1/rollout_service_test.go
@@ -38,7 +38,7 @@ func TestGetStatementsFromSchemaGroups(t *testing.T) {
schemaGroupMatchedTables: map[string][]string{
"schema group 1": {"salary_01"},
},
- expectedStatements: []string{"ALTER TABLE salary_01 ADD COLUMN num INT\n;\n"},
+ expectedStatements: []string{"ALTER TABLE salary_01 ADD COLUMN num INT;\n"},
expectedSchemaGroupNames: []string{"projects/p2/databaseGroups/g1/schemaGroups/schema group 1"},
},
{
@@ -80,7 +80,7 @@ ALTER TABLE singleton ADD COLUMN num INT;`,
expectedStatements: []string{
"ALTER TABLE salary_01 ADD COLUMN num INT;\n\nCREATE INDEX salary_01_num_idx ON salary_01 (num);\n",
"ALTER TABLE salary_02 ADD COLUMN num INT;\n\nCREATE INDEX salary_02_num_idx ON salary_02 (num);\n",
- "\nCREATE TABLE singleton(id INT);\n\nALTER TABLE person ADD COLUMN name VARCHAR(30);\n\nALTER TABLE partpartially ADD COLUMN num INT;\n\nALTER TABLE singleton ADD COLUMN num INT\n;\n",
+ "\nCREATE TABLE singleton(id INT);\n\nALTER TABLE person ADD COLUMN name VARCHAR(30);\n\nALTER TABLE partpartially ADD COLUMN num INT;\n\nALTER TABLE singleton ADD COLUMN num INT;\n",
},
expectedSchemaGroupNames: []string{
"projects/p2/databaseGroups/g1/schemaGroups/schema group 1",
@@ -117,7 +117,7 @@ ALTER TABLE singleton ADD COLUMN num INT;`,
"ALTER TABLE salary_02 ADD COLUMN num INT;\n\nCREATE INDEX salary_02_num_idx ON salary_02 (num);\n",
"\nCREATE TABLE singleton_00(id INT);\n",
"\nALTER TABLE person ADD COLUMN name VARCHAR(30);\n\nALTER TABLE partpartially ADD COLUMN num INT;\n",
- "\nALTER TABLE singleton_00 ADD COLUMN num INT\n;\n",
+ "\nALTER TABLE singleton_00 ADD COLUMN num INT;\n",
},
expectedSchemaGroupNames: []string{
"projects/p2/databaseGroups/g1/schemaGroups/schema group 1",
diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml
index c84eb6f231..e14c67a7af 100644
--- a/backend/plugin/advisor/tidb/test/column_auto_increment_initial_value.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml
index d23d0b34d5..97c05daa3f 100644
--- a/backend/plugin/advisor/tidb/test/column_auto_increment_must_integer.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml b/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml
index 7c72ff8355..659bc82ee4 100644
--- a/backend/plugin/advisor/tidb/test/column_auto_increment_must_unsigned.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_comment.yaml b/backend/plugin/advisor/tidb/test/column_comment.yaml
index 1e764ba49f..e0d2456fa1 100644
--- a/backend/plugin/advisor/tidb/test/column_comment.yaml
+++ b/backend/plugin/advisor/tidb/test/column_comment.yaml
@@ -16,19 +16,19 @@
code: 409
title: column.comment
content: The length of column `t`.`a` comment should be within 10 characters
- line: 2
+ line: 1
details: ""
- status: WARN
code: 408
title: column.comment
content: Column `t`.`b` requires comments
- line: 3
+ line: 2
details: ""
- status: WARN
code: 408
title: column.comment
content: Column `t`.`c` requires comments
- line: 4
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int COMMENT 'comment');
@@ -38,7 +38,7 @@
code: 408
title: column.comment
content: Column `t`.`b` requires comments
- line: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int COMMENT 'this is comment');
@@ -48,13 +48,13 @@
code: 409
title: column.comment
content: The length of column `t`.`a` comment should be within 10 characters
- line: 1
+ line: 0
details: ""
- status: WARN
code: 408
title: column.comment
content: Column `t`.`b` requires comments
- line: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(b int COMMENT 'It is comment');
@@ -64,13 +64,13 @@
code: 409
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- line: 1
+ line: 0
details: ""
- status: WARN
code: 408
title: column.comment
content: Column `t`.`b` requires comments
- line: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(b int COMMENT 'It is COMMENT');
@@ -80,11 +80,11 @@
code: 409
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- line: 1
+ line: 0
details: ""
- status: WARN
code: 409
title: column.comment
content: The length of column `t`.`b` comment should be within 10 characters
- line: 3
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml b/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml
index f5b200b722..003d5a7655 100644
--- a/backend/plugin/advisor/tidb/test/column_current_time_count_limit.yaml
+++ b/backend/plugin/advisor/tidb/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: 6
+ line: 4
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: 5
+ line: 3
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: 3
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_change.yaml b/backend/plugin/advisor/tidb/test/column_disallow_change.yaml
index 48b6696a3c..0b84d20f52 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_change.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_change.yaml
@@ -17,7 +17,6 @@
title: column.disallow-change
content: |-
"
- ALTER TABLE t CHANGE COLUMN b a int
- ;" contains CHANGE COLUMN statement
- line: 3
+ ALTER TABLE t CHANGE COLUMN b a int;" contains CHANGE COLUMN statement
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml b/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml
index 54ccb860b1..5a72de0a7c 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_change_type.yaml
@@ -4,9 +4,8 @@
code: 403
title: column.disallow-change-type
content: |-
- "ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED
- ;" changes column type
- line: 2
+ "ALTER TABLE tech_book MODIFY id INTEGER UNSIGNED;" changes column type
+ line: 0
details: ""
- statement: ALTER TABLE tech_book MODIFY id int
want:
@@ -22,9 +21,8 @@
code: 403
title: column.disallow-change-type
content: |-
- "ALTER TABLE tech_book MODIFY id bigint
- ;" changes column type
- line: 2
+ "ALTER TABLE tech_book MODIFY id bigint;" changes column type
+ line: 0
details: ""
- statement: ALTER TABLE tech_book CHANGE name uname varchar(20)
want:
@@ -32,7 +30,6 @@
code: 403
title: column.disallow-change-type
content: |-
- "ALTER TABLE tech_book CHANGE name uname varchar(20)
- ;" changes column type
- line: 2
+ "ALTER TABLE tech_book CHANGE name uname varchar(20);" changes column type
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml b/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml
index d600fbc3ca..03832c139f 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_changing_order.yaml
@@ -17,9 +17,8 @@
title: column.disallow-changing-order
content: |-
"
- ALTER TABLE t MODIFY COLUMN a int FIRST
- ;" changes column order
- line: 3
+ ALTER TABLE t MODIFY COLUMN a int FIRST;" changes column order
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(b int, a1 int);
@@ -30,9 +29,8 @@
title: column.disallow-changing-order
content: |-
"
- ALTER TABLE t CHANGE COLUMN a1 a int FIRST
- ;" changes column order
- line: 3
+ ALTER TABLE t CHANGE COLUMN a1 a int FIRST;" changes column order
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int, b int);
@@ -43,9 +41,8 @@
title: column.disallow-changing-order
content: |-
"
- ALTER TABLE t MODIFY COLUMN a int AFTER b
- ;" changes column order
- line: 3
+ ALTER TABLE t MODIFY COLUMN a int AFTER b;" changes column order
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a1 int, b int);
@@ -56,7 +53,6 @@
title: column.disallow-changing-order
content: |-
"
- ALTER TABLE t CHANGE COLUMN a1 a int AFTER b
- ;" changes column order
- line: 3
+ ALTER TABLE t CHANGE COLUMN a1 a int AFTER b;" changes column order
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml b/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml
index 2b3c284b70..c4e9a109c0 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_drop_in_index.yaml
@@ -17,7 +17,7 @@
code: 424
title: "column.disallow-drop-in-index"
content: "`t`.`b` cannot drop index column"
- line: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int, c int, INDEX idx_ac(a,c));
@@ -27,7 +27,7 @@
code: 424
title: "column.disallow-drop-in-index"
content: "`t`.`c` cannot drop index column"
- line: 3
+ line: 1
details: ""
- statement: |-
@@ -51,11 +51,11 @@
code: 424
title: "column.disallow-drop-in-index"
content: "`t`.`a` cannot drop index column"
- line: 2
+ line: 1
details: ""
- status: WARN
code: 424
title: "column.disallow-drop-in-index"
content: "`t`.`c` cannot drop index column"
- line: 4
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml b/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml
index 7125519720..6bd8ac847e 100644
--- a/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml
+++ b/backend/plugin/advisor/tidb/test/column_disallow_set_charset.yaml
@@ -22,9 +22,8 @@
code: 414
title: column.disallow-set-charset
content: |-
- Disallow set column charset but "CREATE TABLE t(a varchar(20) CHARSET ascii)
- ;" does
- line: 2
+ Disallow set column charset but "CREATE TABLE t(a varchar(20) CHARSET ascii);" does
+ line: 0
details: ""
- statement: ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET ascii
want:
@@ -32,9 +31,8 @@
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: 2
+ Disallow set column charset but "ALTER TABLE tech_book ADD COLUMN a varchar(20) CHARSET ascii;" does
+ line: 0
details: ""
- statement: ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii
want:
@@ -42,9 +40,8 @@
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: 2
+ Disallow set column charset but "ALTER TABLE tech_book MODIFY COLUMN id varchar(20) CHARSET ascii;" does
+ line: 0
details: ""
- statement: ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii
want:
@@ -52,7 +49,6 @@
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: 2
+ Disallow set column charset but "ALTER TABLE tech_book CHANGE COLUMN name name varchar(20) CHARSET ascii;" does
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml b/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml
index a826b65ac6..257a06c887 100644
--- a/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml
+++ b/backend/plugin/advisor/tidb/test/column_maximum_character_length.yaml
@@ -20,7 +20,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: 0
details: ""
- statement: ALTER TABLE tech_book ADD COLUMN name_2 char(225)
want:
@@ -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: 2
+ line: 0
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: 2
+ line: 0
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: 2
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_no_null.yaml b/backend/plugin/advisor/tidb/test/column_no_null.yaml
index c91a3aa86d..9c9e2c4e3a 100644
--- a/backend/plugin/advisor/tidb/test/column_no_null.yaml
+++ b/backend/plugin/advisor/tidb/test/column_no_null.yaml
@@ -6,30 +6,30 @@
- status: WARN
code: 402
title: column.no-null
- content: '`book`.`id` cannot have NULL value'
- line: 2
+ content: "`book`.`id` cannot have NULL value"
+ line: 1
details: ""
- status: WARN
code: 402
title: column.no-null
- content: '`book`.`name` cannot have NULL value'
- line: 3
+ content: "`book`.`name` cannot have NULL value"
+ line: 2
details: ""
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255))
want:
- status: WARN
code: 402
title: column.no-null
- content: '`book`.`name` cannot have NULL value'
- line: 1
+ content: "`book`.`name` cannot have NULL value"
+ line: 0
details: ""
- statement: CREATE TABLE book(id int NOT NULL, name varchar(255))
want:
- status: WARN
code: 402
title: column.no-null
- content: '`book`.`name` cannot have NULL value'
- line: 1
+ content: "`book`.`name` cannot have NULL value"
+ line: 0
details: ""
- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL)
want:
@@ -46,8 +46,8 @@
- status: WARN
code: 402
title: column.no-null
- content: '`book`.`id` cannot have NULL value'
- line: 3
+ content: "`book`.`id` cannot have NULL value"
+ line: 1
details: ""
- statement: |-
CREATE TABLE book(a int NOT NULL);
@@ -66,8 +66,8 @@
- status: WARN
code: 402
title: column.no-null
- content: '`book`.`name` cannot have NULL value'
- line: 3
+ content: "`book`.`name` cannot have NULL value"
+ line: 1
details: ""
- statement: |-
CREATE TABLE book(id int NOT NULL);
diff --git a/backend/plugin/advisor/tidb/test/column_require_default.yaml b/backend/plugin/advisor/tidb/test/column_require_default.yaml
index ed80fca205..8027324e79 100644
--- a/backend/plugin/advisor/tidb/test/column_require_default.yaml
+++ b/backend/plugin/advisor/tidb/test/column_require_default.yaml
@@ -16,7 +16,7 @@
code: 420
title: column.require-default
content: Column `t`.`a` doesn't have DEFAULT.
- line: 2
+ line: 1
details: ""
- statement: |-
ALTER TABLE tech_book ADD COLUMN a BLOB;
@@ -27,11 +27,11 @@
code: 420
title: column.require-default
content: Column `tech_book`.`b` doesn't have DEFAULT.
- line: 2
+ line: 1
details: ""
- status: WARN
code: 420
title: column.require-default
content: Column `tech_book`.`a` doesn't have DEFAULT.
- line: 4
+ line: 2
details: ""
diff --git a/backend/plugin/advisor/tidb/test/column_required.yaml b/backend/plugin/advisor/tidb/test/column_required.yaml
index fe2b0c2998..a2c94ab133 100644
--- a/backend/plugin/advisor/tidb/test/column_required.yaml
+++ b/backend/plugin/advisor/tidb/test/column_required.yaml
@@ -3,8 +3,8 @@
- status: WARN
code: 401
title: column.required
- content: 'Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id'
- line: 2
+ content: "Table `book` requires columns: created_ts, creator_id, updated_ts, updater_id"
+ line: 0
details: ""
- statement: |-
CREATE TABLE book(
@@ -32,8 +32,8 @@
- status: WARN
code: 401
title: column.required
- content: 'Table `book` requires columns: creator_id'
- line: 8
+ content: "Table `book` requires columns: creator_id"
+ line: 6
details: ""
- statement: |-
CREATE TABLE book(
@@ -62,8 +62,8 @@
- status: WARN
code: 401
title: column.required
- content: 'Table `book` requires columns: creator_id'
- line: 8
+ content: "Table `book` requires columns: creator_id"
+ line: 6
details: ""
- statement: |-
CREATE TABLE book(
@@ -92,8 +92,8 @@
- status: WARN
code: 401
title: column.required
- content: 'Table `book` requires columns: creator_id'
- line: 8
+ content: "Table `book` requires columns: creator_id"
+ line: 6
details: ""
- statement: |-
CREATE TABLE book(
@@ -122,8 +122,8 @@
- status: WARN
code: 401
title: column.required
- content: 'Table `book` requires columns: updater_id'
- line: 5
+ content: "Table `book` requires columns: updater_id"
+ line: 4
details: ""
- statement: |-
CREATE TABLE book(
@@ -154,14 +154,14 @@
- status: WARN
code: 401
title: column.required
- content: 'Table `book` requires columns: creator_id'
- line: 5
+ content: "Table `book` requires columns: creator_id"
+ line: 4
details: ""
- status: WARN
code: 401
title: column.required
- content: 'Table `student` requires columns: creator_id, updater_id'
- line: 10
+ content: "Table `student` requires columns: creator_id, updater_id"
+ line: 8
details: ""
- statement: |-
CREATE TABLE book(
diff --git a/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml b/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml
index 169e70d0fc..fba25614a9 100644
--- a/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml
+++ b/backend/plugin/advisor/tidb/test/column_set_default_for_not_null.yaml
@@ -29,7 +29,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: 1
details: ""
- statement: |-
CREATE TABLE book(
@@ -41,7 +41,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: 1
details: ""
- statement: |-
CREATE TABLE book(a int);
@@ -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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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/tidb/test/column_type_disallow_list.yaml b/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml
index aa3d6dc244..089222d82d 100644
--- a/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml
+++ b/backend/plugin/advisor/tidb/test/column_type_disallow_list.yaml
@@ -12,7 +12,7 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- line: 1
+ line: 0
details: ""
- statement: |-
CREATE TABLE t(d int);
@@ -22,7 +22,7 @@
code: 411
title: column.type-disallow-list
content: Disallow column type JSON but column `t`.`a` is
- line: 3
+ line: 1
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: 3
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml b/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml
index c5b2d15f6a..159aa52104 100644
--- a/backend/plugin/advisor/tidb/test/database_drop_empty_database.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml b/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml
index bab83ee30a..c644b733f6 100644
--- a/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml
+++ b/backend/plugin/advisor/tidb/test/index_key_number_limit.yaml
@@ -16,7 +16,7 @@
code: 802
title: index.key-number-limit
content: The number of index `pk` in table `t` should be not greater than 5
- line: 4
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int, b int, c int, d int, e int, f int, g int);
@@ -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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml
index c16e93b8f3..ad6e23f896 100644
--- a/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml
+++ b/backend/plugin/advisor/tidb/test/index_no_duplicate_column.yaml
@@ -15,7 +15,7 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- line: 3
+ line: 2
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -25,7 +25,7 @@
code: 812
title: index.no-duplicate-column
content: INDEX `idx_a` has duplicate column `t`.`a`
- line: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml b/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml
index 96e9f4f70c..fec20bfefc 100644
--- a/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml
+++ b/backend/plugin/advisor/tidb/test/index_pk_type_limit.yaml
@@ -4,7 +4,7 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- line: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(id INT PRIMARY KEY)
want:
@@ -20,7 +20,7 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id` is varchar(5)
- line: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3))
want:
@@ -28,13 +28,13 @@
code: 803
title: index.pk-type-limit
content: Columns in primary key must be INT/BIGINT but `t`.`id2` is varchar(5)
- line: 1
+ line: 0
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: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2))
want:
@@ -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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(id int);
diff --git a/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml
index 6b7fc068ea..d3b94e5d61 100644
--- a/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml
+++ b/backend/plugin/advisor/tidb/test/index_primary_key_type_allowlist.yaml
@@ -4,7 +4,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: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(id INT PRIMARY KEY)
want:
@@ -20,7 +20,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: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(id INT, id2 VARCHAR(5), id3 VARCHAR(5), PRIMARY KEY(id, id2, id3))
want:
@@ -28,13 +28,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: 1
+ line: 0
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: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(id INT, id2 BIGINT, PRIMARY KEY(id, id2))
want:
@@ -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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
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: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(id int);
diff --git a/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml b/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml
index 70ba0fc71d..5f655a9429 100644
--- a/backend/plugin/advisor/tidb/test/index_total_number_limit.yaml
+++ b/backend/plugin/advisor/tidb/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: 6
+ line: 4
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: 7
+ line: 5
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: 10
+ line: 8
details: ""
diff --git a/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml b/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml
index ef671ba1ea..4699d22bfb 100644
--- a/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml
+++ b/backend/plugin/advisor/tidb/test/index_type_no_blob.yaml
@@ -4,7 +4,7 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- line: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, PRIMARY KEY(b(1), mb(2), lb(3), id))
want:
@@ -12,19 +12,19 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- line: 1
+ line: 0
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- line: 1
+ line: 0
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- line: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id INT, UNIQUE INDEX(b(1), mb(2), lb(3), id))
want:
@@ -32,19 +32,19 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- line: 1
+ line: 0
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- line: 1
+ line: 0
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- line: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(b BLOB, mb MEDIUMBLOB, lb LONGBLOB, id iNT, INDEX(b(1), mb(2), lb(3), id))
want:
@@ -52,19 +52,19 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- line: 1
+ line: 0
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- line: 1
+ line: 0
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- line: 1
+ line: 0
details: ""
- statement: CREATE TABLE t(id INT, PRIMARY KEY(id))
want:
@@ -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: 3
+ line: 1
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: 3
+ line: 1
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- line: 3
+ line: 1
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- line: 3
+ line: 1
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: 3
+ line: 1
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- line: 3
+ line: 1
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- line: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -149,19 +149,19 @@
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`b` is blob
- line: 2
+ line: 1
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`mb` is mediumblob
- line: 3
+ line: 2
details: ""
- status: WARN
code: 804
title: index.type-no-blob
content: Columns in index must not be BLOB but `t`.`lb` is longblob
- line: 4
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(b blob, mb mediumblob, lb longblob, id int);
diff --git a/backend/plugin/advisor/tidb/test/naming_column.yaml b/backend/plugin/advisor/tidb/test/naming_column.yaml
index 97e0bc8a28..d0d0d1cd31 100644
--- a/backend/plugin/advisor/tidb/test/naming_column.yaml
+++ b/backend/plugin/advisor/tidb/test/naming_column.yaml
@@ -4,15 +4,15 @@
code: 302
title: naming.column
content: '`book`.`creatorId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 1
+ line: 0
details: ""
- statement: CREATE TABLE book(id int, gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx int)
want:
- status: WARN
code: 302
title: naming.column
- content: '`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters'
- line: 1
+ content: "`book`.`gbhzmtchhsjzyrhdroxmyouwloxqezowdvhcbqalqcgqhfbjnvmhwrbggezmzeusx` mismatches column naming convention, its length should be within 64 characters"
+ line: 0
details: ""
- statement: CREATE TABLE book(id int, creator_id int)
want:
@@ -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: 3
+ line: 1
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: 8
+ line: 6
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: 7
+ line: 5
details: ""
- statement: |-
CREATE TABLE book(
@@ -100,23 +100,23 @@
code: 302
title: naming.column
content: '`book`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 3
+ line: 2
details: ""
- status: WARN
code: 302
title: naming.column
content: '`book`.`updaterId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 4
+ line: 3
details: ""
- status: WARN
code: 302
title: naming.column
content: '`student`.`createdTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 8
+ line: 7
details: ""
- status: WARN
code: 302
title: naming.column
content: '`student`.`updatedTs` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 9
+ line: 8
details: ""
diff --git a/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml b/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml
index 29e0a0dc10..d224242456 100644
--- a/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml
+++ b/backend/plugin/advisor/tidb/test/naming_column_auto_increment.yaml
@@ -12,7 +12,7 @@
code: 307
title: naming.column.auto-increment
content: '`book`.`a` mismatches auto_increment column naming convention, naming format should be "^id$"'
- line: 1
+ line: 0
details: ""
- statement: ALTER TABLE tech_book ADD COLUMN a int AUTO_INCREMENT
want:
@@ -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: 2
+ line: 0
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: 2
+ line: 0
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: 2
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/naming_index_fk.yaml b/backend/plugin/advisor/tidb/test/naming_index_fk.yaml
index 149bba0c69..0d53de6157 100644
--- a/backend/plugin/advisor/tidb/test/naming_index_fk.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
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 `rvemempmcmmhutaskvcidmwaldtfjdgmcpkhmibtadfydtkexpuzczrrneucthfwk` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- line: 2
+ line: 0
details: ""
- status: WARN
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: 2
+ line: 0
details: ""
- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id))
want:
@@ -50,5 +50,5 @@
code: 305
title: naming.index.fk
content: Foreign key in table `book` mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found `fk_book_author_id`
- line: 1
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/naming_index_idx.yaml b/backend/plugin/advisor/tidb/test/naming_index_idx.yaml
index 4d2151138f..1df9bf6636 100644
--- a/backend/plugin/advisor/tidb/test/naming_index_idx.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
details: ""
- statement: CREATE INDEX afvjwsgrbgqzjfrkmbcoxzstznuypasijbbcdykoboredqovetzfcmmqliaelyavw ON tech_book(id, name)
want:
@@ -20,13 +20,13 @@
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: 2
+ line: 0
details: ""
- status: WARN
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: 2
+ line: 0
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: 2
+ line: 0
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: 2
+ line: 0
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/tidb/test/naming_index_uk.yaml b/backend/plugin/advisor/tidb/test/naming_index_uk.yaml
index abe7b98e56..ca78fd4f1c 100644
--- a/backend/plugin/advisor/tidb/test/naming_index_uk.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
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 `qtzmquwvlnttctfluoouxelxeliltcfzzstrtyocogwwyiyrflmrkbhbfasynlacy` in table `tech_book` mismatches the naming convention, its length should be within 64 characters
- line: 2
+ line: 0
details: ""
- status: WARN
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: 2
+ line: 0
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: 2
+ line: 0
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: 2
+ line: 0
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/tidb/test/naming_table.yaml b/backend/plugin/advisor/tidb/test/naming_table.yaml
index c6990b158a..8ab3c90ac6 100644
--- a/backend/plugin/advisor/tidb/test/naming_table.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
details: ""
- statement: CREATE TABLE tech_book_copy(id int, name varchar(255))
want:
@@ -19,8 +19,8 @@
- status: WARN
code: 301
title: naming.table
- content: '`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters'
- line: 2
+ content: "`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters"
+ line: 0
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: 2
+ line: 0
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: 2
+ line: 0
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: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 2
+ line: 0
details: ""
- status: WARN
code: 301
title: naming.table
content: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'
- line: 2
+ line: 0
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/tidb/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml
index 4513d1535f..b7ae80c5bf 100644
--- a/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml
+++ b/backend/plugin/advisor/tidb/test/schema_backward_compatibility.yaml
@@ -4,9 +4,8 @@
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: 2
+ "ALTER TABLE tech_book CHANGE name f2 TEXT;" may cause incompatibility with the existing data and code
+ line: 0
details: ""
- statement: ALTER TABLE tech_book MODIFY name TEXT
want:
@@ -14,9 +13,8 @@
code: 111
title: schema.backward-compatibility
content: |-
- "ALTER TABLE tech_book MODIFY name TEXT
- ;" may cause incompatibility with the existing data and code
- line: 2
+ "ALTER TABLE tech_book MODIFY name TEXT;" may cause incompatibility with the existing data and code
+ line: 0
details: ""
- statement: ALTER TABLE tech_book MODIFY name TEXT NULL
want:
@@ -24,9 +22,8 @@
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: 2
+ "ALTER TABLE tech_book MODIFY name TEXT NULL;" may cause incompatibility with the existing data and code
+ line: 0
details: ""
- statement: ALTER TABLE tech_book MODIFY name TEXT NOT NULL
want:
@@ -34,9 +31,8 @@
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: 2
+ "ALTER TABLE tech_book MODIFY name TEXT NOT NULL;" may cause incompatibility with the existing data and code
+ line: 0
details: ""
- statement: ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla'
want:
@@ -44,7 +40,6 @@
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: 2
+ "ALTER TABLE tech_book MODIFY name TEXT COMMENT 'bla';" may cause incompatibility with the existing data and code
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml
index 632bb3b3ee..f2929c0df8 100644
--- a/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_disallow_commit.yaml
@@ -8,9 +8,8 @@
title: statement.disallow-commit
content: |-
Commit is not allowed, related statement: "
- COMMIT
- ;"
- line: 4
+ COMMIT;"
+ line: 2
details: ""
- statement: |-
START TRANSACTION;
@@ -27,14 +26,13 @@
content: |-
Commit is not allowed, related statement: "
COMMIT;"
- line: 3
+ line: 2
details: ""
- status: WARN
code: 206
title: statement.disallow-commit
content: |-
Commit is not allowed, related statement: "
- COMMIT
- ;"
- line: 8
+ COMMIT;"
+ line: 6
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml
index 71b6916a92..c8bcc30603 100644
--- a/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_disallow_limit.yaml
@@ -12,9 +12,8 @@
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: 2
+ LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO tech_book SELECT * FROM tech_book LIMIT 1;" uses
+ line: 0
details: ""
- statement: INSERT INTO tech_book SELECT * FROM tech_book UNION SELECT * FROM tech_book LIMIT 1
want:
@@ -22,9 +21,8 @@
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: 2
+ 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: 0
details: ""
- statement: UPDATE tech_book SET name = 'my name' LIMIT 10
want:
@@ -32,9 +30,8 @@
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: 2
+ LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "UPDATE tech_book SET name = 'my name' LIMIT 10;" uses
+ line: 0
details: ""
- statement: DELETE FROM tech_book LIMIT 10
want:
@@ -42,7 +39,6 @@
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: 2
+ LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "DELETE FROM tech_book LIMIT 10;" uses
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml b/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml
index 06853d65b6..94dbb22b12 100644
--- a/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_disallow_order_by.yaml
@@ -12,9 +12,8 @@
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: 2
+ ORDER BY clause is forbidden in DELETE and UPDATE statements, but "UPDATE tech_book SET name = 'my name' ORDER BY id;" uses
+ line: 0
details: ""
- statement: DELETE FROM tech_book ORDER BY id
want:
@@ -22,7 +21,6 @@
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: 2
+ ORDER BY clause is forbidden in DELETE and UPDATE statements, but "DELETE FROM tech_book ORDER BY id;" uses
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml
index 2180032bc7..fc8a903004 100644
--- a/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_insert_disallow_order_by_rand.yaml
@@ -12,7 +12,6 @@
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: 2
+ "INSERT INTO tech_book SELECT * FROM tech_book ORDER BY rand();" uses ORDER BY RAND in the INSERT statement
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml
index c6a5a25d87..9d5761f427 100644
--- a/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_insert_must_specify_column.yaml
@@ -12,7 +12,6 @@
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: 2
+ The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1');" does not
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml
index 5f32202d5d..f842515424 100644
--- a/backend/plugin/advisor/tidb/test/statement_merge_alter_table.yaml
+++ b/backend/plugin/advisor/tidb/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: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -26,13 +26,13 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `t`
- line: 3
+ line: 2
details: ""
- status: WARN
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- line: 5
+ line: 3
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -44,11 +44,11 @@
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `tech_book`
- line: 3
+ line: 2
details: ""
- status: WARN
code: 207
title: statement.merge-alter-table
content: There are 2 statements to modify table `t`
- line: 5
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml
index 79fd5cf005..57c07ed5af 100644
--- a/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_select_no_select_all.yaml
@@ -4,9 +4,8 @@
code: 203
title: statement.select.no-select-all
content: |-
- "SELECT * FROM t
- ;" uses SELECT all
- line: 2
+ "SELECT * FROM t;" uses SELECT all
+ line: 0
details: ""
- statement: SELECT a, b FROM t
want:
@@ -22,7 +21,6 @@
code: 203
title: statement.select.no-select-all
content: |-
- "SELECT a, b FROM (SELECT * from t1 JOIN t2) t
- ;" uses SELECT all
- line: 2
+ "SELECT a, b FROM (SELECT * from t1 JOIN t2) t;" uses SELECT all
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
index 9827bafcfa..389cc28567 100644
--- a/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_where_no_leading_wildcard_like.yaml
@@ -12,9 +12,8 @@
code: 204
title: statement.where.no-leading-wildcard-like
content: |-
- "SELECT * FROM t WHERE a LIKE '%abc'
- ;" uses leading wildcard LIKE
- line: 2
+ "SELECT * FROM t WHERE a LIKE '%abc';" uses leading wildcard LIKE
+ line: 0
details: ""
- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'
want:
@@ -22,9 +21,8 @@
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: 2
+ "SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc';" uses leading wildcard LIKE
+ line: 0
details: ""
- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'
want:
@@ -32,9 +30,8 @@
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: 2
+ "SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc';" uses leading wildcard LIKE
+ line: 0
details: ""
- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1
want:
@@ -42,7 +39,6 @@
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: 2
+ "SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1;" uses leading wildcard LIKE
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/statement_where_require.yaml b/backend/plugin/advisor/tidb/test/statement_where_require.yaml
index 71011e6780..ea5f6e00ac 100644
--- a/backend/plugin/advisor/tidb/test/statement_where_require.yaml
+++ b/backend/plugin/advisor/tidb/test/statement_where_require.yaml
@@ -12,9 +12,8 @@
code: 202
title: statement.where.require
content: |-
- "DELETE FROM tech_book
- ;" requires WHERE clause
- line: 2
+ "DELETE FROM tech_book;" requires WHERE clause
+ line: 0
details: ""
- statement: UPDATE tech_book SET id = 1
want:
@@ -22,9 +21,8 @@
code: 202
title: statement.where.require
content: |-
- "UPDATE tech_book SET id = 1
- ;" requires WHERE clause
- line: 2
+ "UPDATE tech_book SET id = 1;" requires WHERE clause
+ line: 0
details: ""
- statement: DELETE FROM tech_book WHERE id > 0
want:
@@ -48,9 +46,8 @@
code: 202
title: statement.where.require
content: |-
- "SELECT id FROM tech_book
- ;" requires WHERE clause
- line: 2
+ "SELECT id FROM tech_book;" requires WHERE clause
+ line: 0
details: ""
- statement: SELECT id FROM tech_book WHERE id > 0
want:
@@ -66,7 +63,6 @@
code: 202
title: statement.where.require
content: |-
- "SELECT id FROM tech_book WHERE id > (SELECT max(id) FROM tech_book)
- ;" requires WHERE clause
- line: 2
+ "SELECT id FROM tech_book WHERE id > (SELECT max(id) FROM tech_book);" requires WHERE clause
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml b/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml
index 15fd1018fd..dfb958c6a9 100644
--- a/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml
+++ b/backend/plugin/advisor/tidb/test/system_charset_allowlist.yaml
@@ -20,9 +20,8 @@
code: 1001
title: system.charset.allowlist
content: |-
- "CREATE TABLE t(a int) CHARSET ascii
- ;" used disabled charset 'ascii'
- line: 2
+ "CREATE TABLE t(a int) CHARSET ascii;" used disabled charset 'ascii'
+ line: 0
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -33,9 +32,8 @@
title: system.charset.allowlist
content: |-
"
- ALTER TABLE t CHARSET ascii
- ;" used disabled charset 'ascii'
- line: 3
+ ALTER TABLE t CHARSET ascii;" used disabled charset 'ascii'
+ line: 1
details: ""
- statement: ALTER DATABASE test CHARSET ascii
want:
@@ -43,9 +41,8 @@
code: 1001
title: system.charset.allowlist
content: |-
- "ALTER DATABASE test CHARSET ascii
- ;" used disabled charset 'ascii'
- line: 2
+ "ALTER DATABASE test CHARSET ascii;" used disabled charset 'ascii'
+ line: 0
details: ""
- statement: CREATE TABLE t(a varchar(255) CHARSET ascii)
want:
@@ -53,9 +50,8 @@
code: 1001
title: system.charset.allowlist
content: |-
- "CREATE TABLE t(a varchar(255) CHARSET ascii)
- ;" used disabled charset 'ascii'
- line: 1
+ "CREATE TABLE t(a varchar(255) CHARSET ascii);" used disabled charset 'ascii'
+ line: 0
details: ""
- statement: |-
CREATE TABLE t(b int);
@@ -66,9 +62,8 @@
title: system.charset.allowlist
content: |-
"
- ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii
- ;" used disabled charset 'ascii'
- line: 3
+ ALTER TABLE t ADD COLUMN a varchar(255) CHARSET ascii;" used disabled charset 'ascii'
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -79,9 +74,8 @@
title: system.charset.allowlist
content: |-
"
- ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii
- ;" used disabled charset 'ascii'
- line: 3
+ ALTER TABLE t MODIFY COLUMN a varchar(255) CHARSET ascii;" used disabled charset 'ascii'
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -92,9 +86,8 @@
title: system.charset.allowlist
content: |-
"
- ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii
- ;" used disabled charset 'ascii'
- line: 3
+ ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARSET ascii;" used disabled charset 'ascii'
+ line: 1
details: ""
- statement: /* this is a comment */
want:
diff --git a/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml b/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml
index cdba824bb8..8e67b619bc 100644
--- a/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml
+++ b/backend/plugin/advisor/tidb/test/system_collation_allowlist.yaml
@@ -4,9 +4,8 @@
code: 1201
title: system.collation.allowlist
content: |-
- "CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci
- ;" used disabled collation 'utf8mb4_polish_ci'
- line: 2
+ "CREATE TABLE t(a int) COLLATE utf8mb4_polish_ci;" used disabled collation 'utf8mb4_polish_ci'
+ line: 0
details: ""
- statement: CREATE TABLE t(a varchar(255))
want:
@@ -22,9 +21,8 @@
code: 1201
title: system.collation.allowlist
content: |-
- "CREATE TABLE t(a int) COLLATE latin1_bin
- ;" used disabled collation 'latin1_bin'
- line: 2
+ "CREATE TABLE t(a int) COLLATE latin1_bin;" used disabled collation 'latin1_bin'
+ line: 0
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -35,9 +33,8 @@
title: system.collation.allowlist
content: |-
"
- ALTER TABLE t COLLATE latin1_bin
- ;" used disabled collation 'latin1_bin'
- line: 3
+ ALTER TABLE t COLLATE latin1_bin;" used disabled collation 'latin1_bin'
+ line: 1
details: ""
- statement: ALTER DATABASE test COLLATE latin1_bin
want:
@@ -45,9 +42,8 @@
code: 1201
title: system.collation.allowlist
content: |-
- "ALTER DATABASE test COLLATE latin1_bin
- ;" used disabled collation 'latin1_bin'
- line: 2
+ "ALTER DATABASE test COLLATE latin1_bin;" used disabled collation 'latin1_bin'
+ line: 0
details: ""
- statement: CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)
want:
@@ -55,9 +51,8 @@
code: 1201
title: system.collation.allowlist
content: |-
- "CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin)
- ;" used disabled collation 'latin1_bin'
- line: 1
+ "CREATE TABLE t(a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin);" used disabled collation 'latin1_bin'
+ line: 0
details: ""
- statement: |-
CREATE TABLE t(b int);
@@ -68,9 +63,8 @@
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: 3
+ ALTER TABLE t ADD COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation 'latin1_bin'
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -81,9 +75,8 @@
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: 3
+ ALTER TABLE t MODIFY COLUMN a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation 'latin1_bin'
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(a int);
@@ -94,7 +87,6 @@
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: 3
+ ALTER TABLE t CHANGE COLUMN a a varchar(255) CHARACTER SET latin1 COLLATE latin1_bin;" used disabled collation 'latin1_bin'
+ line: 1
details: ""
diff --git a/backend/plugin/advisor/tidb/test/table_comment.yaml b/backend/plugin/advisor/tidb/test/table_comment.yaml
index 6a2833b108..c54479a13e 100644
--- a/backend/plugin/advisor/tidb/test/table_comment.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
details: ""
- statement: CREATE TABLE t(a int)
want:
@@ -12,7 +12,7 @@
code: 605
title: table.comment
content: Table `t` requires comments
- line: 2
+ line: 0
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: 2
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml b/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml
index 0d5307a0ae..7863b223f5 100644
--- a/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml
+++ b/backend/plugin/advisor/tidb/test/table_disallow_partition.yaml
@@ -19,9 +19,8 @@
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: 5
+ );" creates
+ line: 3
details: ""
- statement: |-
ALTER TABLE tech_book PARTITION BY RANGE (a) (
@@ -36,7 +35,6 @@
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: 5
+ );" creates
+ line: 3
details: ""
diff --git a/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml
index 0394c75b06..a01e7db9dd 100644
--- a/backend/plugin/advisor/tidb/test/table_drop_naming_convention.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
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: 2
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml b/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml
index 2657588ef9..03eb56088f 100644
--- a/backend/plugin/advisor/tidb/test/table_no_foreign_key.yaml
+++ b/backend/plugin/advisor/tidb/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: 2
+ line: 0
details: ""
- statement: CREATE TABLE book(id INT, author_id INT, FOREIGN KEY fk_book_author_id_author_id (author_id) REFERENCES author (id))
want:
@@ -12,5 +12,5 @@
code: 602
title: table.no-foreign-key
content: Foreign key is not allowed in the table `book`
- line: 1
+ line: 0
details: ""
diff --git a/backend/plugin/advisor/tidb/test/table_require_pk.yaml b/backend/plugin/advisor/tidb/test/table_require_pk.yaml
index 26a04ea666..6f9aa54838 100644
--- a/backend/plugin/advisor/tidb/test/table_require_pk.yaml
+++ b/backend/plugin/advisor/tidb/test/table_require_pk.yaml
@@ -20,7 +20,7 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- line: 2
+ line: 0
details: ""
- statement: |-
CREATE TABLE t(id INT);
@@ -50,7 +50,7 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- line: 3
+ line: 1
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: 3
+ line: 1
details: ""
- statement: |-
CREATE TABLE t(id INT);
@@ -126,7 +126,7 @@
code: 601
title: table.require-pk
content: Table `t` requires PRIMARY KEY
- line: 3
+ line: 1
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: 2
+ line: 0
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: 3
+ line: 1
details: ""
diff --git a/backend/plugin/db/mysql/mysql.go b/backend/plugin/db/mysql/mysql.go
index cdb3795e22..3215653e07 100644
--- a/backend/plugin/db/mysql/mysql.go
+++ b/backend/plugin/db/mysql/mysql.go
@@ -185,6 +185,7 @@ func (driver *Driver) Execute(ctx context.Context, statement string, _ bool, opt
if err != nil {
return 0, errors.Wrapf(err, "failed to split sql")
}
+ list = filterEmptySQL(list)
if len(list) == 0 {
return 0, nil
}
@@ -224,14 +225,12 @@ func (driver *Driver) Execute(ctx context.Context, statement string, _ bool, opt
CommandsTotal: int32(totalCommands),
CommandsCompleted: int32(currentIndex),
CommandStartPosition: &v1pb.TaskRun_ExecutionDetail_Position{
- // TODO(rebelice): should find the first non-comment and blank line.
- Line: int32(chunk[0].BaseLine),
- // TODO(rebelice): we should also set the column position.
+ Line: int32(chunk[0].FirstStatementLine),
+ Column: int32(chunk[0].FirstStatementColumn),
},
CommandEndPosition: &v1pb.TaskRun_ExecutionDetail_Position{
- // TODO(rebelice): should find the first non-comment and blank line.
- Line: int32(chunk[len(chunk)-1].BaseLine),
- // TODO(rebelice): we should also set the column position.
+ Line: int32(chunk[len(chunk)-1].LastLine),
+ Column: int32(chunk[len(chunk)-1].LastColumn),
},
})
}
@@ -246,12 +245,12 @@ func (driver *Driver) Execute(ctx context.Context, statement string, _ bool, opt
return 0, &db.ErrorWithPosition{
Err: errors.Wrapf(err, "failed to execute context in a transaction"),
Start: &storepb.TaskRunResult_Position{
- // TODO(rebelice): should find the first non-comment and blank line and column.
- Line: int32(chunk[0].BaseLine),
+ Line: int32(chunk[0].FirstStatementLine),
+ Column: int32(chunk[0].FirstStatementColumn),
},
End: &storepb.TaskRunResult_Position{
- // TODO(rebelice): should find the first non-comment and blank line and column.
- Line: int32(chunk[len(chunk)-1].BaseLine),
+ Line: int32(chunk[len(chunk)-1].LastLine),
+ Column: int32(chunk[len(chunk)-1].LastColumn),
},
}
}
@@ -277,6 +276,7 @@ func (driver *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement s
if err != nil {
return nil, err
}
+ singleSQLs = filterEmptySQL(singleSQLs)
if len(singleSQLs) == 0 {
return nil, nil
}
@@ -342,3 +342,13 @@ func (driver *Driver) querySingleSQL(ctx context.Context, conn *sql.Conn, single
func (*Driver) RunStatement(ctx context.Context, conn *sql.Conn, statement string) ([]*v1pb.QueryResult, error) {
return util.RunStatement(ctx, storepb.Engine_MYSQL, conn, statement)
}
+
+func filterEmptySQL(list []base.SingleSQL) []base.SingleSQL {
+ var result []base.SingleSQL
+ for _, sql := range list {
+ if !sql.Empty {
+ result = append(result, sql)
+ }
+ }
+ return result
+}
diff --git a/backend/plugin/parser/base/base.go b/backend/plugin/parser/base/base.go
index 7d1d9c5c75..e6417168cd 100644
--- a/backend/plugin/parser/base/base.go
+++ b/backend/plugin/parser/base/base.go
@@ -8,9 +8,22 @@ import (
// SingleSQL is a separate SQL split from multi-SQL.
type SingleSQL struct {
- Text string
+ Text string
+ // BaseLine is the line number of the first line of the SQL in the original SQL.
+ // HINT: ZERO based.
BaseLine int
+ // FirstStatementLine is the line number of the first non-comment and non-blank line of the SQL in the original SQL.
+ // HINT: ZERO based.
+ FirstStatementLine int
+ // FirstStatementColumn is the column number of the first non-comment and non-blank line of the SQL in the original SQL.
+ // HINT: ZERO based.
+ FirstStatementColumn int
+ // LastLine is the line number of the last line of the SQL in the original SQL.
+ // HINT: ZERO based.
LastLine int
+ // LastColumn is the column number of the last line of the SQL in the original SQL.
+ // HINT: ZERO based.
+ LastColumn int
// The sql is empty, such as `/* comments */;` or just `;`.
Empty bool
}
diff --git a/backend/plugin/parser/mysql/mysql.go b/backend/plugin/parser/mysql/mysql.go
index 69390f679a..4ef72e8f93 100644
--- a/backend/plugin/parser/mysql/mysql.go
+++ b/backend/plugin/parser/mysql/mysql.go
@@ -115,8 +115,15 @@ func parseSingleStatement(statement string) (antlr.Tree, *antlr.CommonTokenStrea
func mysqlAddSemicolonIfNeeded(sql string) string {
lexer := parser.NewMySQLLexer(antlr.NewInputStream(sql))
+ lexerErrorListener := &base.ParseErrorListener{}
+ lexer.RemoveErrorListeners()
+ lexer.AddErrorListener(lexerErrorListener)
stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
stream.Fill()
+ if lexerErrorListener.Err != nil {
+ // If the lexer fails, we cannot add semicolon.
+ return sql
+ }
tokens := stream.GetAllTokens()
for i := len(tokens) - 1; i >= 0; i-- {
if tokens[i].GetChannel() != antlr.TokenDefaultChannel || tokens[i].GetTokenType() == parser.MySQLParserEOF {
diff --git a/backend/plugin/parser/mysql/split.go b/backend/plugin/parser/mysql/split.go
index 1751662fdd..8aa957f2ca 100644
--- a/backend/plugin/parser/mysql/split.go
+++ b/backend/plugin/parser/mysql/split.go
@@ -2,7 +2,6 @@ package mysql
import (
"io"
- "strings"
"github.com/antlr4-go/antlr/v4"
parser "github.com/bytebase/mysql-parser"
@@ -20,7 +19,7 @@ func init() {
// SplitSQL splits the given SQL statement into multiple SQL statements.
func SplitSQL(statement string) ([]base.SingleSQL, error) {
- statement = strings.TrimRight(statement, " \r\n\t\f;") + "\n;"
+ statement = mysqlAddSemicolonIfNeeded(statement)
var err error
statement, err = DealWithDelimiter(statement)
if err != nil {
@@ -29,18 +28,7 @@ func SplitSQL(statement string) ([]base.SingleSQL, error) {
lexer := parser.NewMySQLLexer(antlr.NewInputStream(statement))
stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
- list, err := splitMySQLStatement(stream)
- if err != nil {
- return nil, err
- }
- var results []base.SingleSQL
- for _, sql := range list {
- if sql.Empty {
- continue
- }
- results = append(results, sql)
- }
- return results, nil
+ return splitMySQLStatement(stream)
}
// SplitMultiSQLStream splits MySQL multiSQL to stream.
@@ -242,11 +230,18 @@ func splitMySQLStatement(stream *antlr.CommonTokenStream) ([]base.SingleSQL, err
continue
}
+ line, col := firstDefaultChannelTokenPosition(tokens[start : i+1])
+ // From antlr4, the line is ONE based, and the column is ZERO based.
+ // So we should minus 1 for the line.
result = append(result, base.SingleSQL{
- Text: stream.GetTextFromTokens(tokens[start], tokens[i]),
- BaseLine: tokens[start].GetLine() - 1,
- LastLine: tokens[i].GetLine()},
- )
+ Text: stream.GetTextFromTokens(tokens[start], tokens[i]),
+ BaseLine: tokens[start].GetLine() - 1,
+ LastLine: tokens[i].GetLine() - 1,
+ LastColumn: tokens[i].GetColumn(),
+ FirstStatementLine: line,
+ FirstStatementColumn: col,
+ Empty: isEmpty(tokens[start : i+1]),
+ })
start = i + 1
case parser.MySQLParserEOF:
if len(stack) != 0 {
@@ -257,13 +252,44 @@ func splitMySQLStatement(stream *antlr.CommonTokenStream) ([]base.SingleSQL, err
}
if start <= i-1 {
+ line, col := firstDefaultChannelTokenPosition(tokens[start:i])
+ // From antlr4, the line is ONE based, and the column is ZERO based.
+ // So we should minus 1 for the line.
result = append(result, base.SingleSQL{
- Text: stream.GetTextFromTokens(tokens[start], tokens[i-1]),
- BaseLine: tokens[start].GetLine() - 1,
- LastLine: tokens[i-1].GetLine()},
- )
+ Text: stream.GetTextFromTokens(tokens[start], tokens[i-1]),
+ BaseLine: tokens[start].GetLine() - 1,
+ LastLine: tokens[i-1].GetLine() - 1,
+ LastColumn: tokens[i-1].GetColumn(),
+ FirstStatementLine: line,
+ FirstStatementColumn: col,
+ Empty: isEmpty(tokens[start:i]),
+ })
}
}
}
return result, nil
}
+
+func isEmpty(tokens []antlr.Token) bool {
+ for _, token := range tokens {
+ if token.GetChannel() == antlr.TokenDefaultChannel && token.GetTokenType() != parser.MySQLParserSEMICOLON_SYMBOL && token.GetTokenType() != parser.MySQLParserEOF {
+ return false
+ }
+ }
+ return true
+}
+
+// firstDefaultChannelTokenPosition returns the first token position of the default channel.
+// Both line and column are ZERO based.
+func firstDefaultChannelTokenPosition(tokens []antlr.Token) (int, int) {
+ for _, token := range tokens {
+ if token.GetChannel() == antlr.TokenDefaultChannel {
+ // From antlr4, the line is ONE based, and the column is ZERO based.
+ // So we should minus 1 for the line.
+ return token.GetLine() - 1, token.GetColumn()
+ }
+ }
+ // From antlr4, the line is ONE based, and the column is ZERO based.
+ // So we should minus 1 for the line.
+ return tokens[len(tokens)-1].GetLine() - 1, tokens[len(tokens)-1].GetColumn()
+}
diff --git a/backend/plugin/parser/mysql/split_test.go b/backend/plugin/parser/mysql/split_test.go
index 3e1b78f79c..be4ee2c394 100644
--- a/backend/plugin/parser/mysql/split_test.go
+++ b/backend/plugin/parser/mysql/split_test.go
@@ -41,12 +41,16 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
{
statement: `-- klsjdfjasldf
-- klsjdflkjaskldfj
- `,
+`,
want: resData{
res: []base.SingleSQL{
{
- Text: "-- klsjdfjasldf\n\t\t\t-- klsjdflkjaskldfj\n;",
- LastLine: 3,
+ Text: "-- klsjdfjasldf\n\t\t\t-- klsjdflkjaskldfj\n",
+ FirstStatementLine: 1,
+ FirstStatementColumn: 22,
+ LastLine: 1,
+ LastColumn: 22,
+ Empty: true,
},
},
},
@@ -57,12 +61,19 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: `select * from t;`,
- LastLine: 1,
+ Text: `select * from t;`,
+ LastLine: 0,
+ LastColumn: 15,
+ FirstStatementLine: 0,
+ FirstStatementColumn: 0,
},
{
- Text: "\n\t\t\t/* sdfasdf */\n;",
- LastLine: 3,
+ Text: "\n\t\t\t/* sdfasdf */",
+ LastLine: 1,
+ LastColumn: 3,
+ FirstStatementLine: 1,
+ FirstStatementColumn: 3,
+ Empty: true,
},
},
},
@@ -74,17 +85,25 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: `select * from t;`,
- LastLine: 1,
+ Text: `select * from t;`,
+ LastLine: 0,
+ LastColumn: 15,
},
{
- Text: "\n\t\t\t/* sdfasdf */;",
- LastLine: 2,
+ Text: "\n\t\t\t/* sdfasdf */;",
+ LastLine: 1,
+ LastColumn: 16,
+ FirstStatementLine: 1,
+ FirstStatementColumn: 16,
+ Empty: true,
},
{
- Text: "\n\t\t\tselect * from t\n;",
- BaseLine: 1,
- LastLine: 4,
+ Text: "\n\t\t\tselect * from t;",
+ BaseLine: 1,
+ LastLine: 2,
+ LastColumn: 18,
+ FirstStatementLine: 2,
+ FirstStatementColumn: 3,
},
},
},
@@ -120,9 +139,9 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
RETURN income;
- END
-;`,
- LastLine: 15,
+ END ;`,
+ LastLine: 13,
+ LastColumn: 6,
},
},
},
@@ -132,8 +151,9 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: bigSQL + "\n;",
- LastLine: 2,
+ Text: bigSQL + ";",
+ LastLine: 0,
+ LastColumn: len(bigSQL),
},
},
},
@@ -143,12 +163,16 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: " CREATE TABLE t(a int);",
- LastLine: 1,
+ Text: " CREATE TABLE t(a int);",
+ LastLine: 0,
+ LastColumn: 25,
+ FirstStatementColumn: 4,
},
{
- Text: " CREATE TABLE t1(a int)\n;",
- LastLine: 2,
+ Text: " CREATE TABLE t1(a int);",
+ LastLine: 0,
+ LastColumn: 49,
+ FirstStatementColumn: 27,
},
},
},
@@ -159,12 +183,15 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: "CREATE TABLE `tech_Book`(id int, name varchar(255));",
- LastLine: 1,
+ Text: "CREATE TABLE `tech_Book`(id int, name varchar(255));",
+ LastLine: 0,
+ LastColumn: 51,
},
{
- Text: "\nINSERT INTO `tech_Book` VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\\'jdfl;\"ka')\n;",
- LastLine: 3,
+ Text: "\nINSERT INTO `tech_Book` VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\\'jdfl;\"ka');",
+ LastLine: 1,
+ LastColumn: 77,
+ FirstStatementLine: 1,
},
},
},
@@ -180,18 +207,27 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: "\n\t\t\t\t\t\t/* this is the comment. */\n\t\t\t\t\t\tCREATE /* inline comment */TABLE tech_Book(id int, name varchar(255));",
- LastLine: 3,
+ Text: "\n\t\t\t\t\t\t/* this is the comment. */\n\t\t\t\t\t\tCREATE /* inline comment */TABLE tech_Book(id int, name varchar(255));",
+ LastLine: 2,
+ LastColumn: 75,
+ FirstStatementLine: 2,
+ FirstStatementColumn: 6,
},
{
- Text: "\n\t\t\t\t\t\t-- this is the comment.\n\t\t\t\t\t\tINSERT INTO tech_Book VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\\'jdfl;\"ka');",
- BaseLine: 2,
- LastLine: 5,
+ Text: "\n\t\t\t\t\t\t-- this is the comment.\n\t\t\t\t\t\tINSERT INTO tech_Book VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\\'jdfl;\"ka');",
+ BaseLine: 2,
+ LastLine: 4,
+ LastColumn: 81,
+ FirstStatementLine: 4,
+ FirstStatementColumn: 6,
},
{
- Text: "\n\t\t\t\t\t\t# this is the comment.\n\t\t\t\t\t\tINSERT INTO tech_Book VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\\'jdfl;\"ka')\n;",
- BaseLine: 4,
- LastLine: 8,
+ Text: "\n\t\t\t\t\t\t# this is the comment.\n\t\t\t\t\t\tINSERT INTO tech_Book VALUES (0, 'abce_ksdf'), (1, 'lks''kjsafa\\'jdfl;\"ka');",
+ BaseLine: 4,
+ LastLine: 6,
+ LastColumn: 81,
+ FirstStatementLine: 6,
+ FirstStatementColumn: 6,
},
},
},
@@ -210,18 +246,36 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: "# test for defining stored programs\n\t\t\t\t\t\tCREATE PROCEDURE dorepeat(p1 INT)\n\t\t\t\t\t\tBEGIN\n\t\t\t\t\t\t\tSET @x = 0;\n\t\t\t\t\t\t\tREPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;\n\t\t\t\t\t\tEND\n\t\t\t\t\t\t;",
- LastLine: 7,
+ Text: "# test for defining stored programs\n\t\t\t\t\t\tCREATE PROCEDURE dorepeat(p1 INT)\n\t\t\t\t\t\tBEGIN\n\t\t\t\t\t\t\tSET @x = 0;\n\t\t\t\t\t\t\tREPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;\n\t\t\t\t\t\tEND\n\t\t\t\t\t\t;",
+ LastLine: 6,
+ LastColumn: 6,
+ FirstStatementLine: 1,
+ FirstStatementColumn: 6,
+ },
+ {
+ Text: "\n\t\t\t\t\t\tCALL dorepeat(1000);",
+ BaseLine: 6,
+ LastLine: 7,
+ LastColumn: 25,
+ FirstStatementLine: 7,
+ FirstStatementColumn: 6,
},
{
- Text: "\n\t\t\t\t\t\tCALL dorepeat(1000);",
- BaseLine: 6,
- LastLine: 8,
+ Text: "\n\t\t\t\t\t\tSELECT @x;",
+ BaseLine: 7,
+ LastLine: 8,
+ LastColumn: 15,
+ FirstStatementLine: 8,
+ FirstStatementColumn: 6,
},
{
- Text: "\n\t\t\t\t\t\tSELECT @x\n;",
- BaseLine: 7,
- LastLine: 10,
+ Text: "\n\t\t\t\t\t\t",
+ BaseLine: 8,
+ LastLine: 9,
+ LastColumn: 5,
+ FirstStatementLine: 9,
+ FirstStatementColumn: 5,
+ Empty: true,
},
},
},
@@ -241,18 +295,36 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: "# test for defining stored programs\n\t\t\t\t\t\tCREATE PROCEDURE dorepeat(p1 INT)\n\t\t\t\t\t\t/* This is a comment */\n\t\t\t\t\t\tBEGIN\n\t\t\t\t\t\t\tSET @x = 0;\n\t\t\t\t\t\t\tREPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;\n\t\t\t\t\t\tEND\n\t\t\t\t\t\t;",
- LastLine: 8,
+ Text: "# test for defining stored programs\n\t\t\t\t\t\tCREATE PROCEDURE dorepeat(p1 INT)\n\t\t\t\t\t\t/* This is a comment */\n\t\t\t\t\t\tBEGIN\n\t\t\t\t\t\t\tSET @x = 0;\n\t\t\t\t\t\t\tREPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;\n\t\t\t\t\t\tEND\n\t\t\t\t\t\t;",
+ FirstStatementLine: 1,
+ FirstStatementColumn: 6,
+ LastLine: 7,
+ LastColumn: 6,
+ },
+ {
+ Text: "\n\t\t\t\t\t\tCALL dorepeat(1000);",
+ BaseLine: 7,
+ LastLine: 8,
+ LastColumn: 25,
+ FirstStatementLine: 8,
+ FirstStatementColumn: 6,
},
{
- Text: "\n\t\t\t\t\t\tCALL dorepeat(1000);",
- BaseLine: 7,
- LastLine: 9,
+ Text: "\n\t\t\t\t\t\tSELECT @x;",
+ BaseLine: 8,
+ LastLine: 9,
+ LastColumn: 15,
+ FirstStatementLine: 9,
+ FirstStatementColumn: 6,
},
{
- Text: "\n\t\t\t\t\t\tSELECT @x\n;",
- BaseLine: 8,
- LastLine: 11,
+ Text: "\n\t\t\t\t\t\t",
+ BaseLine: 9,
+ LastLine: 10,
+ LastColumn: 5,
+ FirstStatementLine: 10,
+ FirstStatementColumn: 5,
+ Empty: true,
},
},
},
@@ -263,13 +335,17 @@ func TestMySQLSplitMultiSQL(t *testing.T) {
want: resData{
res: []base.SingleSQL{
{
- Text: "CREATE TABLE t\r\n(a int);",
- LastLine: 2,
+ Text: "CREATE TABLE t\r\n(a int);",
+ LastLine: 1,
+ LastColumn: 7,
},
{
- Text: "\r\nCREATE TABLE t1(b int)\n;",
- BaseLine: 1,
- LastLine: 4,
+ Text: "\r\nCREATE TABLE t1(b int);",
+ BaseLine: 1,
+ LastLine: 2,
+ LastColumn: 22,
+ FirstStatementLine: 2,
+ FirstStatementColumn: 0,
},
},
},
diff --git a/backend/plugin/parser/sql/transform/mysql/transform.go b/backend/plugin/parser/sql/transform/mysql/transform.go
index df700f53a8..fa0a3d78ea 100644
--- a/backend/plugin/parser/sql/transform/mysql/transform.go
+++ b/backend/plugin/parser/sql/transform/mysql/transform.go
@@ -121,8 +121,11 @@ func (t *SchemaTransformer) Normalize(schema string, standard string) (string, e
if err != nil {
return "", errors.Wrapf(err, "failed to parse schema %q", schema)
}
- if len(nodeList) != 1 {
- return "", errors.Errorf("Expect one statement after splitting but found %d", len(nodeList))
+ if len(nodeList) == 0 {
+ continue
+ }
+ if len(nodeList) > 1 {
+ return "", errors.Errorf("Expect one statement after splitting but found %d, text %q", len(nodeList), stmt.Text)
}
switch node := nodeList[0].(type) {
@@ -154,8 +157,11 @@ func (t *SchemaTransformer) Normalize(schema string, standard string) (string, e
if err != nil {
return "", errors.Wrapf(err, "failed to parse schema %q", schema)
}
- if len(nodeList) != 1 {
- return "", errors.Errorf("Expect one statement after splitting but found %d", len(nodeList))
+ if len(nodeList) == 0 {
+ continue
+ }
+ if len(nodeList) > 1 {
+ return "", errors.Errorf("Expect one statement after splitting but found %d, text %q", len(nodeList), stmt.Text)
}
switch node := nodeList[0].(type) {
@@ -191,8 +197,11 @@ func (t *SchemaTransformer) Normalize(schema string, standard string) (string, e
if err != nil {
return "", errors.Wrapf(err, "failed to parse schema %q", schema)
}
- if len(nodeList) != 1 {
- return "", errors.Errorf("Expect one statement after splitting but found %d", len(nodeList))
+ if len(nodeList) == 0 {
+ continue
+ }
+ if len(nodeList) > 1 {
+ return "", errors.Errorf("Expect one statement after splitting but found %d, text %q", len(nodeList), stmt.Text)
}
switch node := nodeList[0].(type) {
@@ -372,8 +381,11 @@ func (*SchemaTransformer) Check(schema string) (int, error) {
if err != nil {
return stmt.LastLine, errors.Wrapf(err, "failed to parse schema %q", schema)
}
- if len(nodeList) != 1 {
- return stmt.LastLine, errors.Errorf("Expect one statement after splitting but found %d", len(nodeList))
+ if len(nodeList) == 0 {
+ continue
+ }
+ if len(nodeList) > 1 {
+ return stmt.LastLine, errors.Errorf("Expect one statement after splitting but found %d, text %q", len(nodeList), stmt.Text)
}
switch node := nodeList[0].(type) {
@@ -469,8 +481,11 @@ func (*SchemaTransformer) Transform(schema string) (string, error) {
result = append(result, stmt.Text+"\n\n")
continue
}
- if len(nodeList) != 1 {
- return "", errors.Errorf("Expect one statement after splitting but found %d", len(nodeList))
+ if len(nodeList) == 0 {
+ continue
+ }
+ if len(nodeList) > 1 {
+ return "", errors.Errorf("Expect one statement after splitting but found %d, text %q", len(nodeList), stmt.Text)
}
switch node := nodeList[0].(type) {
diff --git a/backend/plugin/parser/sql/transform/mysql/transform_test.go b/backend/plugin/parser/sql/transform/mysql/transform_test.go
index 879943bc4e..1a3393be42 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;" + "\n" +
+ " END;" + "\n" +
"\n"
a := require.New(t)
diff --git a/backend/plugin/parser/tidb/compatible_test.go b/backend/plugin/parser/tidb/compatible_test.go
index 937129b18d..f45fd54bdc 100644
--- a/backend/plugin/parser/tidb/compatible_test.go
+++ b/backend/plugin/parser/tidb/compatible_test.go
@@ -15,7 +15,7 @@ func TestExtractTiDBUnsupportStmts(t *testing.T) {
}{
{
stmts: "CREATE TABLE `actor` (\n `actor_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n `first_name` varchar(45) NOT NULL,\n `last_name` varchar(45) NOT NULL,\n `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`actor_id`),\n KEY `idx_actor_last_name` (`last_name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;",
- wantSupport: "CREATE TABLE `actor` (\n `actor_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n `first_name` varchar(45) NOT NULL,\n `last_name` varchar(45) NOT NULL,\n `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`actor_id`),\n KEY `idx_actor_last_name` (`last_name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3\n;\n",
+ wantSupport: "CREATE TABLE `actor` (\n `actor_id` smallint unsigned NOT NULL AUTO_INCREMENT,\n `first_name` varchar(45) NOT NULL,\n `last_name` varchar(45) NOT NULL,\n `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`actor_id`),\n KEY `idx_actor_last_name` (`last_name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;\n",
wantErr: false,
},
{
@@ -35,8 +35,7 @@ CREATE TRIGGER order_insert_audit
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/plugin/parser/tidb/differ_utils_test.go b/backend/plugin/parser/tidb/differ_utils_test.go
index 4b5812d5e2..7abf527ada 100644
--- a/backend/plugin/parser/tidb/differ_utils_test.go
+++ b/backend/plugin/parser/tidb/differ_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\n",
+ "CREATE DEFINER=`root`@`%` TRIGGER `ins_sum` BEFORE INSERT ON account FOR EACH ROW SET @sum = sum + NEW.amount * NEW.price;\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\n",
+ "BEGIN DECLARE a INT; SET a = v; SET a = a * 1 + 1; RETURN a; END ;\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\n",
+ "END ;\n\n",
},
}
testDiffWithoutDisableForeignKeyCheck(t, tests)
@@ -74,8 +74,7 @@ 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/tests/grouping_change_test.go b/backend/tests/grouping_change_test.go
index 47c1039c8f..41d74c8faa 100644
--- a/backend/tests/grouping_change_test.go
+++ b/backend/tests/grouping_change_test.go
@@ -564,12 +564,12 @@ func TestCreateGroupingChangeIssue(t *testing.T) {
},
wantDatabaseTaskStatement: map[string][]string{
"employee_01": {
- "ALTER TABLE salary_01 ADD COLUMN num INT\n;\n",
- "ALTER TABLE salary_02 ADD COLUMN num INT\n;\n",
+ "ALTER TABLE salary_01 ADD COLUMN num INT;\n",
+ "ALTER TABLE salary_02 ADD COLUMN num INT;\n",
},
"employee_02": {
- "ALTER TABLE salary_03 ADD COLUMN num INT\n;\n",
- "ALTER TABLE salary_04 ADD COLUMN num INT\n;\n",
+ "ALTER TABLE salary_03 ADD COLUMN num INT;\n",
+ "ALTER TABLE salary_04 ADD COLUMN num INT;\n",
},
},
},
@@ -618,7 +618,7 @@ ALTER TABLE singleton ADD COLUMN num INT;`,
"\nALTER TABLE part_partially_01 ADD COLUMN num INT;\n",
"\nALTER TABLE person_01 ADD COLUMN name VARCHAR(30);\n",
"\nALTER TABLE person_02 ADD COLUMN name VARCHAR(30);\n",
- "\nALTER TABLE singleton ADD COLUMN num INT\n;\n",
+ "\nALTER TABLE singleton ADD COLUMN num INT;\n",
"\nCREATE TABLE singleton(id INT);\n",
"ALTER TABLE salary_01 ADD COLUMN num INT;\n\nCREATE INDEX salary_01_num_idx ON salary_01 (num);\n",
"ALTER TABLE salary_02 ADD COLUMN num INT;\n\nCREATE INDEX salary_02_num_idx ON salary_02 (num);\n",
@@ -626,7 +626,7 @@ ALTER TABLE singleton ADD COLUMN num INT;`,
"employee_02": {
"\nALTER TABLE person_03 ADD COLUMN name VARCHAR(30);\n",
"\nALTER TABLE person_04 ADD COLUMN name VARCHAR(30);\n",
- "\nALTER TABLE singleton ADD COLUMN num INT\n;\n",
+ "\nALTER TABLE singleton ADD COLUMN num INT;\n",
"\nCREATE TABLE singleton(id INT);\n",
"ALTER TABLE salary_03 ADD COLUMN num INT;\n\nCREATE INDEX salary_03_num_idx ON salary_03 (num);\n",
"ALTER TABLE salary_04 ADD COLUMN num INT;\n\nCREATE INDEX salary_04_num_idx ON salary_04 (num);\n",
@@ -650,7 +650,7 @@ ALTER TABLE singleton ADD COLUMN num INT;`,
"employee_03": {
"\nALTER TABLE person_05 ADD COLUMN name VARCHAR(30);\n",
"\nALTER TABLE person_06 ADD COLUMN name VARCHAR(30);\n",
- "\nALTER TABLE singleton ADD COLUMN num INT\n;\n",
+ "\nALTER TABLE singleton ADD COLUMN num INT;\n",
"\nCREATE TABLE singleton(id INT);\n",
"ALTER TABLE salary_05 ADD COLUMN num INT;\n\nCREATE INDEX salary_05_num_idx ON salary_05 (num);\n",
"ALTER TABLE salary_06 ADD COLUMN num INT;\n\nCREATE INDEX salary_06_num_idx ON salary_06 (num);\n",
@@ -659,7 +659,7 @@ ALTER TABLE singleton ADD COLUMN num INT;`,
"\nALTER TABLE part_partially_02 ADD COLUMN num INT;\n",
"\nALTER TABLE person_07 ADD COLUMN name VARCHAR(30);\n",
"\nALTER TABLE person_08 ADD COLUMN name VARCHAR(30);\n",
- "\nALTER TABLE singleton ADD COLUMN num INT\n;\n",
+ "\nALTER TABLE singleton ADD COLUMN num INT;\n",
"\nCREATE TABLE singleton(id INT);\n",
"ALTER TABLE salary_07 ADD COLUMN num INT;\n\nCREATE INDEX salary_07_num_idx ON salary_07 (num);\n",
"ALTER TABLE salary_08 ADD COLUMN num INT;\n\nCREATE INDEX salary_08_num_idx ON salary_08 (num);\n",
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
index cb79fbf78a..1b59843a24 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunComment.vue
@@ -72,8 +72,13 @@ const comment = computed(() => {
return t("task-run.status.executing-sql-detail", {
current: taskRun.executionDetail.commandsCompleted + 1,
total: taskRun.executionDetail.commandsTotal,
- start: taskRun.executionDetail.commandStartPosition?.line ?? 0 + 1,
- end: taskRun.executionDetail.commandEndPosition?.line ?? 0 + 1,
+ startLine:
+ (taskRun.executionDetail.commandStartPosition?.line ?? 0) + 1,
+ startColumn:
+ (taskRun.executionDetail.commandStartPosition?.column ?? 0) + 1,
+ endLine: (taskRun.executionDetail.commandEndPosition?.line ?? 0) + 1,
+ endColumn:
+ (taskRun.executionDetail.commandEndPosition?.column ?? 0) + 1,
});
}
return t("task-run.status.executing-sql");
@@ -88,8 +93,13 @@ const comment = computed(() => {
taskRun.executionDetail?.commandEndPosition
) {
return t("task-run.status.failed-sql-detail", {
- start: taskRun.executionDetail.commandStartPosition?.line ?? 0 + 1,
- end: taskRun.executionDetail.commandEndPosition?.line ?? 0 + 1,
+ startLine:
+ (taskRun.executionDetail.commandStartPosition?.line ?? 0) + 1,
+ startColumn:
+ (taskRun.executionDetail.commandStartPosition?.column ?? 0) + 1,
+ endLine: (taskRun.executionDetail.commandEndPosition?.line ?? 0) + 1,
+ endColumn:
+ (taskRun.executionDetail.commandEndPosition?.column ?? 0) + 1,
message: taskRun.detail,
});
}
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 28136e0b71..6974866a5e 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -409,9 +409,9 @@
"enqueued-with-rollout-time": "Waiting to execute after {time}.",
"dumping-schema-before-executing-sql": "Preparing to execute, dumping schema.",
"executing-sql": "Executing SQL.",
- "executing-sql-detail": "Executing SQL {current} of {total}, from line {start} to line {end}.",
+ "executing-sql-detail": "Executing SQL {current} of {total}, from ({startLine}, {startColumn}) to ({endLine}, {endColumn}).",
"dumping-schema-after-executing-sql": "SQL execution completed, dumping schema.",
- "failed-sql-detail": "Execution failed from line {start} to line {end}: {message}."
+ "failed-sql-detail": "Execution failed from ({startLine}, {startColumn}) to ({endLine}, {endColumn}): {message}."
}
},
"banner": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index c98dfa8e3d..d212559f77 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -410,8 +410,8 @@
"dumping-schema-before-executing-sql": "Listo para ejecutar, exportando esquema.",
"executing-sql": "Ejecutando SQL.",
"dumping-schema-after-executing-sql": "Ejecución SQL completada, exportando esquema ahora.",
- "executing-sql-detail": "Ejecutando SQL {current} de {total}, desde la línea {start} hasta la línea {end}.",
- "failed-sql-detail": "La ejecución falló desde la línea {start} hasta la línea {end}: {message}."
+ "executing-sql-detail": "Ejecutando SQL {actual} de {total}, desde ({startLine}, {startColumn}) hasta ({endLine}, {endColumn}).",
+ "failed-sql-detail": "La ejecución falló desde ({startLine}, {startColumn}) hasta ({endLine}, {endColumn}): {message}."
}
},
"banner": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index e42f0c4bfc..b3a6eb30e5 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -407,9 +407,9 @@
"enqueued-with-rollout-time": "等待执行,{time}后执行。",
"dumping-schema-before-executing-sql": "准备执行,正在导出 schema。",
"executing-sql": "正在执行 SQL。",
- "executing-sql-detail": "正在执行 SQL {current} / {total}。 SQL 语句位于 {start} 行到 {end} 行。",
+ "executing-sql-detail": "正在执行 SQL {current} of {total},从 ({startLine}, {startColumn}) 到 ({endLine}, {endColumn})。",
"dumping-schema-after-executing-sql": "SQL 执行完毕,正在导出 schema。",
- "failed-sql-detail": "从 {start} 行到 {end} 行执行失败:{message}。"
+ "failed-sql-detail": "从 ({startLine}, {startColumn}) 到 ({endLine}, {endColumn}) 的执行失败:{message}。"
}
},
"banner": {