From ce5522b4b78b858ef85170a9979ed3c7685d4736 Mon Sep 17 00:00:00 2001 From: djshow832 <873581766@qq.com> Date: Thu, 23 Jun 2022 10:18:41 +0800 Subject: [PATCH] fix testcase --- infoschema/infoschema.go | 5 +++++ table/temptable/ddl_test.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/infoschema/infoschema.go b/infoschema/infoschema.go index c96fa6d59dc83..3200166d21af0 100644 --- a/infoschema/infoschema.go +++ b/infoschema/infoschema.go @@ -487,6 +487,11 @@ func (is *LocalTemporaryTables) RemoveTable(schema, table model.CIStr) (exist bo return true } +// Count gets the count of the temporary tables. +func (is *LocalTemporaryTables) Count() int { + return len(is.idx2table) +} + // SchemaByTable get a table's schema name func (is *LocalTemporaryTables) SchemaByTable(tableInfo *model.TableInfo) (*model.DBInfo, bool) { if tableInfo == nil { diff --git a/table/temptable/ddl_test.go b/table/temptable/ddl_test.go index 1418a35ad83d1..e08343c1177a6 100644 --- a/table/temptable/ddl_test.go +++ b/table/temptable/ddl_test.go @@ -164,7 +164,7 @@ func TestTruncateLocalTemporaryTable(t *testing.T) { // truncate when empty err := ddl.TruncateLocalTemporaryTable(model.NewCIStr("db1"), model.NewCIStr("t1")) require.True(t, infoschema.ErrTableNotExists.Equal(err)) - require.Nil(t, sessVars.LocalTemporaryTables) + require.Equal(t, 0, sessVars.LocalTemporaryTables.(*infoschema.LocalTemporaryTables).Count()) require.Nil(t, sessVars.TemporaryTableData) // add one table