func (this *Iter_ExtraServ_ExtraGetAllUsers) One() *Row_ExtraServ_ExtraGetAllUsers {
	first, hasFirst := this.Next()
	defer func() {
		if this.rows != nil {
			this.rows.Close()
		}
	}()
	if first != nil && first.err != nil && first.err != io.EOF {
		return &Row_ExtraServ_ExtraGetAllUsers{err: first.err}
	}
	_, hasSecond := this.Next()
	if !hasFirst || hasSecond {
		amount := "none"
		if hasSecond {
			amount = "multiple"
		}
		return &Row_ExtraServ_ExtraGetAllUsers{err: persist.NotFound{Msg: fmt.Sprintf("expected exactly 1 result from query 'ExtraGetAllUsers' found %s", amount)}}
	}
	return first
}
One returns the sole row, or ensures an error if there was not one result when this row is converted
package pb
import (
	sql "database/sql"
	driver "database/sql/driver"
	fmt "fmt"
	io "io"
	proto "github.com/golang/protobuf/proto"
	timestamp "github.com/golang/protobuf/ptypes/timestamp"
	imports "github.com/tcncloud/protoc-gen-persistexamples/user_sql/pb/imports"
	persist "github.com/tcncloud/protoc-gen-persist/persist"
	context "golang.org/x/net/context"
	codes "google.golang.org/grpc/codes"
	gstatus "google.golang.org/grpc/status"
)
type Queries_ExtraServ struct {
	opts Opts_ExtraServ
}
func QueriesExtraServ(opts ...Opts_ExtraServ) *Queries_ExtraServ {
	var myOpts Opts_ExtraServ
	if len(opts) > 0 {
		myOpts = opts[0]
	} else {
		myOpts = OptsExtraServ(&DefaultHooks_ExtraServ{}, &DefaultTypeMappings_ExtraServ{})
	}
	return &Queries_ExtraServ{
		opts: myOpts,
	}
}
func (this *Queries_ExtraServ) ExtraCreateUsersTable(ctx context.Context, db persist.Runnable) *Query_ExtraServ_ExtraCreateUsersTable {
	return &Query_ExtraServ_ExtraCreateUsersTable{
		opts: this.opts,
		ctx:  ctx,
		db:   db,
	}
}
type Query_ExtraServ_ExtraCreateUsersTable struct {
	opts Opts_ExtraServ
	db   persist.Runnable
	ctx  context.Context
}
func (this *Query_ExtraServ_ExtraCreateUsersTable) QueryInType_Empty()  {}
func (this *Query_ExtraServ_ExtraCreateUsersTable) QueryOutType_Empty() {}
func (this *Query_ExtraServ_ExtraCreateUsersTable) Execute(x In_ExtraServ_ExtraCreateUsersTable) *Iter_ExtraServ_ExtraCreateUsersTable {
	var setupErr error
	params := []interface{}{}
	result := &Iter_ExtraServ_ExtraCreateUsersTable{
		tm:  this.opts.MAPPINGS,
		ctx: this.ctx,
	}
	if setupErr != nil {
		result.err = setupErr
		return result
	}
	result.result, result.err = this.db.ExecContext(this.ctx, "CREATE TABLE users(id integer PRIMARY KEY, name VARCHAR(50), friends BYTEA, created_on VARCHAR(50), id2 SMALLINT, counts []BIGINT)", params...)
	return result
}
func (this *Queries_ExtraServ) ExtraGetAllUsers(ctx context.Context, db persist.Runnable) *Query_ExtraServ_ExtraGetAllUsers {
	return &Query_ExtraServ_ExtraGetAllUsers{
		opts: this.opts,
		ctx:  ctx,
		db:   db,
	}
}
type Query_ExtraServ_ExtraGetAllUsers struct {
	opts Opts_ExtraServ
	db   persist.Runnable
	ctx  context.Context
}
func (this *Query_ExtraServ_ExtraGetAllUsers) QueryInType_Empty() {}
func (this *Query_ExtraServ_ExtraGetAllUsers) QueryOutType_User() {}
func (this *Query_ExtraServ_ExtraGetAllUsers) Execute(x In_ExtraServ_ExtraGetAllUsers) *Iter_ExtraServ_ExtraGetAllUsers {
	var setupErr error
	params := []interface{}{}
	result := &Iter_ExtraServ_ExtraGetAllUsers{
		tm:  this.opts.MAPPINGS,
		ctx: this.ctx,
	}
	if setupErr != nil {
		result.err = setupErr
		return result
	}
	result.rows, result.err = this.db.QueryContext(this.ctx, "SELECT id, name, friends, created_on, id2 FROM users", params...)
	return result
}
func (this *Queries_ExtraServ) ExtraSelectUserById(ctx context.Context, db persist.Runnable) *Query_ExtraServ_ExtraSelectUserById {
	return &Query_ExtraServ_ExtraSelectUserById{
		opts: this.opts,
		ctx:  ctx,
		db:   db,
	}
}
type Query_ExtraServ_ExtraSelectUserById struct {
	opts Opts_ExtraServ
	db   persist.Runnable
	ctx  context.Context
}
func (this *Query_ExtraServ_ExtraSelectUserById) QueryInType_User()  {}
func (this *Query_ExtraServ_ExtraSelectUserById) QueryOutType_User() {}
func (this *Query_ExtraServ_ExtraSelectUserById) Execute(x In_ExtraServ_ExtraSelectUserById) *Iter_ExtraServ_ExtraSelectUserById {
	var setupErr error
	params := []interface{}{
		func() (out interface{}) {
			out = x.GetId()
			return
		}(),
	}
	result := &Iter_ExtraServ_ExtraSelectUserById{
		tm:  this.opts.MAPPINGS,
		ctx: this.ctx,
	}
	if setupErr != nil {
		result.err = setupErr
		return result
	}
	result.rows, result.err = this.db.QueryContext(this.ctx, "SELECT id, name, friends, created_on, id2 FROM users WHERE id = $1", params...)
	return result
}
func (this *Queries_ExtraServ) ExtraUpdateUserName(ctx context.Context, db persist.Runnable) *Query_ExtraServ_ExtraUpdateUserName {
	return &Query_ExtraServ_ExtraUpdateUserName{
		opts: this.opts,
		ctx:  ctx,
		db:   db,
	}
}
type Query_ExtraServ_ExtraUpdateUserName struct {
	opts Opts_ExtraServ
	db   persist.Runnable
	ctx  context.Context
}
func (this *Query_ExtraServ_ExtraUpdateUserName) QueryInType_User()  {}
func (this *Query_ExtraServ_ExtraUpdateUserName) QueryOutType_User() {}
func (this *Query_ExtraServ_ExtraUpdateUserName) Execute(x In_ExtraServ_ExtraUpdateUserName) *Iter_ExtraServ_ExtraUpdateUserName {
	var setupErr error
	params := []interface{}{
		func() (out interface{}) {
			out = x.GetName()
			return
		}(),
		func() (out interface{}) {
			out = x.GetId()
			return
		}(),
	}
	result := &Iter_ExtraServ_ExtraUpdateUserName{
		tm:  this.opts.MAPPINGS,
		ctx: this.ctx,
	}
	if setupErr != nil {
		result.err = setupErr
		return result
	}
	result.rows, result.err = this.db.QueryContext(this.ctx, "Update users set name = $1 WHERE id = $2  RETURNING id, name, friends, created_on", params...)
	return result
}
type Iter_ExtraServ_ExtraCreateUsersTable struct {
	result sql.Result
	rows   *sql.Rows
	err    error
	tm     TypeMappings_ExtraServ
	ctx    context.Context
}
func (this *Iter_ExtraServ_ExtraCreateUsersTable) IterOutTypeEmpty() {}
func (this *Iter_ExtraServ_ExtraCreateUsersTable) IterInTypeEmpty()  {}
func (this *Iter_ExtraServ_ExtraCreateUsersTable) Each(fun func(*Row_ExtraServ_ExtraCreateUsersTable) error) error {
	defer func() {
		if this.rows != nil {
			this.rows.Close()
		}
	}()
	for {
		select {
		case <-this.ctx.Done():
			return this.ctx.Err()
		default:
			if row, ok := this.Next(); !ok {
				return nil
			} else if err := fun(row); err != nil {
				return err
			}
		}
	}
}
func (this *Iter_ExtraServ_ExtraCreateUsersTable) One() *Row_ExtraServ_ExtraCreateUsersTable {
	first, hasFirst := this.Next()
	defer func() {
		if this.rows != nil {
			this.rows.Close()
		}
	}()
	if first != nil && first.err != nil && first.err != io.EOF {
		return &Row_ExtraServ_ExtraCreateUsersTable{err: first.err}
	}
	_, hasSecond := this.Next()
	if !hasFirst || hasSecond {
		amount := "none"
		if hasSecond {
			amount = "multiple"
		}
		return &Row_ExtraServ_ExtraCreateUsersTable{err: persist.NotFound{Msg: fmt.Sprintf("expected exactly 1 result from query 'ExtraCreateUsersTable' found %s", amount)}}
	}
	return first
}
func (this *Iter_ExtraServ_ExtraCreateUsersTable) Zero() error {
	row, ok := this.Next()
	if row != nil && row.err != nil && row.err != io.EOF {
		return row.err
	}
	if ok {
		return fmt.Errorf("expected exactly 0 results from query 'ExtraCreateUsersTable'")
	}
	return nil
}
func (this *Iter_ExtraServ_ExtraCreateUsersTable) Next() (*Row_ExtraServ_ExtraCreateUsersTable, bool) {
	if this.err == io.EOF {
		return nil, false
	}
	if this.err != nil {
		err := this.err
		this.err = io.EOF
		if this.rows != nil {
			this.rows.Close()
		}
		return &Row_ExtraServ_ExtraCreateUsersTable{err: err}, true
	}
	if this.rows == nil {
		this.err = io.EOF
		return nil, false
	}
	cols, err := this.rows.Columns()
	if err != nil {
		return &Row_ExtraServ_ExtraCreateUsersTable{err: err}, true
	}
	if !this.rows.Next() {
		if this.err = this.rows.Err(); this.err == nil {
			this.err = io.EOF
			return nil, false
		} else if this.err != nil {
			return &Row_ExtraServ_ExtraCreateUsersTable{err: err}, true
		}
	}
	toScan := make([]interface{}, len(cols))
	scanned := make([]alwaysScanner, len(cols))
	for i := range scanned {
		toScan[i] = &scanned[i]
	}
	if this.err = this.rows.Scan(toScan...); this.err != nil {
		return &Row_ExtraServ_ExtraCreateUsersTable{err: this.err}, true
	}
	res := &Empty{}
	for i, col := range cols {
		_ = i
		switch col {
		default:
			return &Row_ExtraServ_ExtraCreateUsersTable{err: fmt.Errorf("unsupported column in output: %s", col)}, true
		}
	}
	return &Row_ExtraServ_ExtraCreateUsersTable{item: res}, true
}
func (this *Iter_ExtraServ_ExtraCreateUsersTable) Slice() []*Row_ExtraServ_ExtraCreateUsersTable {
	var results []*Row_ExtraServ_ExtraCreateUsersTable
	for {
		if i, ok := this.Next(); ok {
			results = append(results, i)
		} else {
			break
		}
	}
	return results
}
func (r *Iter_ExtraServ_ExtraCreateUsersTable) Columns() ([]string, error) {
	if r.err != nil {
		return nil, r.err
	}
	if r.rows != nil {
		return r.rows.Columns()
	}
	return nil, nil
}
type Iter_ExtraServ_ExtraGetAllUsers struct {
	result sql.Result
	rows   *sql.Rows
	err    error
	tm     TypeMappings_ExtraServ
	ctx    context.Context
}
func (this *Iter_ExtraServ_ExtraGetAllUsers) IterOutTypeUser() {}
func (this *Iter_ExtraServ_ExtraGetAllUsers) IterInTypeEmpty() {}
func (this *Iter_ExtraServ_ExtraGetAllUsers) Each(fun func(*Row_ExtraServ_ExtraGetAllUsers) error) error {
	defer func() {
		if this.rows != nil {
			this.rows.Close()
		}
	}()
	for {
		select {
		case <-this.ctx.Done():
			return this.ctx.Err()
		default:
			if row, ok := this.Next(); !ok {
				return nil
			} else if err := fun(row); err != nil {
				return err
			}
		}
	}
}