func (p *ProjExec) evalExprs(input, output *chunk.Chunk) error {
	for _, expr := range p.Exprs {
		if e, ok := expr.(*expression.ScalarFunction); ok {
			if e.FuncName.L == ast.Database {
				db, _, err := e.EvalString(p.ctx, input.GetRow(0))
				if err != nil {
					return err
				}
				output.AppendString(0, db)
				return nil
			}
		}
	}
	return nil
}
Only handle select database() for now.
package executor
import (
	"bytes"
	"context"
	"fmt"
	"runtime"
	"strings"
	"github.com/cznic/mathutil"
	"github.com/pingcap/errors"
	"github.com/pingcap/parser/ast"
	"github.com/pingcap/parser/mysql"
	"github.com/pingcap/parser/terror"
	"github.com/pingcap/tidb/kv"
	"github.com/pingcap/tidb/sessionctx/stmtctx"
	"github.com/pingcap/tidb/sessionctx/variable"
	"github.com/pingcap/tidb/store/tikv"
	"github.com/pingcap/tidb/types"
	"github.com/pingcap/tidb/util/chunk"
	"github.com/pingcap/tidb/util/logutil"
	"github.com/pingcap/tidb/util/stringutil"
	"github.com/zhihu/zetta/pkg/codec"
	"github.com/zhihu/zetta/pkg/model"
	"github.com/zhihu/zetta/pkg/tablecodec"
	"github.com/zhihu/zetta/tablestore/infoschema"
	"github.com/zhihu/zetta/tablestore/mysql/executor/aggfuncs"
	"github.com/zhihu/zetta/tablestore/mysql/expression"
	"github.com/zhihu/zetta/tablestore/mysql/sctx"
	"github.com/zhihu/zetta/tablestore/table"
	"github.com/zhihu/zetta/tablestore/table/tables"
	"github.com/zhihu/zetta/tablestore/util"
	"github.com/zhihu/zetta/tablestore/zstore"
	"go.uber.org/zap"
)
type Executor interface {
	base() *baseExecutor
	Open(context.Context) error
	Next(ctx context.Context, req *chunk.Chunk) error
	Close() error
	Schema() *expression.Schema
}
var (
	_ Executor = &TableScanExec{}
	_ Executor = &TableDualExec{}
	_ Executor = &SimpleExec{}
	_ Executor = &BatchPointGetExecutor{}
	_ Executor = &SimpleScanExecutor{}
)
func Next(ctx context.Context, e Executor, req *chunk.Chunk) error {
	return e.Next(ctx, req)
}
type baseExecutor struct {
	ctx           sctx.Context
	id            fmt.Stringer
	schema        *expression.Schema  
	initCap       int
	maxChunkSize  int
	children      []Executor
	retFieldTypes []*types.FieldType
}
func (e *baseExecutor) base() *baseExecutor {
	return e
}
func (e *baseExecutor) Open(ctx context.Context) error {
	for _, child := range e.children {
		err := child.Open(ctx)
		if err != nil {
			return err
		}
	}
	return nil
}
func (e *baseExecutor) Close() error {
	var firstErr error
	for _, src := range e.children {
		if err := src.Close(); err != nil && firstErr == nil {
			firstErr = err
		}
	}
	return firstErr
}
func (e *baseExecutor) Schema() *expression.Schema {
	if e.schema == nil {
		return expression.NewSchema()
	}
	return e.schema
}
func (e *baseExecutor) Next(ctx context.Context, req *chunk.Chunk) error {
	return nil
}
func newBaseExecutor(ctx sctx.Context, schema *expression.Schema, id fmt.Stringer, children ...Executor) baseExecutor {
	e := baseExecutor{
		children:     children,
		ctx:          ctx,
		id:           id,
		schema:       schema,
		initCap:      ctx.GetSessionVars().InitChunkSize,
		maxChunkSize: ctx.GetSessionVars().MaxChunkSize,
	}
	if schema != nil {
		cols := schema.Columns
		e.retFieldTypes = make([]*types.FieldType, len(cols))
		for i := range cols {
			e.retFieldTypes[i] = cols[i].RetType
		}
	}
	return e
}
func NewFirstChunk(e Executor) *chunk.Chunk {
	base := e.base()
	return chunk.New(base.retFieldTypes, base.initCap, base.maxChunkSize)
}
func retTypes(e Executor) []*types.FieldType {
	base := e.base()
	return base.retFieldTypes
}
type ZettaScanExec struct {
	baseExecutor
	tbl table.Table
}
type TableScanExec struct {
	baseExecutor
	done                  bool
	tbl                   table.Table
	columns               []*model.ColumnMeta
	virtualTableChunkList *chunk.List
	virtualTableChunkIdx  int
	IdxVals []types.Datum
	Index   *model.IndexMeta
	PkVals  []types.Datum
	Limit uint64
}
func (t *TableScanExec) Open(ctx context.Context) error {
	return t.baseExecutor.Open(ctx)
}
func (t *TableScanExec) Close() error {
	return t.baseExecutor.Close()
}
func (t *TableScanExec) Next(ctx context.Context, req *chunk.Chunk) error {
	req.GrowAndReset(t.maxChunkSize)
	return t.nextChunk4InfoSchema(ctx, req)
}
func (t *TableScanExec) getStartKey() []byte {
	tbId := t.tbl.Meta().Id
	if len(t.PkVals) != 0 {
		b, _ := tablecodec.EncodeRecordPrimaryKey(nil, tbId, t.PkVals)
		return b
	}
	if len(t.IdxVals) != 0 {
		b, _ := tablecodec.EncodeIndexUnique(nil, tbId, t.Index.Id, t.IdxVals)
		return b
	}
	return t.tbl.RecordPrefix()
}
func (e *TableScanExec) nextChunk4InfoSchema(ctx context.Context, chk *chunk.Chunk) error {
	if e.virtualTableChunkList == nil {
		e.virtualTableChunkList = chunk.NewList(retTypes(e), e.initCap, e.maxChunkSize)
		columns := make([]*table.Column, e.schema.Len())
		for i, colInfo := range e.columns {
			columns[i] = table.ToColumn(colInfo)
		}
		var err error
		startKey := e.getStartKey()
		mutableRow := chunk.MutRowFromTypes(retTypes(e))
		var rowNums uint64
		fn := func(rec []types.Datum, cols []*table.Column) (bool, error) {
			if e.Limit != 0 && rowNums >= e.Limit {
				return false, nil
			}
			mutableRow.SetDatums(rec...)
			e.virtualTableChunkList.AppendRow(mutableRow.ToRow())
			rowNums++
			return true, nil
		}
		if len(e.IdxVals) != 0 {
			err = e.tbl.FetchRecordsByIndex(e.ctx, e.IdxVals, columns, e.Index.Id, e.Index.Unique, fn)
		} else if len(e.PkVals) != 0 && len(e.tbl.Meta().PrimaryKey) == 1 {
			err = e.tbl.BatchGet(e.ctx, [][]types.Datum{e.PkVals}, columns, 0, true, fn)
		} else {
			err = e.tbl.IterRecords(e.ctx, startKey, nil, columns, false, fn)
		}
		if err != nil {
			return err
		}
	}
	if e.virtualTableChunkIdx >= e.virtualTableChunkList.NumChunks() {
		return nil
	}
	virtualTableChunk := e.virtualTableChunkList.GetChunk(e.virtualTableChunkIdx)
	e.virtualTableChunkIdx++
	chk.SwapColumns(virtualTableChunk)
	return nil
}
type SelectionExec struct {
	baseExecutor
	batched     bool
	filters     []expression.Expression
	selected    []bool
	inputRow    chunk.Row
	inputIter   *chunk.Iterator4Chunk
	childResult *chunk.Chunk
}
func (e *SelectionExec) Open(ctx context.Context) error {
	if err := e.baseExecutor.Open(ctx); err != nil {
		return err
	}
	return e.open(ctx)
}
func (e *SelectionExec) open(ctx context.Context) error {
	e.childResult = NewFirstChunk(e.children[0])
	e.inputIter = chunk.NewIterator4Chunk(e.childResult)
	e.inputRow = e.inputIter.End()
	return nil
}
func (e *SelectionExec) Close() error {
	e.childResult = nil
	e.selected = nil
	return e.baseExecutor.Close()
}
func PrintStack() {
	var buf [4096]byte
	n := runtime.Stack(buf[:], false)
	fmt.Printf("==> %s\n", string(buf[:n]))
}
func (e *SelectionExec) Next(ctx context.Context, req *chunk.Chunk) error {
	if !e.batched {
		return e.unPatchedNext(ctx, req)
	}
	return nil
}
func (e *SelectionExec) unPatchedNext(ctx context.Context, req *chunk.Chunk) error {
	req.Reset()
	for {
		for ; e.inputRow != e.inputIter.End(); e.inputRow = e.inputIter.Next() {
			selected, _, err := expression.EvalBool(e.ctx, e.filters, e.inputRow)
			if err != nil {
				return err
			}
			if selected {
				req.AppendRow(e.inputRow)
			}
		}
		err := Next(ctx, e.children[0], e.childResult)
		if err != nil {
			return err
		}
		e.inputRow = e.inputIter.Begin()
		if e.childResult.NumRows() == 0 {
			return nil
		}
	}
}
type ProjExec struct {
	baseExecutor
	inputRow    chunk.Row
	inputIter   *chunk.Iterator4Chunk
	childResult *chunk.Chunk
	Exprs       []expression.Expression
	colIndexMap map[int]int
}
func (p *ProjExec) Open(ctx context.Context) error {
	if err := p.baseExecutor.Open(ctx); err != nil {
		return err
	}
	return p.open()
}
func (p *ProjExec) open() error {
	p.childResult = NewFirstChunk(p.children[0])
	p.inputIter = chunk.NewIterator4Chunk(p.childResult)
	p.inputRow = p.inputIter.End()
	return nil
}
func (p *ProjExec) Close() error {
	p.childResult = nil
	return p.baseExecutor.Close()
}