diff options
Diffstat (limited to 'core/vm/sqlvm/ast')
-rw-r--r-- | core/vm/sqlvm/ast/ast.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/core/vm/sqlvm/ast/ast.go b/core/vm/sqlvm/ast/ast.go index 3a1d12c19..9a5afb202 100644 --- a/core/vm/sqlvm/ast/ast.go +++ b/core/vm/sqlvm/ast/ast.go @@ -756,6 +756,7 @@ func (n *IsOperatorNode) GetType() DataType { type LikeOperatorNode struct { UntaggedExprNodeBase BinaryOperatorNode + Escape ExprNode } var _ BinaryOperator = (*LikeOperatorNode)(nil) @@ -765,6 +766,40 @@ func (n *LikeOperatorNode) GetType() DataType { return ComposeDataType(DataTypeMajorBool, DataTypeMinorDontCare) } +// GetChildren returns a list of child nodes used for traversing. +func (n *LikeOperatorNode) GetChildren() []Node { + size := 2 + if n.Escape != nil { + size++ + } + + idx := 0 + nodes := make([]Node, size) + nodes[idx] = n.Object + idx++ + nodes[idx] = n.Subject + idx++ + if n.Escape != nil { + nodes[idx] = n.Escape + idx++ + } + return nodes +} + +// IsConstant returns whether a node is a constant. +func (n *LikeOperatorNode) IsConstant() bool { + if !n.Object.IsConstant() { + return false + } + if !n.Subject.IsConstant() { + return false + } + if n.Escape != nil && !n.Escape.IsConstant() { + return false + } + return true +} + // --------------------------------------------------------------------------- // Cast // --------------------------------------------------------------------------- |