func (s *stmt) convertToNamed(args []driver.Value) []driver.NamedValue {
	namedArgs := make([]driver.NamedValue, len(args))
	for idx, arg := range args {
		namedArgs[idx] = driver.NamedValue{
			Ordinal: idx,
			Value:   arg,
		}
	}
	return namedArgs
}
convertToNamed takes an argument list of Value that come from the older Exec/Query functions
and converts them to NamedValue to be forwarded to their Context equivalents.
package vertigo
import (
	"context"
	"database/sql/driver"
	"errors"
	"fmt"
	"io"
	"math/rand"
	"os"
	"reflect"
	"regexp"
	"strings"
	"time"
	"github.com/vertica/vertica-sql-go/common"
	"github.com/vertica/vertica-sql-go/logger"
	"github.com/vertica/vertica-sql-go/msgs"
	"github.com/vertica/vertica-sql-go/parse"
)
var (
	stmtLogger = logger.New("stmt")
)
type parseState int
const (
	parseStateUnparsed parseState = iota
	parseStateParseError
	parseStateParsed
)
type stmt struct {
	conn         *connection
	command      string
	preparedName string
	parseState   parseState
	namedArgPos  []string
	posArgCnt    int
	paramTypes   []common.ParameterType
	lastRowDesc  *msgs.BERowDescMsg
	rolledBack bool
}
func newStmt(connection *connection, command string) (*stmt, error) {
	if len(command) == 0 {
		return nil, fmt.Errorf("cannot create an empty statement")
	}
	s := &stmt{
		conn:         connection,
		preparedName: fmt.Sprintf("S%d%d%d", os.Getpid(), time.Now().Unix(), rand.Int31()),
		parseState:   parseStateUnparsed,
	}
	argCounter := func() string {
		s.posArgCnt++
		return "?"
	}
	s.command = parse.Lex(command, parse.WithNamedCallback(s.pushNamed), parse.WithPositionalSubstitution(argCounter))
	return s, nil
}
func (s *stmt) pushNamed(name string) {
	s.namedArgPos = append(s.namedArgPos, name)
}
func (s *stmt) Close() error {
	if s.parseState != parseStateParsed {
		return nil
	}
	if s.rolledBack {
		s.parseState = parseStateUnparsed
		s.conn.dead = true
		return nil
	}
	closeMsg := &msgs.FECloseMsg{TargetType: msgs.CmdTargetTypeStatement, TargetName: s.preparedName}
	if err := s.conn.sendMessage(closeMsg); err != nil {
		return err
	}
	if err := s.conn.sendMessage(&msgs.FEFlushMsg{}); err != nil {
		return err
	}
	for {
		bMsg, err := s.conn.recvMessage()
		if err != nil {
			return err
		}
		switch bMsg.(type) {
		case *msgs.BECloseCompleteMsg:
			s.parseState = parseStateUnparsed
			return nil
		case *msgs.BECmdDescriptionMsg:
			continue
		default:
			s.conn.defaultMessageHandler(bMsg)
		}
	}
}
func (s *stmt) NumInput() int {
	if len(s.namedArgPos) > 0 {
		uniqueArgs := make(map[string]bool)
		for _, arg := range s.namedArgPos {
			uniqueArgs[arg] = true
		}
		return len(uniqueArgs)
	}
	return s.posArgCnt
}