From e664ddfaf58283800ee9fe66286437e41a52c860 Mon Sep 17 00:00:00 2001 From: fzzf678 <108643977+fzzf678@users.noreply.github.com> Date: Sun, 29 Sep 2024 17:43:17 +0800 Subject: [PATCH 1/6] Update insert_common.go --- pkg/executor/insert_common.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/executor/insert_common.go b/pkg/executor/insert_common.go index 810fb014221dc..fad6c49276d90 100644 --- a/pkg/executor/insert_common.go +++ b/pkg/executor/insert_common.go @@ -1179,11 +1179,7 @@ func (e *InsertValues) handleDuplicateKey(ctx context.Context, txn kv.Transactio if handle == nil { return false, nil } - _, err = e.removeRow(ctx, txn, handle, r, true) - if err != nil { - return false, err - } - return false, nil + return e.removeRow(ctx, txn, handle, r, true) } // batchCheckAndInsert checks rows with duplicate errors. From 0550cdf85a409e2567ebe4e98252bb367744f9e1 Mon Sep 17 00:00:00 2001 From: fzzf678 <108643977+fzzf678@users.noreply.github.com> Date: Sun, 29 Sep 2024 18:27:17 +0800 Subject: [PATCH 2/6] add test --- .../test/loaddatatest/load_data_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/executor/test/loaddatatest/load_data_test.go b/pkg/executor/test/loaddatatest/load_data_test.go index f4003a9ba676b..816987ee5664d 100644 --- a/pkg/executor/test/loaddatatest/load_data_test.go +++ b/pkg/executor/test/loaddatatest/load_data_test.go @@ -472,3 +472,21 @@ func TestLoadDataFromServerFile(t *testing.T) { err := tk.ExecToErr("load data infile 'remote.csv' into table load_data_test") require.ErrorContains(t, err, "[executor:8154]Don't support load data from tidb-server's disk.") } + +func TestFix56408(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("USE test; DROP TABLE IF EXISTS load_data_replace;") + tk.MustExec("create table a(id int,name varchar(20),addr varchar(100),primary key (id) nonclustered);") + loadSQL := "LOAD DATA LOCAL INFILE '/tmp/nonexistence.csv' REPLACE INTO TABLE a FIELDS terminated by '|';" + ctx := tk.Session().(sessionctx.Context) + tests := []testCase{ + {[]byte("1|aa|beijing\n1|aa|beijing\n1|aa|beijing\n1|aa|beijing\n2|bb|shanghai\n2|bb|shanghai\n2|bb|shanghai\n3|cc|guangzhou\n"), + []string{"1 aa beijing", "2 bb shanghai", "3 cc guangzhou"}, + "Records: 8 Deleted: 0 Skipped: 5 Warnings: 0"}, + } + deleteSQL := "DO 1" + selectSQL := "TABLE a;" + checkCases(tests, loadSQL, t, tk, ctx, selectSQL, deleteSQL) + tk.MustExec("ADMIN CHECK TABLE a") +} From 4fa3b820a59fea286c5d26eff4b63bff8400c0a0 Mon Sep 17 00:00:00 2001 From: fzzf678 <108643977+fzzf678@users.noreply.github.com> Date: Sun, 29 Sep 2024 18:57:28 +0800 Subject: [PATCH 3/6] undo --- pkg/executor/test/loaddatatest/load_data_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/executor/test/loaddatatest/load_data_test.go b/pkg/executor/test/loaddatatest/load_data_test.go index 816987ee5664d..a5cb6d2630a5e 100644 --- a/pkg/executor/test/loaddatatest/load_data_test.go +++ b/pkg/executor/test/loaddatatest/load_data_test.go @@ -482,7 +482,9 @@ func TestFix56408(t *testing.T) { ctx := tk.Session().(sessionctx.Context) tests := []testCase{ {[]byte("1|aa|beijing\n1|aa|beijing\n1|aa|beijing\n1|aa|beijing\n2|bb|shanghai\n2|bb|shanghai\n2|bb|shanghai\n3|cc|guangzhou\n"), + //[]string{"1 aa beijing", "1 aa beijing", "1 aa beijing", "1 aa beijing", "2 bb shanghai", "2 bb shanghai", "2 bb shanghai", "3 cc guangzhou"}, []string{"1 aa beijing", "2 bb shanghai", "3 cc guangzhou"}, + //"Records: 8 Deleted: 0 Skipped: 0 Warnings: 0"}, "Records: 8 Deleted: 0 Skipped: 5 Warnings: 0"}, } deleteSQL := "DO 1" From 8a4589fb22e82d6bec701f56a745ec549e340a82 Mon Sep 17 00:00:00 2001 From: fzzf678 <108643977+fzzf678@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:31:11 +0800 Subject: [PATCH 4/6] fix bazel --- pkg/executor/test/loaddatatest/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/executor/test/loaddatatest/BUILD.bazel b/pkg/executor/test/loaddatatest/BUILD.bazel index 1253bceb1b4c8..88853b38caccb 100644 --- a/pkg/executor/test/loaddatatest/BUILD.bazel +++ b/pkg/executor/test/loaddatatest/BUILD.bazel @@ -9,7 +9,7 @@ go_test( ], flaky = True, race = "on", - shard_count = 11, + shard_count = 12, deps = [ "//pkg/config", "//pkg/executor", From 2b5ef43801feed79f67fc1a40e91f185a8ba9672 Mon Sep 17 00:00:00 2001 From: fzzf678 <108643977+fzzf678@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:24:04 +0800 Subject: [PATCH 5/6] remove comment --- pkg/executor/test/loaddatatest/load_data_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/executor/test/loaddatatest/load_data_test.go b/pkg/executor/test/loaddatatest/load_data_test.go index a5cb6d2630a5e..816987ee5664d 100644 --- a/pkg/executor/test/loaddatatest/load_data_test.go +++ b/pkg/executor/test/loaddatatest/load_data_test.go @@ -482,9 +482,7 @@ func TestFix56408(t *testing.T) { ctx := tk.Session().(sessionctx.Context) tests := []testCase{ {[]byte("1|aa|beijing\n1|aa|beijing\n1|aa|beijing\n1|aa|beijing\n2|bb|shanghai\n2|bb|shanghai\n2|bb|shanghai\n3|cc|guangzhou\n"), - //[]string{"1 aa beijing", "1 aa beijing", "1 aa beijing", "1 aa beijing", "2 bb shanghai", "2 bb shanghai", "2 bb shanghai", "3 cc guangzhou"}, []string{"1 aa beijing", "2 bb shanghai", "3 cc guangzhou"}, - //"Records: 8 Deleted: 0 Skipped: 0 Warnings: 0"}, "Records: 8 Deleted: 0 Skipped: 5 Warnings: 0"}, } deleteSQL := "DO 1" From 539bd2c0942c0c5a0d87b14746916db0747860f3 Mon Sep 17 00:00:00 2001 From: fzzf678 <108643977+fzzf678@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:25:13 +0800 Subject: [PATCH 6/6] Update load_data_test.go --- pkg/executor/test/loaddatatest/load_data_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/executor/test/loaddatatest/load_data_test.go b/pkg/executor/test/loaddatatest/load_data_test.go index 816987ee5664d..ce577d5e1e24d 100644 --- a/pkg/executor/test/loaddatatest/load_data_test.go +++ b/pkg/executor/test/loaddatatest/load_data_test.go @@ -483,7 +483,8 @@ func TestFix56408(t *testing.T) { tests := []testCase{ {[]byte("1|aa|beijing\n1|aa|beijing\n1|aa|beijing\n1|aa|beijing\n2|bb|shanghai\n2|bb|shanghai\n2|bb|shanghai\n3|cc|guangzhou\n"), []string{"1 aa beijing", "2 bb shanghai", "3 cc guangzhou"}, - "Records: 8 Deleted: 0 Skipped: 5 Warnings: 0"}, + "Records: 8 Deleted: 0 Skipped: 5 Warnings: 0", + }, } deleteSQL := "DO 1" selectSQL := "TABLE a;"