From 25e6a68d1eb5618ecf997f7a587bbf9b12f0e161 Mon Sep 17 00:00:00 2001 From: qw4990 Date: Mon, 11 Sep 2023 16:18:39 +0800 Subject: [PATCH] fixup --- planner/core/plan_cacheable_checker.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/planner/core/plan_cacheable_checker.go b/planner/core/plan_cacheable_checker.go index ae7ce3fac28b7..d11cfe459bd8f 100644 --- a/planner/core/plan_cacheable_checker.go +++ b/planner/core/plan_cacheable_checker.go @@ -19,6 +19,7 @@ import ( "errors" "fmt" "math" + "strings" "sync" "github.com/pingcap/tidb/expression" @@ -623,7 +624,12 @@ func getMaxParamLimit(sctx sessionctx.Context) int { // checkTableCacheable checks whether a query accessing this table is cacheable. func checkTableCacheable(ctx context.Context, sctx sessionctx.Context, schema infoschema.InfoSchema, node *ast.TableName, isNonPrep bool) (cacheable bool, reason string) { - tb, err := schema.TableByName(node.Schema, node.Name) + tableSchema := node.Schema + if tableSchema.L == "" { + tableSchema.O = sctx.GetSessionVars().CurrentDB + tableSchema.L = strings.ToLower(tableSchema.O) + } + tb, err := schema.TableByName(tableSchema, node.Name) if intest.InTest && ctx != nil && ctx.Value(PlanCacheKeyTestIssue46760) != nil { err = errors.New("mock error") }