Skip to content

Commit

Permalink
*: update pingcap/errors version (#51854) (#53526)
Browse files Browse the repository at this point in the history
close #53517
  • Loading branch information
ti-chi-bot committed May 24, 2024
1 parent 86528c7 commit 3841026
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 24 deletions.
12 changes: 6 additions & 6 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5767,13 +5767,13 @@ def go_deps():
name = "com_github_pingcap_errors",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/errors",
sha256 = "4dadf9dc507b4187a70b78e49d572bc0e8f89a7b4a8974d6a978f72620526996",
strip_prefix = "github.com/pingcap/[email protected].20221009092201-b66cddb77c32",
sha256 = "99d36c5e5649442d9923d4b1cd7f1242faaf4071844c2e3c77497230b3f38cd7",
strip_prefix = "github.com/pingcap/[email protected].20240318064555-6bd07397691f",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/errors/com_github_pingcap_errors-v0.11.5-0.20221009092201-b66cddb77c32.zip",
"http://ats.apps.svc/gomod/github.com/pingcap/errors/com_github_pingcap_errors-v0.11.5-0.20221009092201-b66cddb77c32.zip",
"https://cache.hawkingrei.com/gomod/github.com/pingcap/errors/com_github_pingcap_errors-v0.11.5-0.20221009092201-b66cddb77c32.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/errors/com_github_pingcap_errors-v0.11.5-0.20221009092201-b66cddb77c32.zip",
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/errors/com_github_pingcap_errors-v0.11.5-0.20240318064555-6bd07397691f.zip",
"http://ats.apps.svc/gomod/github.com/pingcap/errors/com_github_pingcap_errors-v0.11.5-0.20240318064555-6bd07397691f.zip",
"https://cache.hawkingrei.com/gomod/github.com/pingcap/errors/com_github_pingcap_errors-v0.11.5-0.20240318064555-6bd07397691f.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/errors/com_github_pingcap_errors-v0.11.5-0.20240318064555-6bd07397691f.zip",
],
)
go_repository(
Expand Down
9 changes: 7 additions & 2 deletions br/pkg/redact/redact.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import (

// InitRedact inits the enableRedactLog
func InitRedact(redactLog bool) {
errors.RedactLogEnabled.Store(redactLog)
mode := errors.RedactLogDisable
if redactLog {
mode = errors.RedactLogEnable
}
errors.RedactLogEnabled.Store(mode)
}

// NeedRedact returns whether to redact log
func NeedRedact() bool {
return errors.RedactLogEnabled.Load()
mode := errors.RedactLogEnabled.Load()
return mode != errors.RedactLogDisable && mode != ""
}

// String receives string argument and return omitted information if redact log enabled
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pingcap/badger v1.5.1-0.20230103063557-828f39b09b6d
github.com/pingcap/errors v0.11.5-0.20221009092201-b66cddb77c32
github.com/pingcap/errors v0.11.5-0.20240318064555-6bd07397691f
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c
github.com/pingcap/fn v1.0.0
github.com/pingcap/kvproto v0.0.0-20240208102409-a554af8ee11f
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ github.com/pingcap/badger v1.5.1-0.20230103063557-828f39b09b6d/go.mod h1:p8QnkZn
github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pingcap/errors v0.11.5-0.20190809092503-95897b64e011/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pingcap/errors v0.11.5-0.20221009092201-b66cddb77c32 h1:m5ZsBa5o/0CkzZXfXLaThzKuR85SnHHetqBCpzQ30h8=
github.com/pingcap/errors v0.11.5-0.20221009092201-b66cddb77c32/go.mod h1:X2r9ueLEUZgtx2cIogM0v4Zj5uvvzhuuiu7Pn8HzMPg=
github.com/pingcap/errors v0.11.5-0.20240318064555-6bd07397691f h1:FxA+NgsdHNOv+/hZGxUh8Gb3WuZqgqmxDwztEOiA1v4=
github.com/pingcap/errors v0.11.5-0.20240318064555-6bd07397691f/go.mod h1:X2r9ueLEUZgtx2cIogM0v4Zj5uvvzhuuiu7Pn8HzMPg=
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c h1:CgbKAHto5CQgWM9fSBIvaxsJHuGP0uM74HXtv3MyyGQ=
github.com/pingcap/failpoint v0.0.0-20220801062533-2eaa32854a6c/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew=
github.com/pingcap/fn v1.0.0 h1:CyA6AxcOZkQh52wIqYlAmaVmF6EvrcqFywP463pjA8g=
Expand Down
2 changes: 1 addition & 1 deletion pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ func (s *session) tryReplaceWriteConflictError(oldErr error) (newErr error) {
if !kv.ErrWriteConflict.Equal(oldErr) {
return nil
}
if errors.RedactLogEnabled.Load() {
if errors.RedactLogEnabled.Load() == errors.RedactLogEnable {
return nil
}
originErr := errors.Cause(oldErr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,7 @@ var defaultSysVars = []*SysVar{
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBRedactLog, Value: BoolToOnOff(DefTiDBRedactLog), Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
s.EnableRedactLog = TiDBOptOn(val)
errors.RedactLogEnabled.Store(s.EnableRedactLog)
errors.RedactLogEnabled.Store(val)
return nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBShardAllocateStep, Value: strconv.Itoa(DefTiDBShardAllocateStep), Type: TypeInt, MinValue: 1, MaxValue: uint64(math.MaxInt64), SetSession: func(s *SessionVars, val string) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/driver/txn/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestWriteConflictPrettyFormat(t *testing.T) {

// test log redaction
original := errors.RedactLogEnabled.Load()
errors.RedactLogEnabled.Store(true)
errors.RedactLogEnabled.Store(errors.RedactLogEnable)
defer func() { errors.RedactLogEnabled.Store(original) }()
expectedStr = "[kv:9007]Write conflict, " +
"txnStartTS=399402937522847774, conflictStartTS=399402937719455772, conflictCommitTS=399402937719455773, " +
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/dbterror/terror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func genErrMsg(pattern string, a ...interface{}) string {

func TestErrorRedact(t *testing.T) {
original := errors.RedactLogEnabled.Load()
errors.RedactLogEnabled.Store(true)
errors.RedactLogEnabled.Store(errors.RedactLogEnable)
defer func() { errors.RedactLogEnabled.Store(original) }()

class := ErrClass{}
Expand Down
10 changes: 4 additions & 6 deletions pkg/util/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,10 @@ func SyntaxWarn(err error) error {
}
logutil.BgLogger().Debug("syntax error", zap.Error(err))

// If the warn is already a terror with stack, pass it through.
if errors.HasStack(err) {
cause := errors.Cause(err)
if _, ok := cause.(*terror.Error); ok {
return err
}
// If the "err" is already a terror, pass it through.
cause := errors.Cause(err)
if _, ok := cause.(*terror.Error); ok {
return err
}

return parser.ErrParse.GenWithStackByArgs(syntaxErrorPrefix, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion tests/integrationtest/r/expression/misc.result
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Warning 8061 Optimizer hint unknown_hint is not supported by TiDB and is ignored
select 1 from /*+ test1() */ t;
1
Level Code Message
Warning 1064 You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use [parser:8066]Optimizer hint can only be followed by certain keywords like SELECT, INSERT, etc.
Warning 8066 Optimizer hint can only be followed by certain keywords like SELECT, INSERT, etc.
drop table if exists t;
create table t(a bigint, b double, c decimal, d varchar(20), e datetime, f time, g json);
insert into t values(1, 1.1, 2.2, "abc", "2018-10-24", NOW(), "12");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ select count(*) /*+ stream_agg() */ from t where a > 1;
count(*) /*+ stream_agg()
0
Level Code Message
Warning 1064 You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use [parser:8066]Optimizer hint can only be followed by certain keywords like SELECT, INSERT, etc.
Warning 8066 Optimizer hint can only be followed by certain keywords like SELECT, INSERT, etc.
select count(*) from (select count(*) as a /*+ stream_agg() */ from t where b > 1 group by b) t1 where a > 1;
count(*)
0
Level Code Message
Warning 1064 You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use [parser:8066]Optimizer hint can only be followed by certain keywords like SELECT, INSERT, etc.
Warning 8066 Optimizer hint can only be followed by certain keywords like SELECT, INSERT, etc.
set tidb_cost_model_version=2;
drop table if exists t, t1, th;
drop view if exists v, v1;
Expand Down

0 comments on commit 3841026

Please sign in to comment.