From 37667b3d6291fdbf2a3e7e7f43877f558da8595e Mon Sep 17 00:00:00 2001 From: zyguan Date: Tue, 7 May 2024 21:52:09 +0800 Subject: [PATCH 1/2] This is an automated cherry-pick of #53034 Signed-off-by: ti-chi-bot --- pkg/table/tables/BUILD.bazel | 120 +++++++++++++++++++++ table/tables/index_test.go | 70 ++++++++++++ tablecodec/tablecodec.go | 4 + tests/integrationtest/r/table/index.result | 84 +++++++++++++++ tests/integrationtest/t/table/index.test | 53 +++++++++ 5 files changed, 331 insertions(+) create mode 100644 pkg/table/tables/BUILD.bazel create mode 100644 tests/integrationtest/r/table/index.result create mode 100644 tests/integrationtest/t/table/index.test diff --git a/pkg/table/tables/BUILD.bazel b/pkg/table/tables/BUILD.bazel new file mode 100644 index 0000000000000..df8ec012c2250 --- /dev/null +++ b/pkg/table/tables/BUILD.bazel @@ -0,0 +1,120 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "tables", + srcs = [ + "cache.go", + "index.go", + "mutation_checker.go", + "partition.go", + "state_remote.go", + "tables.go", + "testutil.go", + ], + importpath = "github.com/pingcap/tidb/pkg/table/tables", + visibility = ["//visibility:public"], + deps = [ + "//pkg/errctx", + "//pkg/errno", + "//pkg/expression", + "//pkg/kv", + "//pkg/meta", + "//pkg/meta/autoid", + "//pkg/metrics", + "//pkg/parser", + "//pkg/parser/ast", + "//pkg/parser/model", + "//pkg/parser/mysql", + "//pkg/parser/terror", + "//pkg/sessionctx", + "//pkg/sessionctx/binloginfo", + "//pkg/sessionctx/stmtctx", + "//pkg/sessionctx/variable", + "//pkg/statistics", + "//pkg/table", + "//pkg/tablecodec", + "//pkg/types", + "//pkg/util", + "//pkg/util/chunk", + "//pkg/util/codec", + "//pkg/util/collate", + "//pkg/util/dbterror", + "//pkg/util/generatedexpr", + "//pkg/util/hack", + "//pkg/util/logutil", + "//pkg/util/mock", + "//pkg/util/ranger", + "//pkg/util/rowcodec", + "//pkg/util/sqlexec", + "//pkg/util/stringutil", + "//pkg/util/tableutil", + "//pkg/util/tracing", + "@com_github_google_btree//:btree", + "@com_github_pingcap_errors//:errors", + "@com_github_pingcap_failpoint//:failpoint", + "@com_github_pingcap_log//:log", + "@com_github_pingcap_tipb//go-binlog", + "@com_github_pingcap_tipb//go-tipb", + "@com_github_tikv_client_go_v2//oracle", + "@com_github_tikv_client_go_v2//tikv", + "@org_uber_go_zap//:zap", + ], +) + +go_test( + name = "tables_test", + timeout = "short", + srcs = [ + "cache_test.go", + "index_test.go", + "main_test.go", + "mutation_checker_test.go", + "state_remote_test.go", + "tables_test.go", + ], + embed = [":tables"], + flaky = True, + shard_count = 32, + deps = [ + "//pkg/ddl", + "//pkg/ddl/util/callback", + "//pkg/domain", + "//pkg/infoschema", + "//pkg/kv", + "//pkg/lightning/backend/encode", + "//pkg/lightning/backend/kv", + "//pkg/meta/autoid", + "//pkg/metrics", + "//pkg/parser", + "//pkg/parser/ast", + "//pkg/parser/auth", + "//pkg/parser/model", + "//pkg/parser/mysql", + "//pkg/session", + "//pkg/session/types", + "//pkg/sessionctx", + "//pkg/sessionctx/stmtctx", + "//pkg/sessionctx/variable", + "//pkg/sessiontxn", + "//pkg/store/helper", + "//pkg/table", + "//pkg/tablecodec", + "//pkg/testkit", + "//pkg/testkit/external", + "//pkg/testkit/testsetup", + "//pkg/types", + "//pkg/util", + "//pkg/util/codec", + "//pkg/util/collate", + "//pkg/util/mock", + "//pkg/util/rowcodec", + "//pkg/util/stmtsummary", + "@com_github_pingcap_errors//:errors", + "@com_github_pingcap_failpoint//:failpoint", + "@com_github_prometheus_client_model//go", + "@com_github_stretchr_testify//assert", + "@com_github_stretchr_testify//require", + "@com_github_tikv_client_go_v2//oracle", + "@org_uber_go_goleak//:goleak", + ], +) diff --git a/table/tables/index_test.go b/table/tables/index_test.go index efcae3b337c3c..cc96a8aafc8b8 100644 --- a/table/tables/index_test.go +++ b/table/tables/index_test.go @@ -16,6 +16,7 @@ package tables_test import ( "context" + "strings" "testing" "github.com/pingcap/tidb/ddl" @@ -199,3 +200,72 @@ func TestAssertionWithLazyCheck(t *testing.T) { // `CheckNotExist`. Anyway there should never be assertion failure. tk.MustGetErrCode("insert into t values (4, 3, 3)", errno.ErrDupEntry) } + +func TestGenIndexValueWithLargePaddingSize(t *testing.T) { + // ref https://github.com/pingcap/tidb/issues/47115 + tblInfo := buildTableInfo(t, "create table t (a int, b int, k varchar(255), primary key (a, b), key (k))") + var idx table.Index + for _, idxInfo := range tblInfo.Indices { + if !idxInfo.Primary { + idx = tables.NewIndex(tblInfo.ID, tblInfo, idxInfo) + break + } + } + var a, b *model.ColumnInfo + for _, col := range tblInfo.Columns { + if col.Name.String() == "a" { + a = col + } else if col.Name.String() == "b" { + b = col + } + } + require.NotNil(t, a) + require.NotNil(t, b) + + store := testkit.CreateMockStore(t) + txn, err := store.Begin() + require.NoError(t, err) + mockCtx := mock.NewContext() + sc := mockCtx.GetSessionVars().StmtCtx + padding := strings.Repeat(" ", 128) + idxColVals := types.MakeDatums("abc" + padding) + handleColVals := types.MakeDatums(1, 2) + encodedHandle, err := codec.EncodeKey(sc.TimeZone(), nil, handleColVals...) + require.NoError(t, err) + commonHandle, err := kv.NewCommonHandle(encodedHandle) + require.NoError(t, err) + + key, _, err := idx.GenIndexKey(sc.ErrCtx(), sc.TimeZone(), idxColVals, commonHandle, nil) + require.NoError(t, err) + _, err = idx.Create(mockCtx.GetTableCtx(), txn, idxColVals, commonHandle, nil) + require.NoError(t, err) + val, err := txn.Get(context.Background(), key) + require.NoError(t, err) + colInfo := tables.BuildRowcodecColInfoForIndexColumns(idx.Meta(), tblInfo) + colInfo = append(colInfo, rowcodec.ColInfo{ + ID: a.ID, + IsPKHandle: false, + Ft: rowcodec.FieldTypeFromModelColumn(a), + }) + colInfo = append(colInfo, rowcodec.ColInfo{ + ID: b.ID, + IsPKHandle: false, + Ft: rowcodec.FieldTypeFromModelColumn(b), + }) + colVals, err := tablecodec.DecodeIndexKV(key, val, 1, tablecodec.HandleDefault, colInfo) + require.NoError(t, err) + require.Len(t, colVals, 3) + _, d, err := codec.DecodeOne(colVals[0]) + require.NoError(t, err) + require.Equal(t, "abc"+padding, d.GetString()) + _, d, err = codec.DecodeOne(colVals[1]) + require.NoError(t, err) + require.Equal(t, int64(1), d.GetInt64()) + _, d, err = codec.DecodeOne(colVals[2]) + require.NoError(t, err) + require.Equal(t, int64(2), d.GetInt64()) + handle, err := tablecodec.DecodeIndexHandle(key, val, 1) + require.NoError(t, err) + require.False(t, handle.IsInt()) + require.Equal(t, commonHandle.Encoded(), handle.Encoded()) +} diff --git a/tablecodec/tablecodec.go b/tablecodec/tablecodec.go index 8766b188d9164..859115ff880fd 100644 --- a/tablecodec/tablecodec.go +++ b/tablecodec/tablecodec.go @@ -843,7 +843,11 @@ func buildRestoredColumn(allCols []rowcodec.ColInfo) []rowcodec.ColInfo { } if collate.IsBinCollation(col.Ft.GetCollate()) { // Change the fieldType from string to uint since we store the number of the truncated spaces. + // NOTE: the corresponding datum is generated as `types.NewUintDatum(paddingSize)`, and the raw data is + // encoded via `encodeUint`. Thus we should mark the field type as unsigened here so that the BytesDecoder + // can decode it correctly later. Otherwise there might be issues like #47115. copyColInfo.Ft = types.NewFieldType(mysql.TypeLonglong) + copyColInfo.Ft.AddFlag(mysql.UnsignedFlag) } else { copyColInfo.Ft = allCols[i].Ft } diff --git a/tests/integrationtest/r/table/index.result b/tests/integrationtest/r/table/index.result new file mode 100644 index 0000000000000..6c07b5e2cc68c --- /dev/null +++ b/tests/integrationtest/r/table/index.result @@ -0,0 +1,84 @@ +set @@tidb_enable_mutation_checker=1; +drop table if exists t; +create table t(c year, PRIMARY KEY (c) CLUSTERED, KEY i1(c)); +insert into t values('2020'); +set @@tidb_enable_mutation_checker=default; +set @@tidb_txn_assertion_level = 'STRICT'; +drop table if exists t; +create table t (id int primary key, v1 int, v2 int, index (v1), unique index (v2)); +set @@tidb_constraint_check_in_place = true; +insert into t values (1, 1, 1); +insert into t values (2, 1, 1); +Error 1062 (23000): Duplicate entry '1' for key 't.v2' +set @@tidb_constraint_check_in_place = false; +insert into t values (3, 3, 3); +insert into t values (4, 3, 3); +Error 1062 (23000): Duplicate entry '3' for key 't.v2' +set @@tidb_txn_assertion_level=default; +set @@tidb_constraint_check_in_place=default; +drop table if exists t; +create table t(a varchar(20), b varchar(20), unique index idx_a(a(1))); +insert into t values ('qaa', 'abc'); +insert into t values ('qbb', 'xyz'); +Error 1062 (23000): Duplicate entry 'q' for key 't.idx_a' +insert into t values ('rcc', 'xyz'); +select * from t order by a; +a b +qaa abc +rcc xyz +update t set a = 'qcc' where a = 'rcc'; +Error 1062 (23000): Duplicate entry 'q' for key 't.idx_a' +update ignore t set a = 'qcc' where a = 'rcc'; +Level Code Message +Warning 1062 Duplicate entry 'q' for key 't.idx_a' +drop table if exists t; +create table t (id int, a varchar(64), b varchar(64), c varchar(64), index idx_a(a(64))); +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `id` int(11) DEFAULT NULL, + `a` varchar(64) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL, + `c` varchar(64) DEFAULT NULL, + KEY `idx_a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin +alter table t add index idx_b(b(64)); +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `id` int(11) DEFAULT NULL, + `a` varchar(64) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL, + `c` varchar(64) DEFAULT NULL, + KEY `idx_a` (`a`), + KEY `idx_b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin +alter table t add index idx_c(c(32)); +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `id` int(11) DEFAULT NULL, + `a` varchar(64) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL, + `c` varchar(64) DEFAULT NULL, + KEY `idx_a` (`a`), + KEY `idx_b` (`b`), + KEY `idx_c` (`c`(32)) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin +alter table t modify column c varchar(32); +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `id` int(11) DEFAULT NULL, + `a` varchar(64) DEFAULT NULL, + `b` varchar(64) DEFAULT NULL, + `c` varchar(32) DEFAULT NULL, + KEY `idx_a` (`a`), + KEY `idx_b` (`b`), + KEY `idx_c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin +drop table t; +drop table if exists t; +create table t (a int, b int, k varchar(255), primary key (a, b), key k (k)); +insert into t values (1, 1, 'abc '); +drop table t; diff --git a/tests/integrationtest/t/table/index.test b/tests/integrationtest/t/table/index.test new file mode 100644 index 0000000000000..e06bbf66b0bc7 --- /dev/null +++ b/tests/integrationtest/t/table/index.test @@ -0,0 +1,53 @@ +# TestIssue29520 +set @@tidb_enable_mutation_checker=1; +drop table if exists t; +create table t(c year, PRIMARY KEY (c) CLUSTERED, KEY i1(c)); +insert into t values('2020'); +set @@tidb_enable_mutation_checker=default; + +# TestAssertionWithLazyCheck +set @@tidb_txn_assertion_level = 'STRICT'; +drop table if exists t; +create table t (id int primary key, v1 int, v2 int, index (v1), unique index (v2)); +set @@tidb_constraint_check_in_place = true; +insert into t values (1, 1, 1); +-- error 1062 +insert into t values (2, 1, 1); +set @@tidb_constraint_check_in_place = false; +insert into t values (3, 3, 3); +-- error 1062 +insert into t values (4, 3, 3); +set @@tidb_txn_assertion_level=default; +set @@tidb_constraint_check_in_place=default; + +# TestDuplicateErrorOnPrefixIndex, Issue: #44316. +drop table if exists t; +create table t(a varchar(20), b varchar(20), unique index idx_a(a(1))); +insert into t values ('qaa', 'abc'); +-- error 1062 +insert into t values ('qbb', 'xyz'); +insert into t values ('rcc', 'xyz'); +select * from t order by a; +-- error 1062 +update t set a = 'qcc' where a = 'rcc'; +--enable_warnings; +update ignore t set a = 'qcc' where a = 'rcc'; +--disable_warnings; + +# Test Issue 48295. +drop table if exists t; +create table t (id int, a varchar(64), b varchar(64), c varchar(64), index idx_a(a(64))); +show create table t; +alter table t add index idx_b(b(64)); +show create table t; +alter table t add index idx_c(c(32)); +show create table t; +alter table t modify column c varchar(32); +show create table t; +drop table t; + +# Test Issue 47115. +drop table if exists t; +create table t (a int, b int, k varchar(255), primary key (a, b), key k (k)); +insert into t values (1, 1, 'abc '); +drop table t; From ae074a03d20379acf420fa0b0ffa5f5b45285d02 Mon Sep 17 00:00:00 2001 From: zyguan Date: Fri, 10 May 2024 09:57:58 +0000 Subject: [PATCH 2/2] resolve conflicts Signed-off-by: zyguan --- pkg/table/tables/BUILD.bazel | 120 --------------------- table/tables/index_test.go | 6 +- tests/integrationtest/r/table/index.result | 84 --------------- tests/integrationtest/t/table/index.test | 53 --------- 4 files changed, 3 insertions(+), 260 deletions(-) delete mode 100644 pkg/table/tables/BUILD.bazel delete mode 100644 tests/integrationtest/r/table/index.result delete mode 100644 tests/integrationtest/t/table/index.test diff --git a/pkg/table/tables/BUILD.bazel b/pkg/table/tables/BUILD.bazel deleted file mode 100644 index df8ec012c2250..0000000000000 --- a/pkg/table/tables/BUILD.bazel +++ /dev/null @@ -1,120 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "tables", - srcs = [ - "cache.go", - "index.go", - "mutation_checker.go", - "partition.go", - "state_remote.go", - "tables.go", - "testutil.go", - ], - importpath = "github.com/pingcap/tidb/pkg/table/tables", - visibility = ["//visibility:public"], - deps = [ - "//pkg/errctx", - "//pkg/errno", - "//pkg/expression", - "//pkg/kv", - "//pkg/meta", - "//pkg/meta/autoid", - "//pkg/metrics", - "//pkg/parser", - "//pkg/parser/ast", - "//pkg/parser/model", - "//pkg/parser/mysql", - "//pkg/parser/terror", - "//pkg/sessionctx", - "//pkg/sessionctx/binloginfo", - "//pkg/sessionctx/stmtctx", - "//pkg/sessionctx/variable", - "//pkg/statistics", - "//pkg/table", - "//pkg/tablecodec", - "//pkg/types", - "//pkg/util", - "//pkg/util/chunk", - "//pkg/util/codec", - "//pkg/util/collate", - "//pkg/util/dbterror", - "//pkg/util/generatedexpr", - "//pkg/util/hack", - "//pkg/util/logutil", - "//pkg/util/mock", - "//pkg/util/ranger", - "//pkg/util/rowcodec", - "//pkg/util/sqlexec", - "//pkg/util/stringutil", - "//pkg/util/tableutil", - "//pkg/util/tracing", - "@com_github_google_btree//:btree", - "@com_github_pingcap_errors//:errors", - "@com_github_pingcap_failpoint//:failpoint", - "@com_github_pingcap_log//:log", - "@com_github_pingcap_tipb//go-binlog", - "@com_github_pingcap_tipb//go-tipb", - "@com_github_tikv_client_go_v2//oracle", - "@com_github_tikv_client_go_v2//tikv", - "@org_uber_go_zap//:zap", - ], -) - -go_test( - name = "tables_test", - timeout = "short", - srcs = [ - "cache_test.go", - "index_test.go", - "main_test.go", - "mutation_checker_test.go", - "state_remote_test.go", - "tables_test.go", - ], - embed = [":tables"], - flaky = True, - shard_count = 32, - deps = [ - "//pkg/ddl", - "//pkg/ddl/util/callback", - "//pkg/domain", - "//pkg/infoschema", - "//pkg/kv", - "//pkg/lightning/backend/encode", - "//pkg/lightning/backend/kv", - "//pkg/meta/autoid", - "//pkg/metrics", - "//pkg/parser", - "//pkg/parser/ast", - "//pkg/parser/auth", - "//pkg/parser/model", - "//pkg/parser/mysql", - "//pkg/session", - "//pkg/session/types", - "//pkg/sessionctx", - "//pkg/sessionctx/stmtctx", - "//pkg/sessionctx/variable", - "//pkg/sessiontxn", - "//pkg/store/helper", - "//pkg/table", - "//pkg/tablecodec", - "//pkg/testkit", - "//pkg/testkit/external", - "//pkg/testkit/testsetup", - "//pkg/types", - "//pkg/util", - "//pkg/util/codec", - "//pkg/util/collate", - "//pkg/util/mock", - "//pkg/util/rowcodec", - "//pkg/util/stmtsummary", - "@com_github_pingcap_errors//:errors", - "@com_github_pingcap_failpoint//:failpoint", - "@com_github_prometheus_client_model//go", - "@com_github_stretchr_testify//assert", - "@com_github_stretchr_testify//require", - "@com_github_tikv_client_go_v2//oracle", - "@org_uber_go_goleak//:goleak", - ], -) diff --git a/table/tables/index_test.go b/table/tables/index_test.go index cc96a8aafc8b8..2e1a028099235 100644 --- a/table/tables/index_test.go +++ b/table/tables/index_test.go @@ -230,14 +230,14 @@ func TestGenIndexValueWithLargePaddingSize(t *testing.T) { padding := strings.Repeat(" ", 128) idxColVals := types.MakeDatums("abc" + padding) handleColVals := types.MakeDatums(1, 2) - encodedHandle, err := codec.EncodeKey(sc.TimeZone(), nil, handleColVals...) + encodedHandle, err := codec.EncodeKey(sc, nil, handleColVals...) require.NoError(t, err) commonHandle, err := kv.NewCommonHandle(encodedHandle) require.NoError(t, err) - key, _, err := idx.GenIndexKey(sc.ErrCtx(), sc.TimeZone(), idxColVals, commonHandle, nil) + key, _, err := idx.GenIndexKey(sc, idxColVals, commonHandle, nil) require.NoError(t, err) - _, err = idx.Create(mockCtx.GetTableCtx(), txn, idxColVals, commonHandle, nil) + _, err = idx.Create(mockCtx, txn, idxColVals, commonHandle, nil) require.NoError(t, err) val, err := txn.Get(context.Background(), key) require.NoError(t, err) diff --git a/tests/integrationtest/r/table/index.result b/tests/integrationtest/r/table/index.result deleted file mode 100644 index 6c07b5e2cc68c..0000000000000 --- a/tests/integrationtest/r/table/index.result +++ /dev/null @@ -1,84 +0,0 @@ -set @@tidb_enable_mutation_checker=1; -drop table if exists t; -create table t(c year, PRIMARY KEY (c) CLUSTERED, KEY i1(c)); -insert into t values('2020'); -set @@tidb_enable_mutation_checker=default; -set @@tidb_txn_assertion_level = 'STRICT'; -drop table if exists t; -create table t (id int primary key, v1 int, v2 int, index (v1), unique index (v2)); -set @@tidb_constraint_check_in_place = true; -insert into t values (1, 1, 1); -insert into t values (2, 1, 1); -Error 1062 (23000): Duplicate entry '1' for key 't.v2' -set @@tidb_constraint_check_in_place = false; -insert into t values (3, 3, 3); -insert into t values (4, 3, 3); -Error 1062 (23000): Duplicate entry '3' for key 't.v2' -set @@tidb_txn_assertion_level=default; -set @@tidb_constraint_check_in_place=default; -drop table if exists t; -create table t(a varchar(20), b varchar(20), unique index idx_a(a(1))); -insert into t values ('qaa', 'abc'); -insert into t values ('qbb', 'xyz'); -Error 1062 (23000): Duplicate entry 'q' for key 't.idx_a' -insert into t values ('rcc', 'xyz'); -select * from t order by a; -a b -qaa abc -rcc xyz -update t set a = 'qcc' where a = 'rcc'; -Error 1062 (23000): Duplicate entry 'q' for key 't.idx_a' -update ignore t set a = 'qcc' where a = 'rcc'; -Level Code Message -Warning 1062 Duplicate entry 'q' for key 't.idx_a' -drop table if exists t; -create table t (id int, a varchar(64), b varchar(64), c varchar(64), index idx_a(a(64))); -show create table t; -Table Create Table -t CREATE TABLE `t` ( - `id` int(11) DEFAULT NULL, - `a` varchar(64) DEFAULT NULL, - `b` varchar(64) DEFAULT NULL, - `c` varchar(64) DEFAULT NULL, - KEY `idx_a` (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin -alter table t add index idx_b(b(64)); -show create table t; -Table Create Table -t CREATE TABLE `t` ( - `id` int(11) DEFAULT NULL, - `a` varchar(64) DEFAULT NULL, - `b` varchar(64) DEFAULT NULL, - `c` varchar(64) DEFAULT NULL, - KEY `idx_a` (`a`), - KEY `idx_b` (`b`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin -alter table t add index idx_c(c(32)); -show create table t; -Table Create Table -t CREATE TABLE `t` ( - `id` int(11) DEFAULT NULL, - `a` varchar(64) DEFAULT NULL, - `b` varchar(64) DEFAULT NULL, - `c` varchar(64) DEFAULT NULL, - KEY `idx_a` (`a`), - KEY `idx_b` (`b`), - KEY `idx_c` (`c`(32)) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin -alter table t modify column c varchar(32); -show create table t; -Table Create Table -t CREATE TABLE `t` ( - `id` int(11) DEFAULT NULL, - `a` varchar(64) DEFAULT NULL, - `b` varchar(64) DEFAULT NULL, - `c` varchar(32) DEFAULT NULL, - KEY `idx_a` (`a`), - KEY `idx_b` (`b`), - KEY `idx_c` (`c`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin -drop table t; -drop table if exists t; -create table t (a int, b int, k varchar(255), primary key (a, b), key k (k)); -insert into t values (1, 1, 'abc '); -drop table t; diff --git a/tests/integrationtest/t/table/index.test b/tests/integrationtest/t/table/index.test deleted file mode 100644 index e06bbf66b0bc7..0000000000000 --- a/tests/integrationtest/t/table/index.test +++ /dev/null @@ -1,53 +0,0 @@ -# TestIssue29520 -set @@tidb_enable_mutation_checker=1; -drop table if exists t; -create table t(c year, PRIMARY KEY (c) CLUSTERED, KEY i1(c)); -insert into t values('2020'); -set @@tidb_enable_mutation_checker=default; - -# TestAssertionWithLazyCheck -set @@tidb_txn_assertion_level = 'STRICT'; -drop table if exists t; -create table t (id int primary key, v1 int, v2 int, index (v1), unique index (v2)); -set @@tidb_constraint_check_in_place = true; -insert into t values (1, 1, 1); --- error 1062 -insert into t values (2, 1, 1); -set @@tidb_constraint_check_in_place = false; -insert into t values (3, 3, 3); --- error 1062 -insert into t values (4, 3, 3); -set @@tidb_txn_assertion_level=default; -set @@tidb_constraint_check_in_place=default; - -# TestDuplicateErrorOnPrefixIndex, Issue: #44316. -drop table if exists t; -create table t(a varchar(20), b varchar(20), unique index idx_a(a(1))); -insert into t values ('qaa', 'abc'); --- error 1062 -insert into t values ('qbb', 'xyz'); -insert into t values ('rcc', 'xyz'); -select * from t order by a; --- error 1062 -update t set a = 'qcc' where a = 'rcc'; ---enable_warnings; -update ignore t set a = 'qcc' where a = 'rcc'; ---disable_warnings; - -# Test Issue 48295. -drop table if exists t; -create table t (id int, a varchar(64), b varchar(64), c varchar(64), index idx_a(a(64))); -show create table t; -alter table t add index idx_b(b(64)); -show create table t; -alter table t add index idx_c(c(32)); -show create table t; -alter table t modify column c varchar(32); -show create table t; -drop table t; - -# Test Issue 47115. -drop table if exists t; -create table t (a int, b int, k varchar(255), primary key (a, b), key k (k)); -insert into t values (1, 1, 'abc '); -drop table t;