func (s *Subquery) EvalMultiple(ctx *sql.Context) ([]interface{}, error) {
	if s.value != nil {
		return s.value.([]interface{}), nil
	}
	iter, err := s.Query.RowIter(ctx)
	if err != nil {
		return nil, err
	}
	rows, err := sql.RowIterToRows(iter)
	if err != nil {
		return nil, err
	}
	if len(rows) == 0 {
		s.value = []interface{}{}
		return nil, nil
	}
	var result = make([]interface{}, len(rows))
	for i, row := range rows {
		result[i] = row[0]
	}
	s.value = result
	return result, nil
}
EvalMultiple returns all rows returned by a subquery.
package expression
import (
	"fmt"
	"github.com/src-d/go-mysql-server/sql"
	errors "gopkg.in/src-d/go-errors.v1"
)
var errExpectedSingleRow = errors.NewKind("the subquery returned more than 1 row")
type Subquery struct {
	Query sql.Node
	value interface{}
}
func NewSubquery(node sql.Node) *Subquery {
	return &Subquery{node, nil}
}
func (s *Subquery) Eval(ctx *sql.Context, _ sql.Row) (interface{}, error) {
	if s.value != nil {
		if elems, ok := s.value.([]interface{}); ok {
			if len(elems) > 1 {
				return nil, errExpectedSingleRow.New()
			}
			return elems[0], nil
		}
		return s.value, nil
	}
	iter, err := s.Query.RowIter(ctx)
	if err != nil {
		return nil, err
	}
	rows, err := sql.RowIterToRows(iter)
	if err != nil {
		return nil, err
	}
	if len(rows) == 0 {
		s.value = nil
		return nil, nil
	}
	if len(rows) > 1 {
		return nil, errExpectedSingleRow.New()
	}
	s.value = rows[0][0]
	return s.value, nil
}