Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: improve error line reporting for TiDB and PostgreSQL parsers (#17773)
Danny Xu7b8b14a56cdc
diff --git a/backend/component/sheet/sheet.go b/backend/component/sheet/sheet.goindex 0330839644..a18fb07f75 100644--- a/backend/component/sheet/sheet.go+++ b/backend/component/sheet/sheet.go@@ -15,7 +15,6 @@ import ("github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/backend/generated-go/store""github.com/bytebase/bytebase/backend/plugin/parser/base"- pgrawparser "github.com/bytebase/bytebase/backend/plugin/parser/pg/legacy"tsqlbatch "github.com/bytebase/bytebase/backend/plugin/parser/tsql/batch""github.com/bytebase/bytebase/backend/store"@@ -234,19 +233,6 @@ func convertErrorToAdvice(err error) []*storepb.Advice {},}}- if _, ok := err.(*pgrawparser.ConvertError); ok {- return []*storepb.Advice{- {- Status: storepb.Advice_ERROR,- Code: InternalErrorCode,- Title: "Parser conversion error",- Content: err.Error(),- StartPosition: &storepb.Position{- Line: int32(1),- },- },- }- }return []*storepb.Advice{{Status: storepb.Advice_ERROR,diff --git a/backend/plugin/advisor/catalog/test/pg_walk_through.yaml b/backend/plugin/advisor/catalog/test/pg_walk_through.yamlindex fe68d0c07e..0144bdfc94 100644--- a/backend/plugin/advisor/catalog/test/pg_walk_through.yaml+++ b/backend/plugin/advisor/catalog/test/pg_walk_through.yaml@@ -574,7 +574,7 @@err:type: 408content: 'Cannot drop column "id" in table "public"."test", it''s referenced by view: "public"."v1"'- line: 0+ line: 1payload:- '"public"."v1"'- statement: ALTER TABLE test ALTER COLUMN id TYPE varchar(20);@@ -583,7 +583,7 @@err:type: 408content: 'Cannot alter type of column "id" in table "public"."test", it''s referenced by view: "public"."v1"'- line: 0+ line: 1payload:- '"public"."v1"'- statement: DROP TABLE test;@@ -592,7 +592,7 @@err:type: 304content: 'Cannot drop table "public"."test", it''s referenced by view: "public"."v1"'- line: 0+ line: 1payload:- '"public"."v1"'- statement: |-diff --git a/backend/plugin/advisor/pg/test/builtin_prior_backup_check.yaml b/backend/plugin/advisor/pg/test/builtin_prior_backup_check.yamlindex 37e47c9796..0ece15a37d 100644--- a/backend/plugin/advisor/pg/test/builtin_prior_backup_check.yaml+++ b/backend/plugin/advisor/pg/test/builtin_prior_backup_check.yaml@@ -36,7 +36,7 @@title: builtin.prior-backup-checkcontent: Data change can only run DML, "CREATE TABLE t_test_backup(a int);" is not DMLstartposition:- line: 0+ line: 1column: 0endposition: null- statement: SET ROLE role1;DELETE FROM tech_book WHERE a > 1;diff --git a/backend/plugin/advisor/pg/test/column_comment.yaml b/backend/plugin/advisor/pg/test/column_comment.yamlindex 9f393e4995..d62bd0e41a 100644--- a/backend/plugin/advisor/pg/test/column_comment.yaml+++ b/backend/plugin/advisor/pg/test/column_comment.yaml@@ -10,7 +10,7 @@title: column.commentcontent: Comment is required for column `t.a`startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -23,7 +23,7 @@title: column.commentcontent: Column `t.a` comment is too long. The length of comment should be within 10 charactersstartposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -36,7 +36,7 @@title: column.commentcontent: Comment is required for column `t.d`startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -50,6 +50,6 @@title: column.commentcontent: Comment is required for column `t.a`startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/column_default_disallow_volatile.yaml b/backend/plugin/advisor/pg/test/column_default_disallow_volatile.yamlindex 745fcee28c..85d842a879 100644--- a/backend/plugin/advisor/pg/test/column_default_disallow_volatile.yaml+++ b/backend/plugin/advisor/pg/test/column_default_disallow_volatile.yaml@@ -8,6 +8,6 @@title: column.default-disallow-volatilecontent: Column "tech_book"."b" in schema "public" has volatile DEFAULTstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml b/backend/plugin/advisor/pg/test/column_disallow_change_type.yamlindex 1e25918385..4541a807e6 100644--- a/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml+++ b/backend/plugin/advisor/pg/test/column_disallow_change_type.yaml@@ -6,7 +6,7 @@title: column.disallow-change-typecontent: The statement "ALTER TABLE tech_book ALTER COLUMN id SET DATA TYPE INTEGER" changes column typestartposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ADD COLUMN c1 intdiff --git a/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml b/backend/plugin/advisor/pg/test/column_maximum_character_length.yamlindex 965ef715e1..d6eeec361b 100644--- a/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml+++ b/backend/plugin/advisor/pg/test/column_maximum_character_length.yaml@@ -10,7 +10,7 @@title: column.maximum-character-lengthcontent: The length of the CHAR column "name" in table "t" is bigger than 20, please use VARCHAR insteadstartposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE public.tech_book ADD COLUMN name_2 char(225)@@ -21,7 +21,7 @@title: column.maximum-character-lengthcontent: The length of the CHAR column "name_2" in table "public"."tech_book" is bigger than 20, please use VARCHAR insteadstartposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ALTER COLUMN name SET DATA TYPE char(225)@@ -32,6 +32,6 @@title: column.maximum-character-lengthcontent: The length of the CHAR column "name" in table "tech_book" is bigger than 20, please use VARCHAR insteadstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/column_no_null.yaml b/backend/plugin/advisor/pg/test/column_no_null.yamlindex 878ebc33dc..895f757eb0 100644--- a/backend/plugin/advisor/pg/test/column_no_null.yaml+++ b/backend/plugin/advisor/pg/test/column_no_null.yaml@@ -10,7 +10,7 @@title: column.no-nullcontent: Column "id" in "public"."book" cannot have NULL valuestartposition:- line: 1+ line: 2column: 0endposition: null- status: 2@@ -18,7 +18,7 @@title: column.no-nullcontent: Column "name" in "public"."book" cannot have NULL valuestartposition:- line: 2+ line: 3column: 0endposition: null- statement: CREATE TABLE book(id int, name varchar(255), PRIMARY KEY (id))@@ -29,7 +29,7 @@title: column.no-nullcontent: Column "name" in "public"."book" cannot have NULL valuestartposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255))@@ -40,7 +40,7 @@title: column.no-nullcontent: Column "name" in "public"."book" cannot have NULL valuestartposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id int NOT NULL, name varchar(255))@@ -51,7 +51,7 @@title: column.no-nullcontent: Column "name" in "public"."book" cannot have NULL valuestartposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id int PRIMARY KEY, name varchar(255) NOT NULL)@@ -64,7 +64,7 @@title: column.no-nullcontent: Column "reader" in "public"."tech_book" cannot have NULL valuestartposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -82,7 +82,7 @@title: column.no-nullcontent: Column "name" in "public"."tech_book" cannot have NULL valuestartposition:- line: 0+ line: 1column: 0endposition: null- statement: /* this is a comment */diff --git a/backend/plugin/advisor/pg/test/column_require_default.yaml b/backend/plugin/advisor/pg/test/column_require_default.yamlindex 2aed84eef3..65691f6aba 100644--- a/backend/plugin/advisor/pg/test/column_require_default.yaml+++ b/backend/plugin/advisor/pg/test/column_require_default.yaml@@ -11,7 +11,7 @@title: column.require-defaultcontent: Column "t"."a" in schema "public" doesn't have DEFAULTstartposition:- line: 1+ line: 2column: 0endposition: null- status: 2@@ -19,7 +19,7 @@title: column.require-defaultcontent: Column "t"."b" in schema "public" doesn't have DEFAULTstartposition:- line: 2+ line: 3column: 0endposition: null- statement: CREATE TABLE t(a serial primary key, b int default 1)@@ -36,7 +36,7 @@title: column.require-defaultcontent: Column "t"."a" in schema "public" doesn't have DEFAULTstartposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -49,7 +49,7 @@title: column.require-defaultcontent: Column "tech_book"."a" in schema "public" doesn't have DEFAULTstartposition:- line: 0+ line: 1column: 0endposition: null- status: 2@@ -57,6 +57,6 @@title: column.require-defaultcontent: Column "tech_book"."b" in schema "public" doesn't have DEFAULTstartposition:- line: 1+ line: 2column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/column_required.yaml b/backend/plugin/advisor/pg/test/column_required.yamlindex b3eb2252d7..e0ed57553b 100644--- a/backend/plugin/advisor/pg/test/column_required.yaml+++ b/backend/plugin/advisor/pg/test/column_required.yaml@@ -6,7 +6,7 @@title: column.requiredcontent: 'Table "book" requires columns: created_ts, creator_id, updated_ts, updater_id'startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -27,7 +27,7 @@title: column.requiredcontent: 'Table "tech_book" requires columns: creator_id'startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -40,6 +40,6 @@title: column.requiredcontent: 'Table "tech_book" requires columns: creator_id'startposition:- line: 1+ line: 2column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml b/backend/plugin/advisor/pg/test/column_type_disallow_list.yamlindex 974bf2fb39..c24eefb0e3 100644--- a/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml+++ b/backend/plugin/advisor/pg/test/column_type_disallow_list.yaml@@ -8,7 +8,7 @@title: column.type-disallow-listcontent: Disallow column type JSON but column "t"."b" isstartposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -21,6 +21,6 @@title: column.type-disallow-listcontent: Disallow column type JSON but column "t"."a" isstartposition:- line: 1+ line: 2column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/index_create_concurrently.yaml b/backend/plugin/advisor/pg/test/index_create_concurrently.yamlindex d1b88c726c..564d6485c9 100644--- a/backend/plugin/advisor/pg/test/index_create_concurrently.yaml+++ b/backend/plugin/advisor/pg/test/index_create_concurrently.yaml@@ -6,7 +6,7 @@title: index.create-concurrentlycontent: Creating indexes will block writes on the table, unless use CONCURRENTLYstartposition:- line: 0+ line: 1column: 0endposition: null- statement: create index concurrently on tech_book(id);diff --git a/backend/plugin/advisor/pg/test/index_key_number_limit.yaml b/backend/plugin/advisor/pg/test/index_key_number_limit.yamlindex 467b8edfc3..7f413d596f 100644--- a/backend/plugin/advisor/pg/test/index_key_number_limit.yaml+++ b/backend/plugin/advisor/pg/test/index_key_number_limit.yaml@@ -12,7 +12,7 @@title: index.key-number-limitcontent: The number of keys of index "t_id_name" in table "t" should be not greater than 5startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE t(id int, name char(225), c1 int, c2 int, c3 int, c4 int, CONSTRAINT t_id_name UNIQUE (id, name, c1, c2, c3, c4));@@ -23,7 +23,7 @@title: index.key-number-limitcontent: The number of keys of index "t_id_name" in table "t" should be not greater than 5startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -36,7 +36,7 @@title: index.key-number-limitcontent: The number of keys of index "idx_address_phone" in table "address" should be not greater than 5startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -49,7 +49,7 @@title: index.key-number-limitcontent: The number of keys of index "idx_address_phone" in table "address" should be not greater than 5startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -62,6 +62,6 @@title: index.key-number-limitcontent: The number of keys of index "address_id_name" in table "address" should be not greater than 5startposition:- line: 1+ line: 2column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml b/backend/plugin/advisor/pg/test/index_no_duplicate_column.yamlindex 120b66b6b5..f64dbd808b 100644--- a/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml+++ b/backend/plugin/advisor/pg/test/index_no_duplicate_column.yaml@@ -11,7 +11,7 @@title: index.no-duplicate-columncontent: PRIMARY KEY "" has duplicate column "t"."a"startposition:- line: 2+ line: 3column: 0endposition: null- statement: |-@@ -24,7 +24,7 @@title: index.no-duplicate-columncontent: INDEX "idx_a" has duplicate column "t"."a"startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -37,7 +37,7 @@title: index.no-duplicate-columncontent: UNIQUE KEY "uk_a" has duplicate column "t"."a"startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -50,7 +50,7 @@title: index.no-duplicate-columncontent: PRIMARY KEY "pk_a" has duplicate column "t"."a"startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -63,6 +63,6 @@title: index.no-duplicate-columncontent: FOREIGN KEY "fk_a" has duplicate column "t"."a"startposition:- line: 1+ line: 2column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml b/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yamlindex 7a6b2bad7e..081fdbe689 100644--- a/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml+++ b/backend/plugin/advisor/pg/test/index_primary_key_type_allowlist.yaml@@ -13,7 +13,7 @@title: index.primary-key-type-allowlistcontent: The column "a" is one of the primary key, but its type "character varying(20)" is not in allowliststartposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -28,6 +28,6 @@title: index.primary-key-type-allowlistcontent: The column "a" is one of the primary key, but its type "character varying(20)" is not in allowliststartposition:- line: 1+ line: 2column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/index_total_number_limit.yaml b/backend/plugin/advisor/pg/test/index_total_number_limit.yamlindex b73987ed66..0da89ace7c 100644--- a/backend/plugin/advisor/pg/test/index_total_number_limit.yaml+++ b/backend/plugin/advisor/pg/test/index_total_number_limit.yaml@@ -15,7 +15,7 @@title: index.total-number-limitcontent: The count of index in table "public"."tech_book" should be no more than 5, but found 8startposition:- line: 4+ line: 5column: 0endposition: null- statement: |-@@ -32,7 +32,7 @@title: index.total-number-limitcontent: The count of index in table "public"."t" should be no more than 5, but found 6startposition:- line: 5+ line: 6column: 0endposition: null- statement: |-@@ -52,6 +52,6 @@title: index.total-number-limitcontent: The count of index in table "public"."t" should be no more than 5, but found 6startposition:- line: 8+ line: 9column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/naming_column.yaml b/backend/plugin/advisor/pg/test/naming_column.yamlindex be23b22c8c..476da7f842 100644--- a/backend/plugin/advisor/pg/test/naming_column.yaml+++ b/backend/plugin/advisor/pg/test/naming_column.yaml@@ -6,7 +6,7 @@title: naming.columncontent: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id int, qavszgslczmsacubtvyymzhojfytkcmon int)@@ -25,7 +25,7 @@title: naming.columncontent: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -42,7 +42,7 @@title: naming.columncontent: '"book"."creatorId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-diff --git a/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml b/backend/plugin/advisor/pg/test/naming_fully_qualified.yamlindex d31ca2e5e1..f09ac6c1b3 100644--- a/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml+++ b/backend/plugin/advisor/pg/test/naming_fully_qualified.yaml@@ -10,7 +10,7 @@title: naming.fully-qualifiedcontent: 'unqualified object name: ''pokesv2'''startposition:- line: 3+ line: 4column: 0endposition: null- statement: |-@@ -24,7 +24,7 @@title: naming.fully-qualifiedcontent: 'unqualified object name: ''seq'''startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -40,7 +40,7 @@title: naming.fully-qualifiedcontent: 'unqualified object name: ''pokesv1'''startposition:- line: 3+ line: 4column: 0endposition: null- statement: DROP TRIGGER test_trigger ON public.pokes;@@ -55,7 +55,7 @@title: naming.fully-qualifiedcontent: 'unqualified object name: ''pokesv1'''startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -69,7 +69,7 @@title: naming.fully-qualifiedcontent: 'unqualified object name: ''pokesv1'''startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -85,7 +85,7 @@title: naming.fully-qualifiedcontent: 'unqualified object name: ''pokesv1'''startposition:- line: 3+ line: 4column: 0endposition: null- statement: "CREATE TABLE public.pokes (foo int); \nSELECT * FROM (SELECT (id) FROM tech_book) AS foo;"@@ -96,7 +96,7 @@title: naming.fully-qualifiedcontent: 'unqualified object name: ''tech_book'''startposition:- line: 1+ line: 2column: 0endposition: null- statement: "CREATE TABLE public.pokes (foo int);\nWITH foo1 AS (SELECT * FROM public.tech_book) \nSELECT * FROM foo1;"diff --git a/backend/plugin/advisor/pg/test/naming_index_fk.yaml b/backend/plugin/advisor/pg/test/naming_index_fk.yamlindex 87b0d18354..8ccacc5cb9 100644--- a/backend/plugin/advisor/pg/test/naming_index_fk.yaml+++ b/backend/plugin/advisor/pg/test/naming_index_fk.yaml@@ -8,7 +8,7 @@title: naming.index.fkcontent: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "fk_author_id"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT wlwflloczhmazamdotbibvqrrzyhmvkslvyzpmlmxt FOREIGN KEY (author_id) REFERENCES author (id)@@ -19,7 +19,7 @@title: naming.index.fkcontent: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "wlwflloczhmazamdotbibvqrrzyhmvkslvyzpmlmxt"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ADD COLUMN author_id INT CONSTRAINT fk_tech_book_author_id_author_id REFERENCES author (id)@@ -32,7 +32,7 @@title: naming.index.fkcontent: Foreign key in table "tech_book" mismatches the naming convention, expect "^$|^fk_tech_book_author_id_author_id$" but found "fk_author_id"startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))@@ -45,7 +45,7 @@title: naming.index.fkcontent: Foreign key in table "book" mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found "fk_book_author_id"startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id INT, author_id INT CONSTRAINT fk_book_author_id_author_id REFERENCES author (id))@@ -63,6 +63,6 @@title: naming.index.fkcontent: Foreign key in table "book" mismatches the naming convention, expect "^$|^fk_book_author_id_author_id$" but found "fk_book_author_id"startposition:- line: 3+ line: 4column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/naming_index_idx.yaml b/backend/plugin/advisor/pg/test/naming_index_idx.yamlindex c97fe71747..55040616e3 100644--- a/backend/plugin/advisor/pg/test/naming_index_idx.yaml+++ b/backend/plugin/advisor/pg/test/naming_index_idx.yaml@@ -8,7 +8,7 @@title: naming.index.idxcontent: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "tech_book_id_name"startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE INDEX wfdtqyetsyoovcvikjlyfukxyjxxxhifl ON tech_book(id, name)@@ -19,7 +19,7 @@title: naming.index.idxcontent: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "wfdtqyetsyoovcvikjlyfukxyjxxxhifl"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER INDEX old_index RENAME TO idx_tech_book_id_name@@ -32,6 +32,6 @@title: naming.index.idxcontent: Index in table "tech_book" mismatches the naming convention, expect "^$|^idx_tech_book_id_name$" but found "idx_tech_book"startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/naming_index_pk.yaml b/backend/plugin/advisor/pg/test/naming_index_pk.yamlindex d16aa1ac63..6e9faff391 100644--- a/backend/plugin/advisor/pg/test/naming_index_pk.yaml+++ b/backend/plugin/advisor/pg/test/naming_index_pk.yaml@@ -8,7 +8,7 @@title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "tech_book_id_name"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT udmhjtnsaablcmjhqcznfiwtnevcehcvw PRIMARY KEY (id, name)@@ -19,7 +19,7 @@title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "udmhjtnsaablcmjhqcznfiwtnevcehcvw"startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id INT, name VARCHAR(20), CONSTRAINT pk_book_name PRIMARY KEY (name))@@ -38,7 +38,7 @@title: naming.index.pkcontent: Primary key in table "book" mismatches the naming convention, expect "^$|^pk_book_name$" but found "tech_book_name"startposition:- line: 4+ line: 5column: 0endposition: null- statement: CREATE TABLE book(id INT, name VARCHAR(20), PRIMARY KEY (name))@@ -55,7 +55,7 @@title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book RENAME CONSTRAINT old_pk TO pk_tech_book_id_name@@ -68,7 +68,7 @@title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER INDEX old_pk RENAME TO pk_tech_book_id_name@@ -81,6 +81,6 @@title: naming.index.pkcontent: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id_name$" but found "pk_tech_book"startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/naming_index_uk.yaml b/backend/plugin/advisor/pg/test/naming_index_uk.yamlindex 08282fb5ff..247f5c6ac6 100644--- a/backend/plugin/advisor/pg/test/naming_index_uk.yaml+++ b/backend/plugin/advisor/pg/test/naming_index_uk.yaml@@ -8,7 +8,7 @@title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "tech_book_id_name"startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE UNIQUE INDEX dzfzqbhnkiiegdhvqjeqoevesfuwcmokrehxlapoqj ON tech_book(id, name)@@ -19,7 +19,7 @@title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "dzfzqbhnkiiegdhvqjeqoevesfuwcmokrehxlapoqj"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ADD CONSTRAINT uk_tech_book_id_name UNIQUE (id, name)@@ -32,7 +32,7 @@title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "tech_book_id_name"startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), CONSTRAINT uk_book_name UNIQUE (name))@@ -51,7 +51,7 @@title: naming.index.ukcontent: Unique key in table "book" mismatches the naming convention, expect "^$|^uk_book_name$" but found "book_name"startposition:- line: 4+ line: 5column: 0endposition: null- statement: CREATE TABLE book(id INT PRIMARY KEY, name VARCHAR(20), UNIQUE (name))@@ -68,7 +68,7 @@title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book RENAME CONSTRAINT old_uk TO uk_tech_book_id_name@@ -81,7 +81,7 @@title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER INDEX old_uk RENAME TO uk_tech_book_id_name@@ -94,6 +94,6 @@title: naming.index.ukcontent: Unique key in table "tech_book" mismatches the naming convention, expect "^$|^uk_tech_book_id_name$" but found "uk_tech_book"startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/naming_table.yaml b/backend/plugin/advisor/pg/test/naming_table.yamlindex 6331449094..05d68fb8ac 100644--- a/backend/plugin/advisor/pg/test/naming_table.yaml+++ b/backend/plugin/advisor/pg/test/naming_table.yaml@@ -6,7 +6,7 @@title: naming.tablecontent: '"techBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE "rlcmidzlevbivwvcntihenpoibtiutqeb"(id int, name varchar(255))@@ -19,7 +19,7 @@title: naming.tablecontent: '"_techbook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE techBook(id int, name varchar(255))@@ -34,7 +34,7 @@title: naming.tablecontent: '"TechBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -51,7 +51,7 @@title: naming.tablecontent: '"_techbook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'startposition:- line: 0+ line: 1column: 0endposition: null- status: 2@@ -59,6 +59,6 @@title: naming.tablecontent: '"TechBook" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'startposition:- line: 1+ line: 2column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml b/backend/plugin/advisor/pg/test/schema_backward_compatibility.yamlindex 66c7f50d7e..5634d89b14 100644--- a/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml+++ b/backend/plugin/advisor/pg/test/schema_backward_compatibility.yaml@@ -6,6 +6,6 @@title: schema.backward-compatibilitycontent: '"ALTER TABLE tech_book ALTER COLUMN name TYPE TEXT" may cause incompatibility with the existing data and code'startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml b/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yamlindex cdbe0d8eeb..db79c3a467 100644--- a/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml+++ b/backend/plugin/advisor/pg/test/statement_add_check_not_valid.yaml@@ -6,7 +6,7 @@title: statement.add-check-not-validcontent: Adding check constraints with validation will block reads and writes. You can add check constraints not valid and then validate separatelystartposition:- line: 0+ line: 1column: 0endposition: null- statement: alter table tech_book add constraint check_id check(id > 0) NOT VALID;diff --git a/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml b/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yamlindex d25ff0b339..9fe5e326c4 100644--- a/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml+++ b/backend/plugin/advisor/pg/test/statement_add_foreign_key_not_valid.yaml@@ -18,7 +18,7 @@title: statement.add-foreign-key-not-validcontent: Adding foreign keys with validation will block reads and writes. You can add check foreign keys not valid and then validate separatelystartposition:- line: 11+ line: 12column: 0endposition: null- statement: |-diff --git a/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml b/backend/plugin/advisor/pg/test/statement_create_specify_schema.yamlindex 14c22b4748..0e2c765b41 100644--- a/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml+++ b/backend/plugin/advisor/pg/test/statement_create_specify_schema.yaml@@ -6,7 +6,7 @@title: statement.create-specify-schemacontent: Table schema should be specified.startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE public.t(id int);diff --git a/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml b/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yamlindex 331a292748..758055fbf9 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_add_column_with_default.yaml@@ -8,6 +8,6 @@title: statement.disallow-add-column-with-defaultcontent: Adding column with DEFAULT will locked the whole table and rewriting each rowsstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml b/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yamlindex cbbdc63cdb..516692b1c8 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_add_not_null.yaml@@ -6,7 +6,7 @@title: statement.disallow-add-not-nullcontent: Setting NOT NULL will block reads and writes. You can use CHECK ("name" IS NOT NULL) insteadstartposition:- line: 0+ line: 1column: 0endposition: null- statement: |-diff --git a/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml b/backend/plugin/advisor/pg/test/statement_disallow_commit.yamlindex 66ce58abf6..58b8b737c7 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_commit.yaml@@ -9,7 +9,7 @@title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'startposition:- line: 2+ line: 3column: 0endposition: null- statement: |-@@ -27,7 +27,7 @@title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'startposition:- line: 2+ line: 3column: 0endposition: null- status: 2@@ -35,6 +35,6 @@title: statement.disallow-commitcontent: 'Commit is not allowed, related statement: "COMMIT;"'startposition:- line: 6+ line: 7column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_disallow_mix_in_ddl.yaml b/backend/plugin/advisor/pg/test/statement_disallow_mix_in_ddl.yamlindex 2455aa3b98..70e3e82b33 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_mix_in_ddl.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_mix_in_ddl.yaml@@ -6,7 +6,7 @@title: statement.disallow-mix-in-ddlcontent: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDLstartposition:- line: 0+ line: 1column: 0endposition: null- statement: UPDATE tech_book SET id = 1;@@ -17,7 +17,7 @@title: statement.disallow-mix-in-ddlcontent: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDLstartposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ADD COLUMN author TEXT; UPDATE tech_book SET id = 1;DELETE FROM tech_book WHERE a > 1;@@ -28,7 +28,7 @@title: statement.disallow-mix-in-ddlcontent: Alter schema can only run DDL, "DELETE FROM tech_book WHERE a > 1;" is not DDLstartposition:- line: 0+ line: 1column: 0endposition: null- status: 2@@ -36,6 +36,6 @@title: statement.disallow-mix-in-ddlcontent: Alter schema can only run DDL, "UPDATE tech_book SET id = 1;" is not DDLstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_disallow_mix_in_dml.yaml b/backend/plugin/advisor/pg/test/statement_disallow_mix_in_dml.yamlindex 58503bd9b5..3c10935ca0 100644--- a/backend/plugin/advisor/pg/test/statement_disallow_mix_in_dml.yaml+++ b/backend/plugin/advisor/pg/test/statement_disallow_mix_in_dml.yaml@@ -10,6 +10,6 @@title: statement.disallow-mix-in-dmlcontent: Data change can only run DML, "ALTER TABLE tech_book ADD COLUMN author TEXT;" is not DMLstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml b/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yamlindex b669c7d165..1a68ee82e8 100644--- a/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml+++ b/backend/plugin/advisor/pg/test/statement_insert_disallow_order_by_rand.yaml@@ -8,6 +8,6 @@title: statement.insert.disallow-order-by-randcontent: The INSERT statement uses ORDER BY random() or random_between(), related statement "INSERT INTO tech_book SELECT * FROM tech_book ORDER BY random()"startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml b/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yamlindex 797bb0af01..b089a7fc59 100644--- a/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml+++ b/backend/plugin/advisor/pg/test/statement_insert_must_specify_column.yaml@@ -8,6 +8,6 @@title: statement.insert.must-specify-columncontent: The INSERT statement must specify columns but "INSERT INTO tech_book VALUES (1, '1')" does notstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml b/backend/plugin/advisor/pg/test/statement_insert_row_limit.yamlindex c72a05b224..ff6a96ce06 100644--- a/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml+++ b/backend/plugin/advisor/pg/test/statement_insert_row_limit.yaml@@ -8,7 +8,7 @@title: statement.insert.row-limitcontent: The statement "INSERT INTO tech_book values(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')" inserts 6 rows. The count exceeds 5.startposition:- line: 0+ line: 1column: 0endposition: null- statement: INSERT INTO tech_book SELECT * FROM tech_book;diff --git a/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml b/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yamlindex 7c53075e8d..3b0124f5ea 100644--- a/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml+++ b/backend/plugin/advisor/pg/test/statement_maximum_limit_value.yaml@@ -7,6 +7,6 @@title: statement.maximum-limit-valuecontent: The limit value 1000000 exceeds the maximum allowed value 1000startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml b/backend/plugin/advisor/pg/test/statement_merge_alter_table.yamlindex b3f7f4bef9..88e5ef986d 100644--- a/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml+++ b/backend/plugin/advisor/pg/test/statement_merge_alter_table.yaml@@ -11,6 +11,6 @@title: statement.merge-alter-tablecontent: There are 2 statements to modify table `t`startposition:- line: 2+ line: 3column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_non_transactional.yaml b/backend/plugin/advisor/pg/test/statement_non_transactional.yamlindex 707018990f..992f3c9fe3 100644--- a/backend/plugin/advisor/pg/test/statement_non_transactional.yaml+++ b/backend/plugin/advisor/pg/test/statement_non_transactional.yaml@@ -8,7 +8,7 @@title: statement.non-transactionalcontent: This statement is non-transactionalstartposition:- line: 0+ line: 1column: 0endposition: null- statement: VACUUM FULL tech_book@@ -19,6 +19,6 @@title: statement.non-transactionalcontent: This statement is non-transactionalstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml b/backend/plugin/advisor/pg/test/statement_select_no_select_all.yamlindex 3e4965a0d6..be1d9ece14 100644--- a/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml+++ b/backend/plugin/advisor/pg/test/statement_select_no_select_all.yaml@@ -6,7 +6,7 @@title: statement.select.no-select-allcontent: '"SELECT * FROM t" uses SELECT all'startposition:- line: 0+ line: 1column: 0endposition: null- statement: SELECT a, b FROM t@@ -19,7 +19,7 @@title: statement.select.no-select-allcontent: '"SELECT a, b FROM (SELECT * from t1, t2) t" uses SELECT all'startposition:- line: 0+ line: 1column: 0endposition: null- statement: INSERT INTO t SELECT * FROM t1@@ -30,6 +30,6 @@title: statement.select.no-select-allcontent: '"INSERT INTO t SELECT * FROM t1" uses SELECT all'startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml b/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yamlindex 6df20f31e3..1e2a33d904 100644--- a/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml+++ b/backend/plugin/advisor/pg/test/statement_where_no_leading_wildcard_like.yaml@@ -8,7 +8,7 @@title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''%abc''" uses leading wildcard LIKE'startposition:- line: 0+ line: 1column: 0endposition: null- statement: SELECT * FROM t WHERE a LIKE 'abc' OR a LIKE '%abc'@@ -19,7 +19,7 @@title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''abc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'startposition:- line: 0+ line: 1column: 0endposition: null- statement: SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc'@@ -30,7 +30,7 @@title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc''" uses leading wildcard LIKE'startposition:- line: 0+ line: 1column: 0endposition: null- statement: SELECT * FROM (SELECT * FROM t WHERE a LIKE '%acc' OR a LIKE '%abc') t1@@ -41,6 +41,6 @@title: statement.where.no-leading-wildcard-likecontent: '"SELECT * FROM (SELECT * FROM t WHERE a LIKE ''%acc'' OR a LIKE ''%abc'') t1" uses leading wildcard LIKE'startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/statement_where_require_select.yaml b/backend/plugin/advisor/pg/test/statement_where_require_select.yamlindex 0ab57157ae..9d01185a66 100644--- a/backend/plugin/advisor/pg/test/statement_where_require_select.yaml+++ b/backend/plugin/advisor/pg/test/statement_where_require_select.yaml@@ -6,7 +6,7 @@title: statement.where.require.selectcontent: '"SELECT a FROM t" requires WHERE clause'startposition:- line: 0+ line: 1column: 0endposition: null- statement: SELECT a FROM t WHERE a > 0@@ -19,7 +19,7 @@title: statement.where.require.selectcontent: '"SELECT a FROM t WHERE a > (SELECT max(id) FROM user)" requires WHERE clause'startposition:- line: 0+ line: 1column: 0endposition: null- statement: SELECT 1diff --git a/backend/plugin/advisor/pg/test/statement_where_require_update_delete.yaml b/backend/plugin/advisor/pg/test/statement_where_require_update_delete.yamlindex 58533cf9a0..0feac1472f 100644--- a/backend/plugin/advisor/pg/test/statement_where_require_update_delete.yaml+++ b/backend/plugin/advisor/pg/test/statement_where_require_update_delete.yaml@@ -6,7 +6,7 @@title: statement.where.require.update-deletecontent: '"DELETE FROM t1" requires WHERE clause'startposition:- line: 0+ line: 1column: 0endposition: null- statement: UPDATE t1 SET a = 1@@ -17,7 +17,7 @@title: statement.where.require.update-deletecontent: '"UPDATE t1 SET a = 1" requires WHERE clause'startposition:- line: 0+ line: 1column: 0endposition: null- statement: DELETE FROM t1 WHERE a > 0diff --git a/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml b/backend/plugin/advisor/pg/test/system_collation_allowlist.yamlindex 4be6d1219e..7edae7f7c8 100644--- a/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml+++ b/backend/plugin/advisor/pg/test/system_collation_allowlist.yaml@@ -8,7 +8,7 @@title: system.collation.allowlistcontent: Use disabled collation "unknown", related statement "CREATE TABLE t(a text COLLATE "unknown")"startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ADD COLUMN c1 text COLLATE "unknown"@@ -19,7 +19,7 @@title: system.collation.allowlistcontent: Use disabled collation "unknown", related statement "ALTER TABLE tech_book ADD COLUMN c1 text COLLATE "unknown""startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ALTER COLUMN id TYPE text COLLATE "unknown"@@ -30,6 +30,6 @@title: system.collation.allowlistcontent: Use disabled collation "unknown", related statement "ALTER TABLE tech_book ALTER COLUMN id TYPE text COLLATE "unknown""startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/system_comment_length.yaml b/backend/plugin/advisor/pg/test/system_comment_length.yamlindex 8f2a84eb72..1718cdfdb7 100644--- a/backend/plugin/advisor/pg/test/system_comment_length.yaml+++ b/backend/plugin/advisor/pg/test/system_comment_length.yaml@@ -8,7 +8,7 @@title: system.comment.lengthcontent: The length of comment should be within 20 charactersstartposition:- line: 0+ line: 1column: 0endposition: null- statement: comment on table public is 'is a table name'@@ -21,6 +21,6 @@title: system.comment.lengthcontent: The length of comment should be within 20 charactersstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/table_comment.yaml b/backend/plugin/advisor/pg/test/table_comment.yamlindex 1bdd1be352..261c7e3a64 100644--- a/backend/plugin/advisor/pg/test/table_comment.yaml+++ b/backend/plugin/advisor/pg/test/table_comment.yaml@@ -10,7 +10,7 @@title: table.commentcontent: Comment is required for table `t`startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -24,7 +24,7 @@title: table.commentcontent: Comment is required for table `d`startposition:- line: 1+ line: 2column: 0endposition: null- statement: |-@@ -38,7 +38,7 @@title: table.commentcontent: Comment is required for table `t`startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -52,7 +52,7 @@title: table.commentcontent: Comment is required for table `t`startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-@@ -65,6 +65,6 @@title: table.commentcontent: Table `t` comment is too long. The length of comment should be within 10 charactersstartposition:- line: 1+ line: 2column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/table_disallow_partition.yaml b/backend/plugin/advisor/pg/test/table_disallow_partition.yamlindex b8d8cb3cfb..fe50b1ebe2 100644--- a/backend/plugin/advisor/pg/test/table_disallow_partition.yaml+++ b/backend/plugin/advisor/pg/test/table_disallow_partition.yaml@@ -8,7 +8,7 @@title: table.disallow-partitioncontent: Table partition is forbidden, but "CREATE TABLE t(a int) PARTITION BY RANGE (a);" createsstartposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE tech_book ATTACH PARTITION p1 DEFAULT;@@ -19,6 +19,6 @@title: table.disallow-partitioncontent: Table partition is forbidden, but "ALTER TABLE tech_book ATTACH PARTITION p1 DEFAULT;" createsstartposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml b/backend/plugin/advisor/pg/test/table_drop_naming_convention.yamlindex 0bc06a44c6..7dd7f76328 100644--- a/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml+++ b/backend/plugin/advisor/pg/test/table_drop_naming_convention.yaml@@ -8,7 +8,7 @@title: table.drop-naming-conventioncontent: '`foo` mismatches drop table naming convention, naming format should be "_delete$"'startposition:- line: 0+ line: 1column: 0endposition: null- statement: DROP TABLE IF EXISTS foo_delete, bar@@ -19,6 +19,6 @@title: table.drop-naming-conventioncontent: '`bar` mismatches drop table naming convention, naming format should be "_delete$"'startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml b/backend/plugin/advisor/pg/test/table_no_foreign_key.yamlindex 8bb4c676ca..acf0effa26 100644--- a/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml+++ b/backend/plugin/advisor/pg/test/table_no_foreign_key.yaml@@ -6,7 +6,7 @@title: table.no-foreign-keycontent: 'Foreign key is not allowed in the table "public"."tech_book", related statement: "ALTER TABLE tech_book ADD CONSTRAINT fk_tech_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id)"'startposition:- line: 0+ line: 1column: 0endposition: null- statement: CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))@@ -17,6 +17,6 @@title: table.no-foreign-keycontent: 'Foreign key is not allowed in the table "public"."book", related statement: "CREATE TABLE book(id INT, author_id INT, CONSTRAINT fk_book_author_id_author_id FOREIGN KEY (author_id) REFERENCES author (id))"'startposition:- line: 0+ line: 1column: 0endposition: nulldiff --git a/backend/plugin/advisor/pg/test/table_require_pk.yaml b/backend/plugin/advisor/pg/test/table_require_pk.yamlindex 50ae924304..0aa06e7cee 100644--- a/backend/plugin/advisor/pg/test/table_require_pk.yaml+++ b/backend/plugin/advisor/pg/test/table_require_pk.yaml@@ -10,7 +10,7 @@title: table.require-pkcontent: 'Table "public"."t" requires PRIMARY KEY, related statement: "CREATE TABLE t(id INT)"'startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE "tech_book" DROP CONSTRAINT "old_pk"@@ -21,7 +21,7 @@title: table.require-pkcontent: 'Table "public"."tech_book" requires PRIMARY KEY, related statement: "ALTER TABLE \"tech_book\" DROP CONSTRAINT \"old_pk\""'startposition:- line: 0+ line: 1column: 0endposition: null- statement: ALTER TABLE "tech_book" DROP CONSTRAINT "old_index"@@ -36,7 +36,7 @@title: table.require-pkcontent: 'Table "public"."tech_book" requires PRIMARY KEY, related statement: "ALTER TABLE \"tech_book\" DROP COLUMN id"'startposition:- line: 0+ line: 1column: 0endposition: null- statement: |-diff --git a/backend/plugin/parser/pg/legacy/convert_test.go b/backend/plugin/parser/pg/legacy/convert_test.goindex 199ee40adc..8dd18b241c 100644--- a/backend/plugin/parser/pg/legacy/convert_test.go+++ b/backend/plugin/parser/pg/legacy/convert_test.go@@ -3483,8 +3483,8 @@ func TestPGCreateTableSetLine(t *testing.T) {)`,- columnLineList: []int{2, 2, 3, 4},- constraintLineList: []int{5, 6, 7, 7, 10},+ columnLineList: []int{3, 3, 4, 5},+ constraintLineList: []int{6, 7, 8, 8, 11},},{// test for Windows.@@ -3499,8 +3499,8 @@ func TestPGCreateTableSetLine(t *testing.T) {"\r\n" +"FOREIGN KEY (a, b, c) REFERENCES t1(a, b, c)" + "\r\n" +")",- columnLineList: []int{2, 2, 3, 4},- constraintLineList: []int{5, 6, 7, 7, 9},+ columnLineList: []int{3, 3, 4, 5},+ constraintLineList: []int{6, 7, 8, 8, 10},},{statement: `@@ -3509,7 +3509,7 @@ func TestPGCreateTableSetLine(t *testing.T) {b int CHECK(b>1), c int UNIQUE)`,- columnLineList: []int{2, 3, 3},+ columnLineList: []int{3, 4, 4},constraintLineList: []int{},},{@@ -3521,8 +3521,8 @@ func TestPGCreateTableSetLine(t *testing.T) {UNIQUE(name))`,- columnLineList: []int{2, 3},- constraintLineList: []int{4, 5},+ columnLineList: []int{3, 4},+ constraintLineList: []int{5, 6},},}diff --git a/backend/plugin/parser/pg/legacy/parser.go b/backend/plugin/parser/pg/legacy/parser.goindex b12afdef47..94143ac375 100644--- a/backend/plugin/parser/pg/legacy/parser.go+++ b/backend/plugin/parser/pg/legacy/parser.go@@ -5,6 +5,7 @@ import ("strings"pgquery "github.com/pganalyze/pg_query_go/v6"+ "github.com/pganalyze/pg_query_go/v6/parser""github.com/pkg/errors"storepb "github.com/bytebase/bytebase/backend/generated-go/store"@@ -23,17 +24,14 @@ func init() {func parsePostgresForRegistry(statement string) (any, error) {nodes, err := Parse(ParseContext{}, statement)if err != nil {- // For ConvertError, return as-is (will be handled by convertErrorToAdvice in sheet.go)- if _, ok := err.(*ConvertError); ok {+ // If it's already a SyntaxError, return it as-is+ if _, ok := err.(*base.SyntaxError); ok {return nil, err}- // For other errors, wrap in base.SyntaxError with proper line number- line := calculatePostgresErrorLine(statement)+ // Otherwise, wrap it as a SyntaxError with line 1return nil, &base.SyntaxError{- Position: &storepb.Position{- Line: int32(line),- },- Message: err.Error(),+ Position: &storepb.Position{Line: 1},+ Message: err.Error(),}}// Filter out nil nodes@@ -46,22 +44,6 @@ func parsePostgresForRegistry(statement string) (any, error) {return res, nil}-// calculatePostgresErrorLine calculates the line number where the PostgreSQL error occurred.-func calculatePostgresErrorLine(statement string) int {- singleSQLs, err := base.SplitMultiSQL(storepb.Engine_POSTGRES, statement)- if err != nil {- return 1- }-- for _, singleSQL := range singleSQLs {- if _, err := Parse(ParseContext{}, singleSQL.Text); err != nil {- return int(singleSQL.End.GetLine())- }- }-- return 1-}-const (operatorLike string = "~~"operatorNotLike string = "!~~"@@ -94,10 +76,11 @@ func (ctx DeparseContext) WriteIndent(buf *strings.Builder, indent string) errorfunc Parse(_ ParseContext, statement string) ([]ast.Node, error) {res, err := pgquery.Parse(statement)if err != nil {- return nil, err+ // Extract line number from parser error's cursor position+ return nil, convertParserError(statement, err)}- // sikp the setting line stage+ // skip the setting line stageif len(res.Stmts) == 0 {return nil, nil}@@ -123,6 +106,32 @@ func Parse(_ ParseContext, statement string) ([]ast.Node, error) {return nodeList, nil}+// convertParserError converts a pgquery parser error to a base.SyntaxError with the correct line number.+// It extracts the line number from the parser.Error's Cursorpos field.+func convertParserError(statement string, err error) error {+ line := int32(1)++ // Try to extract cursor position from parser.Error+ if perr, ok := err.(*parser.Error); ok {+ if perr.Cursorpos > 0 {+ // Count newlines up to cursor position to get line number+ // Cursorpos is 1-based byte offset+ lineCount := 1+ for i := 0; i < perr.Cursorpos-1 && i < len(statement); i++ {+ if statement[i] == '\n' {+ lineCount+++ }+ }+ line = int32(lineCount)+ }+ }++ return &base.SyntaxError{+ Position: &storepb.Position{Line: line},+ Message: err.Error(),+ }+}+// splitSQL splits the given SQL statement into multiple SQL statements.func splitSQL(statement string) ([]base.SingleSQL, error) {t := tokenizer.NewTokenizer(statement)diff --git a/backend/plugin/parser/pg/legacy/parser_test.go b/backend/plugin/parser/pg/legacy/parser_test.gonew file mode 100644index 0000000000..c4e6140203--- /dev/null+++ b/backend/plugin/parser/pg/legacy/parser_test.go@@ -0,0 +1,200 @@+package legacy++import (+ "testing"++ "github.com/stretchr/testify/require"++ storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ "github.com/bytebase/bytebase/backend/plugin/parser/base"+)++func TestParsePostgresForRegistryError(t *testing.T) {+ tests := []struct {+ name string+ statement string+ expectedLine int32 // Expected to be the END line of the statement with error+ }{+ {+ name: "single statement with syntax error",+ statement: "SELECT * FRAM t1;",+ expectedLine: 1,+ },+ {+ name: "multi-line single statement with syntax error",+ statement: `SELECT+ 1,+ 2+FRAM t1;`,+ expectedLine: 4, // Last line of the statement+ },+ {+ name: "multiple statements - error in first",+ statement: `SELECT * FRAM t1;+SELECT 1;+SELECT 2;`,+ expectedLine: 1, // End of first statement+ },+ {+ name: "multiple statements - error in second",+ statement: `SELECT 1;+SELECT * FRAM t2;+SELECT 2;`,+ expectedLine: 2, // End of second statement+ },+ {+ name: "multiple statements - error in third",+ statement: `SELECT 1;+SELECT 2;+SELECT * FRAM t3;`,+ expectedLine: 3, // End of third statement+ },+ {+ name: "multi-line statements - error in second statement",+ statement: `SELECT+ 1,+ 2+FROM t1;+SELECT+ *+FRAM t2;`,+ expectedLine: 7, // End of second statement+ },+ {+ name: "complex multi-line - error on specific line",+ statement: `-- Comment line 1+SELECT 1;+-- Comment line 3+SELECT+ a,+ b,+ c,+ d+FRAM t1;+SELECT 2;`,+ expectedLine: 9, // End of the SELECT statement with error+ },+ {+ name: "error with WHERE typo",+ statement: `SELECT 1;+SELECT 2;+SELECT * FROM t1 WHER id = 1;`,+ expectedLine: 3, // End of third statement+ },+ {+ name: "error in second statement with indentation",+ statement: `select 1;+ selec 2;+select 3;`,+ expectedLine: 2, // End of second statement+ },+ }++ for _, test := range tests {+ t.Run(test.name, func(t *testing.T) {+ _, err := parsePostgresForRegistry(test.statement)+ require.Error(t, err, "expected syntax error for statement: %s", test.statement)+ syntaxErr, ok := err.(*base.SyntaxError)+ require.True(t, ok, "expected error to be *base.SyntaxError, got %T", err)+ require.NotNil(t, syntaxErr.Position, "expected position to be set")+ require.Equal(t, test.expectedLine, syntaxErr.Position.GetLine(),+ "incorrect line number for statement:\n%s\nError: %s", test.statement, syntaxErr.Message)+ })+ }+}++func TestParsePostgresForRegistrySuccess(t *testing.T) {+ tests := []struct {+ name string+ statement string+ }{+ {+ name: "single statement",+ statement: "SELECT 1;",+ },+ {+ name: "multiple statements",+ statement: `SELECT 1;+SELECT 2;+SELECT 3;`,+ },+ {+ name: "multi-line statement",+ statement: `SELECT+ 1,+ 2,+ 3+FROM t1;`,+ },+ {+ name: "complex multi-line statements",+ statement: `-- Comment+SELECT 1;++SELECT+ a,+ b,+ c+FROM t1+WHERE a > 1;++SELECT * FROM t2;`,+ },+ }++ for _, test := range tests {+ t.Run(test.name, func(t *testing.T) {+ result, err := parsePostgresForRegistry(test.statement)+ require.NoError(t, err, "unexpected error for statement: %s", test.statement)+ require.NotNil(t, result, "expected non-nil result")+ })+ }+}++func TestParsePostgresErrorLine(t *testing.T) {+ // Test that error line numbers are correctly reported in SyntaxError+ tests := []struct {+ name string+ statement string+ expectedLine int32+ }{+ {+ name: "single statement error",+ statement: "SELECT * FRAM t1;",+ expectedLine: 1,+ },+ {+ name: "second statement error",+ statement: `SELECT 1;+SELECT * FRAM t2;`,+ expectedLine: 2,+ },+ {+ name: "third statement error",+ statement: `SELECT 1;+SELECT 2;+SELECT * FRAM t3;`,+ expectedLine: 3,+ },+ {+ name: "error in multi-line statement",+ statement: `SELECT+ 1,+ 2+FRAM t1;`,+ expectedLine: 4,+ },+ }++ for _, test := range tests {+ t.Run(test.name, func(t *testing.T) {+ _, err := base.Parse(storepb.Engine_POSTGRES, test.statement)+ require.Error(t, err)+ syntaxErr, ok := err.(*base.SyntaxError)+ require.True(t, ok, "expected *base.SyntaxError, got %T", err)+ require.NotNil(t, syntaxErr.Position)+ require.Equal(t, test.expectedLine, syntaxErr.Position.Line,+ "incorrect error line for statement:\n%s", test.statement)+ })+ }+}diff --git a/backend/plugin/parser/tidb/tidb.go b/backend/plugin/parser/tidb/tidb.goindex 7620ee1130..cfe45ff440 100644--- a/backend/plugin/parser/tidb/tidb.go+++ b/backend/plugin/parser/tidb/tidb.go@@ -37,11 +37,21 @@ func ParseTiDBForSyntaxCheck(statement string) (any, error) {p := newTiDBParser()var returnNodes []ast.StmtNode- baseLine := 0for _, singleSQL := range singleSQLs {nodes, _, err := p.Parse(singleSQL.Text, "", "")if err != nil {- return nil, errors.Wrapf(err, "failed to parse statement at line %d", baseLine)+ // Convert parser error to SyntaxError with proper position+ syntaxErr := convertParserError(err)+ // Adjust the line number to be absolute (relative to the full statement)+ // The TiDB parser reports line numbers relative to singleSQL.Text (starting at 1)+ // We need to add the offset to get the absolute line number+ if se, ok := syntaxErr.(*base.SyntaxError); ok && se.Position != nil {+ // errorLine is 1-based relative to singleSQL.Text+ // singleSQL.BaseLine is 0-based line number of the first line in the original statement+ // Absolute line (1-based) = BaseLine (0-based) + errorLine (1-based)+ se.Position.Line = int32(singleSQL.BaseLine) + se.Position.Line+ }+ return nil, syntaxErr}if len(nodes) != 1 {@@ -57,7 +67,6 @@ func ParseTiDBForSyntaxCheck(statement string) (any, error) {}}returnNodes = append(returnNodes, node)- baseLine = int(singleSQL.End.GetLine())}return returnNodes, nildiff --git a/backend/plugin/parser/tidb/tidb_test.go b/backend/plugin/parser/tidb/tidb_test.goindex 4f1cb665ab..64f2348a40 100644--- a/backend/plugin/parser/tidb/tidb_test.go+++ b/backend/plugin/parser/tidb/tidb_test.go@@ -151,3 +151,97 @@ func TestTiDBParserError(t *testing.T) {require.Equal(t, test.expectedMsg, syntaxErr.Message)}}++func TestParseTiDBForSyntaxCheckError(t *testing.T) {+ tests := []struct {+ name string+ statement string+ expectedLine int32 // Expected to be the END line of the statement with error+ }{+ {+ name: "single statement with syntax error",+ statement: "SELECT * FRAM table;",+ expectedLine: 1,+ },+ {+ name: "multi-line single statement with syntax error",+ statement: `SELECT+ 1,+ 2+FRAM table;`,+ expectedLine: 4, // Last line of the statement+ },+ {+ name: "multiple statements - error in first",+ statement: `SELECT * FRAM t1;+SELECT 1;+SELECT 2;`,+ expectedLine: 1, // End of first statement+ },+ {+ name: "multiple statements - error in second",+ statement: `SELECT 1;+SELECT * FRAM t2;+SELECT 2;`,+ expectedLine: 2, // End of second statement+ },+ {+ name: "multiple statements - error in third",+ statement: `SELECT 1;+SELECT 2;+SELECT * FRAM t3;`,+ expectedLine: 3, // End of third statement+ },+ {+ name: "multi-line statements - error in second statement",+ statement: `SELECT+ 1,+ 2+FROM table1;+SELECT+ *+FRAM table2;`,+ expectedLine: 7, // End of second statement+ },+ {+ name: "complex multi-line - error on specific line",+ statement: `-- Comment line 1+SELECT 1;+-- Comment line 3+SELECT+ a,+ b,+ c,+ d+FRAM table;+SELECT 2;`,+ expectedLine: 9, // End of the SELECT statement with error+ },+ {+ name: "error with WHERE typo",+ statement: `SELECT 1;+SELECT 2;+SELECT * FROM t1 WHER id = 1;`,+ expectedLine: 3, // End of third statement+ },+ {+ name: "error in second statement with indentation",+ statement: `select 1;+ selec 2;+select 3;`,+ expectedLine: 2, // End of second statement+ },+ }++ for _, test := range tests {+ t.Run(test.name, func(t *testing.T) {+ _, err := ParseTiDBForSyntaxCheck(test.statement)+ require.Error(t, err, "expected syntax error for statement: %s", test.statement)+ syntaxErr, ok := err.(*base.SyntaxError)+ require.True(t, ok, "expected error to be *base.SyntaxError, got %T", err)+ require.NotNil(t, syntaxErr.Position, "expected position to be set")+ require.Equal(t, test.expectedLine, syntaxErr.Position.GetLine(),+ "incorrect line number for statement:\n%s\nError: %s", test.statement, syntaxErr.Message)+ })+ }+}diff --git a/backend/plugin/parser/tokenizer/tokenizer.go b/backend/plugin/parser/tokenizer/tokenizer.goindex f4af94bddc..06775a0fd3 100644--- a/backend/plugin/parser/tokenizer/tokenizer.go+++ b/backend/plugin/parser/tokenizer/tokenizer.go@@ -375,10 +375,10 @@ func (t *Tokenizer) SplitTiDBMultiSQL() ([]base.SingleSQL, error) {var res []base.SingleSQLdelimiter := []rune{';'}- // TODO(zp):Start position.t.skipBlank()t.emptyStatement = truestartPos := t.cursor+ startLine := t.line // Track the starting line number (1-based)for {switch {case t.char(0) == eofRune:@@ -387,6 +387,8 @@ func (t *Tokenizer) SplitTiDBMultiSQL() ([]base.SingleSQL, error) {if t.f == nil {res = append(res, base.SingleSQL{Text: s,+ // BaseLine is 0-based line number, so subtract 1 from 1-based startLine+ BaseLine: startLine - 1,// Consider this text:// CREATE TABLE t(// a int@@ -416,7 +418,9 @@ func (t *Tokenizer) SplitTiDBMultiSQL() ([]base.SingleSQL, error) {text := t.getString(startPos, t.pos()-startPos)if t.f == nil {res = append(res, base.SingleSQL{- Text: text,+ Text: text,+ // BaseLine is 0-based line number, so subtract 1 from 1-based startLine+ BaseLine: startLine - 1,End: &store.Position{Line: int32(t.line)},Empty: t.emptyStatement,ByteOffsetStart: t.getByteOffset(int(startPos)),@@ -428,6 +432,7 @@ func (t *Tokenizer) SplitTiDBMultiSQL() ([]base.SingleSQL, error) {return nil, err}startPos = t.pos()+ startLine = t.line // Update startLine for next statementt.emptyStatement = true// deal with the DELIMITER statement, see https://dev.mysql.com/doc/refman/8.0/en/stored-programs-defining.htmlcase t.equalWordCaseInsensitive(delimiterRuneList):@@ -439,7 +444,9 @@ func (t *Tokenizer) SplitTiDBMultiSQL() ([]base.SingleSQL, error) {text := t.getString(startPos, t.pos()-startPos)if t.f == nil {res = append(res, base.SingleSQL{- Text: text,+ Text: text,+ // BaseLine is 0-based line number, so subtract 1 from 1-based startLine+ BaseLine: startLine - 1,End: &store.Position{Line: int32(t.line)},Empty: false,ByteOffsetStart: t.getByteOffset(int(startPos)),@@ -451,6 +458,7 @@ func (t *Tokenizer) SplitTiDBMultiSQL() ([]base.SingleSQL, error) {return nil, err}startPos = t.pos()+ startLine = t.line // Update startLine for next statementt.emptyStatement = truecase t.char(0) == '/' && t.char(1) == '*':if err := t.scanComment(); err != nil {@@ -619,6 +627,7 @@ func (t *Tokenizer) SplitPostgreSQLMultiSQL() ([]base.SingleSQL, error) {t.skipBlank()t.emptyStatement = truestartPos := t.cursor+ startLine := t.line // Track the starting line number (1-based)for {switch {case t.char(0) == '/' && t.char(1) == '*':@@ -651,9 +660,11 @@ func (t *Tokenizer) SplitPostgreSQLMultiSQL() ([]base.SingleSQL, error) {text := t.getString(startPos, t.pos()-startPos)if t.f == nil {res = append(res, base.SingleSQL{- Text: text,- End: &store.Position{Line: int32(t.line - 1)},- Empty: t.emptyStatement,+ Text: text,+ // BaseLine is 0-based line number, so subtract 1 from 1-based startLine+ BaseLine: startLine - 1,+ End: &store.Position{Line: int32(t.line)},+ Empty: t.emptyStatement,})}t.skipBlank()@@ -661,6 +672,7 @@ func (t *Tokenizer) SplitPostgreSQLMultiSQL() ([]base.SingleSQL, error) {return nil, err}startPos = t.pos()+ startLine = t.line // Update startLine for next statementt.emptyStatement = truecase t.char(0) == eofRune:s := t.getString(startPos, t.pos())@@ -668,6 +680,8 @@ func (t *Tokenizer) SplitPostgreSQLMultiSQL() ([]base.SingleSQL, error) {if t.f == nil {res = append(res, base.SingleSQL{Text: s,+ // BaseLine is 0-based line number, so subtract 1 from 1-based startLine+ BaseLine: startLine - 1,// Consider this text:// CREATE TABLE t(// a int@@ -676,12 +690,12 @@ func (t *Tokenizer) SplitPostgreSQLMultiSQL() ([]base.SingleSQL, error) {// EOF line//// Our current location is the EOF line.- // The line t.line is the line of ')',+ // The line t.line is the line after ')',// but we want to get the line of last line of the SQL// which means the line of ')'.// So we need minus the aboveNonBlankLineDistance.End: &store.Position{- Line: int32(t.line - t.aboveNonBlankLineDistance() - 1),+ Line: int32(t.line - t.aboveNonBlankLineDistance()),},Empty: t.emptyStatement,})diff --git a/backend/tests/test-data/sql_review_pg.yaml b/backend/tests/test-data/sql_review_pg.yamlindex 68dd3b563a..75f30702a9 100644--- a/backend/tests/test-data/sql_review_pg.yaml+++ b/backend/tests/test-data/sql_review_pg.yaml@@ -51,7 +51,7 @@"code": 601,"sqlReviewReport": {"startPosition": {- "line": 6+ "line": 7}}}@@ -63,7 +63,7 @@"code": 602,"sqlReviewReport": {"startPosition": {- "line": 6+ "line": 7}}}@@ -75,7 +75,7 @@"code": 301,"sqlReviewReport": {"startPosition": {- "line": 6+ "line": 7}}}@@ -87,7 +87,7 @@"code": 302,"sqlReviewReport": {"startPosition": {- "line": 3+ "line": 4}}}@@ -99,7 +99,7 @@"code": 304,"sqlReviewReport": {"startPosition": {- "line": 4+ "line": 5}}}@@ -111,7 +111,7 @@"code": 305,"sqlReviewReport": {"startPosition": {- "line": 5+ "line": 6}}}@@ -123,7 +123,7 @@"code": 401,"sqlReviewReport": {"startPosition": {- "line": 6+ "line": 7}}}@@ -135,7 +135,7 @@"code": 402,"sqlReviewReport": {"startPosition": {- "line": 1+ "line": 2}}}@@ -147,7 +147,7 @@"code": 402,"sqlReviewReport": {"startPosition": {- "line": 2+ "line": 3}}}@@ -159,7 +159,7 @@"code": 402,"sqlReviewReport": {"startPosition": {- "line": 3+ "line": 4}}}@@ -173,7 +173,9 @@"content": "\"DELETE FROM t\" requires WHERE clause","code": 202,"sqlReviewReport": {- "startPosition": {}+ "startPosition": {+ "line": 1+ }}}run: false@@ -186,7 +188,9 @@"content": "\"DELETE FROM t WHERE a like '%abc'\" uses leading wildcard LIKE","code": 204,"sqlReviewReport": {- "startPosition": {}+ "startPosition": {+ "line": 1+ }}}run: false@@ -232,7 +236,9 @@"content": "Primary key in table \"tech_book\" mismatches the naming convention, expect \"^$|^pk_tech_book_id$\" but found \"pk1\"","code": 306,"sqlReviewReport": {- "startPosition": {}+ "startPosition": {+ "line": 1+ }}}run: false