expression: fix import and BaseVisitor
This commit is contained in:
@ -27,9 +27,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/juju/errors"
|
||||
"github.com/ngaut/log"
|
||||
"github.com/pingcap/tidb/context"
|
||||
|
||||
"github.com/pingcap/tidb/expression/builtin"
|
||||
"github.com/pingcap/tidb/model"
|
||||
mysql "github.com/pingcap/tidb/mysqldef"
|
||||
|
||||
@ -181,9 +181,11 @@ func (bv *BaseVisitor) VisitExistsSubQuery(es *ExistsSubQuery) (Expression, erro
|
||||
// VisitFunctionCase implements Visitor interface.
|
||||
func (bv *BaseVisitor) VisitFunctionCase(f *FunctionCase) (Expression, error) {
|
||||
var err error
|
||||
f.Value, err = f.Value.Accept(bv.V)
|
||||
if err != nil {
|
||||
return f, errors.Trace(err)
|
||||
if f.Value != nil {
|
||||
f.Value, err = f.Value.Accept(bv.V)
|
||||
if err != nil {
|
||||
return f, errors.Trace(err)
|
||||
}
|
||||
}
|
||||
for i := range f.WhenClauses {
|
||||
_, err = f.WhenClauses[i].Accept(bv.V)
|
||||
@ -191,9 +193,11 @@ func (bv *BaseVisitor) VisitFunctionCase(f *FunctionCase) (Expression, error) {
|
||||
return f, errors.Trace(err)
|
||||
}
|
||||
}
|
||||
f.ElseClause, err = f.ElseClause.Accept(bv.V)
|
||||
if err != nil {
|
||||
return f, errors.Trace(err)
|
||||
if f.ElseClause != nil {
|
||||
f.ElseClause, err = f.ElseClause.Accept(bv.V)
|
||||
if err != nil {
|
||||
return f, errors.Trace(err)
|
||||
}
|
||||
}
|
||||
return f, nil
|
||||
}
|
||||
@ -229,6 +233,9 @@ func (bv *BaseVisitor) VisitFunctionSubstring(ss *FunctionSubstring) (Expression
|
||||
if err != nil {
|
||||
return ss, errors.Trace(err)
|
||||
}
|
||||
if ss.Len == nil {
|
||||
return ss, nil
|
||||
}
|
||||
ss.Len, err = ss.Len.Accept(bv.V)
|
||||
if err != nil {
|
||||
return ss, errors.Trace(err)
|
||||
|
||||
@ -13,13 +13,6 @@
|
||||
|
||||
package expression
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/juju/errors"
|
||||
"github.com/pingcap/tidb/expression/builtin"
|
||||
)
|
||||
|
||||
// IdentEvalVisitor converts Ident expression to value expression.
|
||||
type IdentEvalVisitor struct {
|
||||
BaseVisitor
|
||||
|
||||
Reference in New Issue
Block a user