diff --git a/errno/errcode.go b/errno/errcode.go index 1446742b2edb7..038edc0fba2d1 100644 --- a/errno/errcode.go +++ b/errno/errcode.go @@ -1053,7 +1053,7 @@ const ( ErrPlacementPolicyNotExists = 8239 ErrPlacementPolicyWithDirectOption = 8240 ErrPlacementPolicyInUse = 8241 - + ErrOptOnCacheTable = 8242 // TiKV/PD/TiFlash errors. ErrPDServerTimeout = 9001 ErrTiKVServerTimeout = 9002 diff --git a/errno/errname.go b/errno/errname.go index 9e44ef59f7216..a75f77ac9c017 100644 --- a/errno/errname.go +++ b/errno/errname.go @@ -1060,7 +1060,7 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{ ErrPlacementPolicyNotExists: mysql.Message("Unknown placement policy '%-.192s'", nil), ErrPlacementPolicyWithDirectOption: mysql.Message("Placement policy '%s' can't co-exist with direct placement options", nil), ErrPlacementPolicyInUse: mysql.Message("Placement policy '%-.192s' is still in use", nil), - + ErrOptOnCacheTable: mysql.Message("'%s' is unsupported on cache tables.", nil), // TiKV/PD errors. ErrPDServerTimeout: mysql.Message("PD server timeout", nil), ErrTiKVServerTimeout: mysql.Message("TiKV server timeout", nil), diff --git a/errors.toml b/errors.toml index 2937e21de6e00..216b203537c33 100644 --- a/errors.toml +++ b/errors.toml @@ -1486,6 +1486,11 @@ error = ''' invalid as of timestamp: %s ''' +["planner:8242"] +error = ''' +'%s' is unsupported on cache tables. +''' + ["privilege:1141"] error = ''' There is no such grant defined for user '%-.48s' on host '%-.255s' diff --git a/executor/admin_test.go b/executor/admin_test.go index f52cb3335968b..8d2f9c89b6e85 100644 --- a/executor/admin_test.go +++ b/executor/admin_test.go @@ -127,7 +127,35 @@ func (s *testSuite5) TestAdminCheckIndexInLocalTemporaryMode(c *C) { c.Assert(err.Error(), Equals, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin checksum table").Error()) tk.MustExec("drop table if exists local_temporary_admin_checksum_table_with_index_test,local_temporary_admin_checksum_table_without_index_test;") } - +func (s *testSuite5) TestAdminCheckIndexInCacheTable(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists cache_admin_test;") + tk.MustExec("create table cache_admin_test (c1 int, c2 int, c3 int default 1, index (c1), unique key(c2))") + tk.MustExec("insert cache_admin_test (c1, c2) values (1, 1), (2, 2), (5, 5), (10, 10), (11, 11)") + tk.MustExec("alter table cache_admin_test cache") + tk.MustExec("admin check table cache_admin_test;") + tk.MustExec("admin check index cache_admin_test c1;") + tk.MustExec("admin check index cache_admin_test c2;") + tk.MustExec(`drop table if exists check_index_test;`) + tk.MustExec(`create table check_index_test (a int, b varchar(10), index a_b (a, b), index b (b))`) + tk.MustExec(`insert check_index_test values (3, "ab"),(2, "cd"),(1, "ef"),(-1, "hi")`) + tk.MustExec("alter table check_index_test cache") + result := tk.MustQuery("admin check index check_index_test a_b (2, 4);") + result.Check(testkit.Rows("1 ef 3", "2 cd 2")) + result = tk.MustQuery("admin check index check_index_test a_b (3, 5);") + result.Check(testkit.Rows("-1 hi 4", "1 ef 3")) + tk.MustExec("drop table if exists cache_admin_test;") + tk.MustExec("drop table if exists cache_admin_table_with_index_test;") + tk.MustExec("drop table if exists cache_admin_table_without_index_test;") + tk.MustExec("create table cache_admin_table_with_index_test (id int, count int, PRIMARY KEY(id), KEY(count))") + tk.MustExec("create table cache_admin_table_without_index_test (id int, count int, PRIMARY KEY(id))") + tk.MustExec("alter table cache_admin_table_with_index_test cache") + tk.MustExec("alter table cache_admin_table_without_index_test cache") + tk.MustExec("admin checksum table cache_admin_table_with_index_test;") + tk.MustExec("admin checksum table cache_admin_table_without_index_test;") + tk.MustExec("drop table if exists cache_admin_table_with_index_test,cache_admin_table_without_index_test;") +} func (s *testSuite5) TestAdminRecoverIndex(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") diff --git a/planner/core/errors.go b/planner/core/errors.go index 3b9668289dc12..830f3dfb9e367 100644 --- a/planner/core/errors.go +++ b/planner/core/errors.go @@ -101,6 +101,7 @@ var ( ErrNotSupportedWithSem = dbterror.ClassOptimizer.NewStd(mysql.ErrNotSupportedWithSem) ErrAsOf = dbterror.ClassOptimizer.NewStd(mysql.ErrAsOf) ErrOptOnTemporaryTable = dbterror.ClassOptimizer.NewStd(mysql.ErrOptOnTemporaryTable) + ErrOptOnCacheTable = dbterror.ClassOptimizer.NewStd(mysql.ErrOptOnCacheTable) ErrDropTableOnTemporaryTable = dbterror.ClassOptimizer.NewStd(mysql.ErrDropTableOnTemporaryTable) // ErrPartitionNoTemporary returns when partition at temporary mode ErrPartitionNoTemporary = dbterror.ClassOptimizer.NewStd(mysql.ErrPartitionNoTemporary)