Skip to content

Commit

Permalink
expression: fix data race in the collationInfo (#30490)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Dec 8, 2021
1 parent daf8f3e commit 2a1ea89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
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()
}

0 comments on commit 2a1ea89

Please sign in to comment.