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 9// +build go1.8 10 11package mysql 12 13import ( 14 "crypto/tls" 15 "database/sql" 16 "database/sql/driver" 17 "errors" 18 "fmt" 19) 20 21func cloneTLSConfig(c *tls.Config) *tls.Config { 22 return c.Clone() 23} 24 25func namedValueToValue(named []driver.NamedValue) ([]driver.Value, error) { 26 dargs := make([]driver.Value, len(named)) 27 for n, param := range named { 28 if len(param.Name) > 0 { 29 // TODO: support the use of Named Parameters #561 30 return nil, errors.New("mysql: driver does not support the use of Named Parameters") 31 } 32 dargs[n] = param.Value 33 } 34 return dargs, nil 35} 36 37func mapIsolationLevel(level driver.IsolationLevel) (string, error) { 38 switch sql.IsolationLevel(level) { 39 case sql.LevelRepeatableRead: 40 return "REPEATABLE READ", nil 41 case sql.LevelReadCommitted: 42 return "READ COMMITTED", nil 43 case sql.LevelReadUncommitted: 44 return "READ UNCOMMITTED", nil 45 case sql.LevelSerializable: 46 return "SERIALIZABLE", nil 47 default: 48 return "", fmt.Errorf("mysql: unsupported isolation level: %v", level) 49 } 50} 51