Skip to content

Commit

Permalink
Merge pull request #8254 from planetscale/gen4-more-opcodes
Browse files Browse the repository at this point in the history
gen4: plan more opcodes
  • Loading branch information
harshit-gangal authored Jun 3, 2021
2 parents 236ddc4 + 2c6c50a commit 2988268
Show file tree
Hide file tree
Showing 17 changed files with 246 additions and 80 deletions.
4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1794,8 +1794,8 @@ type (

// IsExpr represents an IS ... or an IS NOT ... expression.
IsExpr struct {
Operator IsExprOperator
Expr Expr
Left Expr
Right IsExprOperator
}

// IsExprOperator is an enum for IsExpr.Operator
Expand Down
2 changes: 1 addition & 1 deletion go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast_equals.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ func (node *RangeCond) Format(buf *TrackedBuffer) {

// Format formats the node.
func (node *IsExpr) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "%v %s", node.Expr, node.Operator.ToString())
buf.astPrintf(node, "%v %s", node.Left, node.Right.ToString())
}

// Format formats the node.
Expand Down
4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/vt/sqlparser/ast_visit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions go/vt/sqlparser/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/vt/sqlparser/precedence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func readable(node Expr) string {
case *BinaryExpr:
return fmt.Sprintf("(%s %s %s)", readable(node.Left), node.Operator.ToString(), readable(node.Right))
case *IsExpr:
return fmt.Sprintf("(%s %s)", readable(node.Expr), node.Operator.ToString())
return fmt.Sprintf("(%s %s)", readable(node.Left), node.Right.ToString())
default:
return String(node)
}
Expand Down
4 changes: 2 additions & 2 deletions go/vt/sqlparser/random_expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (g *generator) isExpr() Expr {
ops := []IsExprOperator{IsNullOp, IsNotNullOp, IsTrueOp, IsNotTrueOp, IsFalseOp, IsNotFalseOp}

return &IsExpr{
Operator: ops[g.r.Intn(len(ops))],
Expr: g.booleanExpr(),
Right: ops[g.r.Intn(len(ops))],
Left: g.booleanExpr(),
}
}
2 changes: 1 addition & 1 deletion go/vt/sqlparser/sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/vt/sqlparser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -3513,7 +3513,7 @@ expression:
}
| expression IS is_suffix
{
$$ = &IsExpr{Operator: $3, Expr: $1}
$$ = &IsExpr{Left: $1, Right: $3}
}
| value_expression
{
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/planbuilder/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,11 @@ func (rb *route) computeEqualPlan(pb *primitiveBuilder, comparison *sqlparser.Co
// computeIS computes the plan for an equality constraint.
func (rb *route) computeISPlan(pb *primitiveBuilder, comparison *sqlparser.IsExpr) (opcode engine.RouteOpcode, vindex vindexes.SingleColumn, expr sqlparser.Expr) {
// we only handle IS NULL correct. IsExpr can contain other expressions as well
if comparison.Operator != sqlparser.IsNullOp {
if comparison.Right != sqlparser.IsNullOp {
return engine.SelectScatter, nil, nil
}

vindex = pb.st.Vindex(comparison.Expr, rb)
vindex = pb.st.Vindex(comparison.Left, rb)
// fallback to scatter gather if there is no vindex
if vindex == nil {
return engine.SelectScatter, nil, nil
Expand Down
Loading

0 comments on commit 2988268

Please sign in to comment.