Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: fix data race in the collationInfo #30490

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions expression/builtin_string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func TestLeft(t *testing.T) {
}
}

_, err := funcs[ast.Left].getFunction(ctx, []Expression{varcharCon, int8Con})
_, err := funcs[ast.Left].getFunction(ctx, []Expression{getVarcharCon(), getInt8Con()})
require.NoError(t, err)
}

Expand Down Expand Up @@ -490,7 +490,7 @@ func TestRight(t *testing.T) {
}
}

_, err := funcs[ast.Right].getFunction(ctx, []Expression{varcharCon, int8Con})
_, err := funcs[ast.Right].getFunction(ctx, []Expression{getVarcharCon(), getInt8Con()})
require.NoError(t, err)
}

Expand Down Expand Up @@ -629,7 +629,7 @@ func TestLower(t *testing.T) {
}
}

_, err := funcs[ast.Lower].getFunction(ctx, []Expression{varcharCon})
_, err := funcs[ast.Lower].getFunction(ctx, []Expression{getVarcharCon()})
require.NoError(t, err)

// Test GBK String
Expand Down Expand Up @@ -688,7 +688,7 @@ func TestUpper(t *testing.T) {
}
}

_, err := funcs[ast.Upper].getFunction(ctx, []Expression{varcharCon})
_, err := funcs[ast.Upper].getFunction(ctx, []Expression{getVarcharCon()})
require.NoError(t, err)

// Test GBK String
Expand Down Expand Up @@ -1338,10 +1338,10 @@ func TestHexFunc(t *testing.T) {
}
}

_, err := funcs[ast.Hex].getFunction(ctx, []Expression{int8Con})
_, err := funcs[ast.Hex].getFunction(ctx, []Expression{getInt8Con()})
require.NoError(t, err)

_, err = funcs[ast.Hex].getFunction(ctx, []Expression{varcharCon})
_, err = funcs[ast.Hex].getFunction(ctx, []Expression{getVarcharCon()})
require.NoError(t, err)
}

Expand Down
8 changes: 8 additions & 0 deletions expression/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,11 @@ var (
// MySQL varchar.
varcharCon = &Constant{RetType: &types.FieldType{Tp: mysql.TypeVarchar, Charset: charset.CharsetUTF8, Collate: charset.CollationUTF8}}
)

func getInt8Con() Expression {
return int8Con.Clone()
}

func getVarcharCon() Expression {
return varcharCon.Clone()
}