Skip to content

Commit

Permalink
*: fix empty SQL in slow log for internal statement (#54274) (#54309)
Browse files Browse the repository at this point in the history
close #52743, close #53264, close #54190
  • Loading branch information
ti-chi-bot authored Jul 30, 2024
1 parent 4e373cf commit b5de417
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 @@ -2045,6 +2045,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 b5de417

Please sign in to comment.