From 236f6dcfef7daf583ea98265be1ab41a8c2ffd50 Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Mon, 26 Aug 2019 13:53:11 +0800 Subject: [PATCH] expression: don't use names when do patition pruning (#11858) --- expression/constraint_propagation.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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)