You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils_go18.go 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
  2. //
  3. // Copyright 2017 The Go-MySQL-Driver Authors. All rights reserved.
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public
  6. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  7. // You can obtain one at http://mozilla.org/MPL/2.0/.
  8. // +build go1.8
  9. package mysql
  10. import (
  11. "crypto/tls"
  12. "database/sql"
  13. "database/sql/driver"
  14. "errors"
  15. "fmt"
  16. )
  17. func cloneTLSConfig(c *tls.Config) *tls.Config {
  18. return c.Clone()
  19. }
  20. func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) {
  21. dargs := make([]driver.Value, len(named))
  22. for n, param := range named {
  23. if len(param.Name) > 0 {
  24. // TODO: support the use of Named Parameters #561
  25. return nil, errors.New("mysql: driver does not support the use of Named Parameters")
  26. }
  27. dargs[n] = param.Value
  28. }
  29. return dargs, nil
  30. }
  31. func mapIsolationLevel(level driver.IsolationLevel) (string, error) {
  32. switch sql.IsolationLevel(level) {
  33. case sql.LevelRepeatableRead:
  34. return "REPEATABLE READ", nil
  35. case sql.LevelReadCommitted:
  36. return "READ COMMITTED", nil
  37. case sql.LevelReadUncommitted:
  38. return "READ UNCOMMITTED", nil
  39. case sql.LevelSerializable:
  40. return "SERIALIZABLE", nil
  41. default:
  42. return "", fmt.Errorf("mysql: unsupported isolation level: %v", level)
  43. }
  44. }