Skip to content

Commit

Permalink
*: fix empty SQL in slow log for internal statement (#54274)
Browse files Browse the repository at this point in the history
close #52743, close #53264, close #54190
  • Loading branch information
lcwangchao authored Jun 28, 2024
1 parent 31c1de0 commit 0106f4c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,7 @@ func NewSessionVars(hctx HookContext) *SessionVars {
ResourceGroupName: resourcegroup.DefaultResourceGroupName,
DefaultCollationForUTF8MB4: mysql.DefaultCollationName,
GroupConcatMaxLen: DefGroupConcatMaxLen,
EnableRedactLog: DefTiDBRedactLog,
}
vars.status.Store(uint32(mysql.ServerStatusAutocommit))
vars.StmtCtx.ResourceGroupName = resourcegroup.DefaultResourceGroupName
Expand Down
5 changes: 4 additions & 1 deletion pkg/util/redact/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ go_library(
srcs = ["redact.go"],
importpath = "github.com/pingcap/tidb/pkg/util/redact",
visibility = ["//visibility:public"],
deps = ["@com_github_pingcap_errors//:errors"],
deps = [
"//pkg/util/intest",
"@com_github_pingcap_errors//:errors",
],
)

go_test(
Expand Down
5 changes: 5 additions & 0 deletions pkg/util/redact/redact.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/pkg/util/intest"
)

var (
Expand All @@ -50,7 +51,11 @@ func String(mode string, input string) string {
return b.String()
case "OFF":
return input
case "ON":
return ""
default:
// should never happen
intest.Assert(false, "invalid redact mode")
return ""
}
}
Expand Down

0 comments on commit 0106f4c

Please sign in to comment.