示例#1
0
func (b *executorBuilder) buildSelection(v *plan.Selection) Executor {
	child := v.GetChildByIndex(0)
	oldConditions := v.Conditions
	var src Executor
	switch x := child.(type) {
	case *plan.PhysicalTableScan:
		if x.LimitCount == nil {
			src = b.buildNewTableScan(x, v)
		} else {
			src = b.buildNewTableScan(x, nil)
		}
	case *plan.PhysicalIndexScan:
		if x.LimitCount == nil {
			src = b.buildNewIndexScan(x, v)
		} else {
			src = b.buildNewIndexScan(x, nil)
		}
	default:
		src = b.build(x)
	}

	if len(v.Conditions) == 0 {
		v.Conditions = oldConditions
		return src
	}

	exec := &SelectionExec{
		Src:       src,
		Condition: expression.ComposeCNFCondition(v.Conditions),
		schema:    v.GetSchema(),
		ctx:       b.ctx,
	}
	v.Conditions = oldConditions
	return exec
}