diff --git a/expression/constraint_propagation.go b/expression/constraint_propagation.go index d81ad636c1..1140f6c2e6 100644 --- a/expression/constraint_propagation.go +++ b/expression/constraint_propagation.go @@ -256,17 +256,10 @@ func ruleColumnOPConst(ctx sessionctx.Context, i, j int, exprs *exprSet) { // Make sure col1 and col2 are the same column. // Can't use col1.Equal(ctx, col2) here, because they are not generated in one // expression and their UniqueID are not the same. - if col1.ColName.L != col2.ColName.L { - return - } - if col1.OrigColName.L != "" && - col2.OrigColName.L != "" && - col1.OrigColName.L != col2.OrigColName.L { - return - } - if col1.OrigTblName.L != "" && - col2.OrigTblName.L != "" && - col1.OrigColName.L != col2.OrigColName.L { + // NOTE: We can use this way to compare this two column since this method is only called for partition pruning, + // where all columns come from the same DataSource. + // If we want to use this method in more places. We need to first change the comparing way. + if col1.ID != col2.ID { return } v, isNull, err := compareConstant(ctx, negOP(OP2), fc1, con2)