예제 #1
0
파일: builder.go 프로젝트: jmptrader/tidb
func (b *executorBuilder) buildUnionScanExec(v *plan.PhysicalUnionScan) *UnionScanExec {
	src := b.build(v.GetChildByIndex(0))
	if b.err != nil {
		return nil
	}
	us := &UnionScanExec{ctx: b.ctx, Src: src}
	switch x := src.(type) {
	case *XSelectTableExec:
		us.desc = x.desc
		us.dirty = getDirtyDB(b.ctx).getDirtyTable(x.table.Meta().ID)
		us.condition = v.Condition
		us.buildAndSortAddedRows(x.table, x.asName)
	case *XSelectIndexExec:
		us.desc = x.indexPlan.Desc
		for _, ic := range x.indexPlan.Index.Columns {
			for i, col := range x.indexPlan.GetSchema() {
				if col.ColName.L == ic.Name.L {
					us.usedIndex = append(us.usedIndex, i)
					break
				}
			}
		}
		us.dirty = getDirtyDB(b.ctx).getDirtyTable(x.table.Meta().ID)
		us.condition = v.Condition
		us.buildAndSortAddedRows(x.table, x.asName)
	default:
		b.err = ErrUnknownPlan.Gen("Unknown Plan %T", src)
	}
	return us
}
예제 #2
0
파일: builder.go 프로젝트: pingcap/tidb
func (b *executorBuilder) buildUnionScanExec(v *plan.PhysicalUnionScan) Executor {
	src := b.build(v.GetChildByIndex(0))
	if b.err != nil {
		return nil
	}
	us := &UnionScanExec{ctx: b.ctx, Src: src, schema: v.GetSchema()}
	switch x := src.(type) {
	case *XSelectTableExec:
		us.desc = x.desc
		us.dirty = getDirtyDB(b.ctx).getDirtyTable(x.table.Meta().ID)
		us.condition = v.Condition
		us.buildAndSortAddedRows(x.table, x.asName)
	case *XSelectIndexExec:
		us.desc = x.indexPlan.Desc
		for _, ic := range x.indexPlan.Index.Columns {
			for i, col := range x.indexPlan.GetSchema() {
				if col.ColName.L == ic.Name.L {
					us.usedIndex = append(us.usedIndex, i)
					break
				}
			}
		}
		us.dirty = getDirtyDB(b.ctx).getDirtyTable(x.table.Meta().ID)
		us.condition = v.Condition
		us.buildAndSortAddedRows(x.table, x.asName)
	default:
		// The mem table will not be written by sql directly, so we can omit the union scan to avoid err reporting.
		return src
	}
	return us
}