diff --git a/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go b/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go index 303c39e3afc..e4e4cb1664d 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go +++ b/go/vt/vttablet/tabletserver/vstreamer/planbuilder.go @@ -61,7 +61,7 @@ type Plan struct { // Predicates in the Filter query that we can push down to // MySQL to reduce the returned rows we need to filter. // This will contain any valid expressions in the Filter's - // WHERE clause with the exception of the in_keyspace() + // WHERE clause with the exception of the in_keyrange() // function which is a filter that must be applied by the // vstreamer (it's not a valid MySQL function). whereExprsToPushDown []sqlparser.Expr @@ -613,9 +613,13 @@ func (plan *Plan) analyzeWhere(vschema *localVSchema, where *sqlparser.Where) er // Add it to the expressions that get pushed down to mysqld. log.Errorf("DEBUG: adding to list of pushdown expressions: %v", sqlparser.String(expr)) plan.whereExprsToPushDown = append(plan.whereExprsToPushDown, expr) - // StrVal is varbinary, we do not support varchar since we would have to implement all collation types if val.Type != sqlparser.IntVal && val.Type != sqlparser.StrVal { - return fmt.Errorf("unexpected: %v", sqlparser.String(expr)) + // StrVal is varbinary, we do not support varchar filtering in + // vstreamer since we would have to do so using the correct + // collation. So we ONLY push it down to mysqld. + // TODO: now that we have MySQL compatible collation support + // we could add this support to vstreamer as well. + continue } pv, err := evalengine.Translate(val, &evalengine.Config{ Collation: plan.env.CollationEnv().DefaultConnectionCharset(), @@ -635,11 +639,14 @@ func (plan *Plan) analyzeWhere(vschema *localVSchema, where *sqlparser.Where) er Value: resolved.Value(plan.env.CollationEnv().DefaultConnectionCharset()), }) case *sqlparser.FuncExpr: - if !expr.Name.EqualString("in_keyrange") { - return fmt.Errorf("unsupported constraint: %v", sqlparser.String(expr)) - } - if err := plan.analyzeInKeyRange(vschema, expr.Exprs); err != nil { - return err + if expr.Name.EqualString("in_keyrange") { + if err := plan.analyzeInKeyRange(vschema, expr.Exprs); err != nil { + return err + } + } else { + log.Errorf("DEBUG: adding to list of pushdown expressions: %v", sqlparser.String(expr)) + // Add it to the expressions that get pushed down to mysqld. + plan.whereExprsToPushDown = append(plan.whereExprsToPushDown, expr) } case *sqlparser.IsExpr: // Needed for CreateLookupVindex with ignore_nulls if expr.Right != sqlparser.IsNotNullOp { @@ -660,6 +667,7 @@ func (plan *Plan) analyzeWhere(vschema *localVSchema, where *sqlparser.Where) er Opcode: IsNotNull, ColNum: colnum, }) + log.Errorf("DEBUG: adding to list of pushdown expressions: %v", sqlparser.String(expr)) // Add it to the expressions that get pushed down to mysqld. plan.whereExprsToPushDown = append(plan.whereExprsToPushDown, expr) default: