expression: fold const after rewrite between (#27834)
This commit is contained in:
@ -1654,6 +1654,8 @@ func (er *expressionRewriter) betweenToExpression(v *ast.BetweenExpr) {
|
||||
}
|
||||
l.SetCharsetAndCollation(dstCharset, dstCollation)
|
||||
r.SetCharsetAndCollation(dstCharset, dstCollation)
|
||||
l = expression.FoldConstant(l)
|
||||
r = expression.FoldConstant(r)
|
||||
function, err := er.newFunction(ast.LogicAnd, &v.Type, l, r)
|
||||
if err != nil {
|
||||
er.err = err
|
||||
|
||||
@ -461,6 +461,7 @@ func (s *testExpressionRewriterSuiteSerial) TestBetweenExprCollation(c *C) {
|
||||
tk.MustExec("insert into t1 values ('a', 'B');")
|
||||
tk.MustExec("insert into t1 values ('c', 'D');")
|
||||
tk.MustQuery("select * from t1 where a between 'B' and c;").Check(testkit.Rows("c D"))
|
||||
tk.MustQuery("explain select * from t1 where 'a' between 'g' and 'f';").Check(testkit.Rows("TableDual_6 0.00 root rows:0"))
|
||||
|
||||
tk.MustGetErrMsg("select * from t1 where a between 'B' collate utf8mb4_general_ci and c collate utf8mb4_unicode_ci;", "[expression:1270]Illegal mix of collations (latin1_bin,IMPLICIT), (utf8mb4_general_ci,EXPLICIT), (utf8mb4_unicode_ci,EXPLICIT) for operation 'between'")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user