func (i *blockIter) Next() (sql.Row, error) {
	return i.internalIter.Next()
}
Next implements the sql.RowIter interface.
package plan
import (
	"io"
	"github.com/dolthub/go-mysql-server/sql"
)
type Block struct {
	statements []sql.Node
	rowIterSch sql.Schema  
}
var _ sql.Node = (*Block)(nil)
var _ sql.DebugStringer = (*Block)(nil)
func NewBlock(statements []sql.Node) *Block {
	return &Block{statements: statements}
}
func (b *Block) Resolved() bool {
	for _, s := range b.statements {
		if !s.Resolved() {
			return false
		}
	}
	return true
}
func (b *Block) String() string {
	p := sql.NewTreePrinter()
	_ = p.WriteNode("BLOCK")
	var children []string
	for _, s := range b.statements {
		children = append(children, s.String())
	}
	_ = p.WriteChildren(children...)
	return p.String()
}
func (b *Block) DebugString() string {
	p := sql.NewTreePrinter()
	_ = p.WriteNode("BLOCK")
	var children []string
	for _, s := range b.statements {
		children = append(children, sql.DebugString(s))
	}
	_ = p.WriteChildren(children...)
	return p.String()
}
func (b *Block) Schema() sql.Schema {
	return b.rowIterSch
}
func (b *Block) Children() []sql.Node {
	return b.statements
}
func (b *Block) WithChildren(children ...sql.Node) (sql.Node, error) {
	return NewBlock(children), nil
}
func (b *Block) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
	var returnRows []sql.Row
	var returnNode sql.Node
	var returnSch sql.Schema
	selectSeen := false
	for _, s := range b.statements {
		err := func() error {
			rowCache, disposeFunc := ctx.Memory.NewRowsCache()
			defer disposeFunc()
			var isSelect bool
			subIter, err := s.RowIter(ctx, row)
			if err != nil {
				return err
			}
			subIterNode := s
			subIterSch := s.Schema()
			if blockSubIter, ok := subIter.(BlockRowIter); ok {
				subIterNode = blockSubIter.RepresentingNode()
				subIterSch = blockSubIter.Schema()
			}
			if isSelect = nodeRepresentsSelect(subIterNode); isSelect {
				selectSeen = true
				returnNode = subIterNode
				returnSch = subIterSch
			} else if !selectSeen {
				returnNode = subIterNode
				returnSch = subIterSch
			}
			for {
				newRow, err := subIter.Next()
				if err == io.EOF {
					err := subIter.Close(ctx)
					if err != nil {
						return err
					}
					if isSelect || !selectSeen {
						returnRows = rowCache.Get()
					}
					break
				} else if err != nil {
					return err
				} else if isSelect || !selectSeen {
					err = rowCache.Add(newRow)
					if err != nil {
						return err
					}
				}
			}
			return nil
		}()
		if err != nil {
			return nil, err
		}
	}
	b.rowIterSch = returnSch
	return &blockIter{
		internalIter: sql.RowsToRowIter(returnRows...),
		repNode:      returnNode,
		sch:          returnSch,
	}, nil
}
type blockIter struct {
	internalIter sql.RowIter
	repNode      sql.Node
	sch          sql.Schema
}
var _ BlockRowIter = (*blockIter)(nil)