func (c *CreateSavepoint) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) {
	tdb, ok := c.db.(sql.TransactionDatabase)
	if !ok {
		return sql.RowsToRowIter(), nil
	}
	transaction := ctx.GetTransaction()
	if transaction == nil {
		return sql.RowsToRowIter(), nil
	}
	err := tdb.CreateSavepoint(ctx, transaction, c.name)
	if err != nil {
		return nil, err
	}
	return sql.RowsToRowIter(), nil
}
RowIter implements the sql.Node interface.
package plan
import (
	"fmt"
	"github.com/dolthub/go-mysql-server/sql"
)
type StartTransaction struct {
	UnaryNode  
	db        sql.Database
	transChar sql.TransactionCharacteristic
}
var _ sql.Databaser = (*StartTransaction)(nil)
var _ sql.Node = (*StartTransaction)(nil)
func NewStartTransaction(db sql.UnresolvedDatabase, transactionChar sql.TransactionCharacteristic) *StartTransaction {
	return &StartTransaction{
		db:        db,
		transChar: transactionChar,
	}
}
func (s *StartTransaction) Database() sql.Database {
	return s.db
}
func (s StartTransaction) WithDatabase(database sql.Database) (sql.Node, error) {
	s.db = database
	return &s, nil
}
func (s *StartTransaction) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
	tdb, ok := s.db.(sql.TransactionDatabase)
	if !ok {
		if s.Child == nil {
			return sql.RowsToRowIter(), nil
		}
		return s.Child.RowIter(ctx, row)
	}
	currentTx := ctx.GetTransaction()
	if currentTx != nil {
		err := tdb.CommitTransaction(ctx, currentTx)
		if err != nil {
			return nil, err
		}
	}
	transaction, err := tdb.StartTransaction(ctx, s.transChar)
	if err != nil {
		return nil, err
	}
	ctx.SetTransaction(transaction)
	ctx.SetIgnoreAutoCommit(true)
	if s.Child == nil {
		return sql.RowsToRowIter(), nil
	}
	return s.Child.RowIter(ctx, row)
}
func (s *StartTransaction) String() string {
	if s.Child != nil {
		return s.Child.String()
	}
	return "Start Transaction"
}
func (s *StartTransaction) DebugString() string {
	tp := sql.NewTreePrinter()
	_ = tp.WriteNode("Start Transaction")
	if s.Child != nil {
		_ = tp.WriteChildren(sql.DebugString(s.Child))
	}
	return tp.String()
}
func (s *StartTransaction) Children() []sql.Node {
	if s.Child == nil {
		return nil
	}
	return []sql.Node{s.Child}
}
func (s StartTransaction) WithChildren(children ...sql.Node) (sql.Node, error) {
	if s.Child == nil {
		if len(children) != 0 {
			return nil, sql.ErrInvalidChildrenNumber.New(s, len(children), 0)
		}
		return &s, nil
	}
	if len(children) != 1 {
		return nil, sql.ErrInvalidChildrenNumber.New(s, len(children), 1)
	}
	s.Child = children[0]
	return &s, nil
}
func (s *StartTransaction) Resolved() bool {
	_, unresolved := s.db.(sql.UnresolvedDatabase)
	dbResolved := !unresolved || s.db.Name() == ""
	if s.Child != nil {
		return dbResolved && s.Child.Resolved()
	}
	return dbResolved
}
func (s *StartTransaction) Schema() sql.Schema {
	if s.Child == nil {
		return nil
	}
	return s.Child.Schema()
}
type Commit struct {
	db sql.Database
}
var _ sql.Databaser = (*Commit)(nil)
var _ sql.Node = (*Commit)(nil)
func NewCommit(db sql.UnresolvedDatabase) *Commit {
	return &Commit{
		db: db,
	}
}
func (c *Commit) Database() sql.Database {
	return c.db
}
func (c Commit) WithDatabase(database sql.Database) (sql.Node, error) {
	c.db = database
	return &c, nil
}
func (c *Commit) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) {
	tdb, ok := c.db.(sql.TransactionDatabase)
	if !ok {
		return sql.RowsToRowIter(), nil
	}
	transaction := ctx.GetTransaction()
	if transaction == nil {
		return sql.RowsToRowIter(), nil
	}
	err := tdb.CommitTransaction(ctx, transaction)
	if err != nil {
		return nil, err
	}
	ctx.SetIgnoreAutoCommit(false)
	ctx.SetTransaction(nil)
	return sql.RowsToRowIter(), nil
}
func (*Commit) String() string { return "COMMIT" }
func (c *Commit) WithChildren(children ...sql.Node) (sql.Node, error) {
	if len(children) != 0 {
		return nil, sql.ErrInvalidChildrenNumber.New(c, len(children), 0)
	}
	return c, nil
}
func (c *Commit) Resolved() bool {
	_, unresolved := c.db.(sql.UnresolvedDatabase)
	dbResolved := !unresolved || c.db.Name() == ""
	return dbResolved
}
func (*Commit) Children() []sql.Node { return nil }
func (*Commit) Schema() sql.Schema { return nil }
type Rollback struct {
	db sql.Database
}
var _ sql.Databaser = (*Rollback)(nil)
var _ sql.Node = (*Rollback)(nil)
func NewRollback(db sql.UnresolvedDatabase) *Rollback {
	return &Rollback{
		db: db,
	}
}
func (r *Rollback) RowIter(ctx *sql.Context, _ sql.Row) (sql.RowIter, error) {
	tdb, ok := r.db.(sql.TransactionDatabase)
	if !ok {
		return sql.RowsToRowIter(), nil
	}
	transaction := ctx.GetTransaction()
	if transaction == nil {
		return sql.RowsToRowIter(), nil
	}
	err := tdb.Rollback(ctx, transaction)
	if err != nil {
		return nil, err
	}
	ctx.SetIgnoreAutoCommit(false)
	ctx.SetTransaction(nil)
	return sql.RowsToRowIter(), nil
}
func (r *Rollback) Database() sql.Database {
	return r.db
}
func (r Rollback) WithDatabase(database sql.Database) (sql.Node, error) {
	r.db = database
	return &r, nil
}
func (*Rollback) String() string { return "ROLLBACK" }
func (r *Rollback) WithChildren(children ...sql.Node) (sql.Node, error) {
	if len(children) != 0 {
		return nil, sql.ErrInvalidChildrenNumber.New(r, len(children), 0)
	}
	return r, nil
}
func (r *Rollback) Resolved() bool {
	_, ok := r.db.(sql.UnresolvedDatabase)
	return !ok
}
func (*Rollback) Children() []sql.Node { return nil }
func (*Rollback) Schema() sql.Schema { return nil }
type CreateSavepoint struct {
	name string
	db   sql.Database
}
var _ sql.Databaser = (*CreateSavepoint)(nil)
var _ sql.Node = (*CreateSavepoint)(nil)
func NewCreateSavepoint(db sql.UnresolvedDatabase, name string) *CreateSavepoint {
	return &CreateSavepoint{
		db:   db,
		name: name,
	}
}