filter: no need to always convert dbname to lowercase in IsSystemSchema (#62657)

close pingcap/tidb#62658
This commit is contained in:
Weizhen Wang
2025-07-28 20:20:27 +08:00
committed by GitHub
parent 312226f869
commit 8c6dbedb30
4 changed files with 13 additions and 4 deletions

View File

@ -495,7 +495,7 @@ func (checker *nonPreparedPlanCacheableChecker) Enter(in ast.Node) (out ast.Node
}
return in, !checker.cacheable
case *ast.TableName:
if filter.IsSystemSchema(node.Schema.O) {
if filter.IsSystemSchema(node.Schema.L) {
checker.cacheable = false
checker.reason = "access tables in system schema"
return in, !checker.cacheable

View File

@ -10,6 +10,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/meta/metadef",
"//pkg/util/intest",
"//pkg/util/table-filter",
"//pkg/util/table-rule-selector",
"@com_github_pingcap_errors//:errors",
@ -25,5 +26,8 @@ go_test(
],
embed = [":filter"],
flaky = True,
deps = ["@com_github_stretchr_testify//require"],
deps = [
"//pkg/parser/ast",
"@com_github_stretchr_testify//require",
],
)

View File

@ -18,6 +18,7 @@ import (
"strings"
"github.com/pingcap/tidb/pkg/meta/metadef"
"github.com/pingcap/tidb/pkg/util/intest"
)
var (
@ -30,7 +31,9 @@ var (
// IsSystemSchema checks whether schema is system schema or not.
// case insensitive
func IsSystemSchema(schema string) bool {
schema = strings.ToLower(schema)
intest.AssertFunc(func() bool {
return schema == strings.ToLower(schema)
})
return schema == DMHeartbeatSchema || schema == InspectionSchemaName ||
metadef.IsMemOrSysDB(schema)
}

View File

@ -17,6 +17,7 @@ package filter
import (
"testing"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/stretchr/testify/require"
)
@ -39,6 +40,7 @@ func TestIsSystemSchema(t *testing.T) {
}
for _, tt := range cases {
require.Equalf(t, tt.expected, IsSystemSchema(tt.name), "schema name = %s", tt.name)
name := ast.NewCIStr(tt.name)
require.Equalf(t, tt.expected, IsSystemSchema(name.L), "schema name = %s", tt.name)
}
}