99package mysql
1010
1111import (
12- "crypto/tls"
1312 "database/sql/driver"
14- "errors"
1513 "net"
1614 "strconv"
1715 "strings"
@@ -23,7 +21,7 @@ type mysqlConn struct {
2321 netConn net.Conn
2422 affectedRows uint64
2523 insertId uint64
26- cfg * config
24+ cfg * Config
2725 maxPacketAllowed int
2826 maxWriteSize int
2927 flags clientFlag
@@ -33,28 +31,9 @@ type mysqlConn struct {
3331 strict bool
3432}
3533
36- type config struct {
37- user string
38- passwd string
39- net string
40- addr string
41- dbname string
42- params map [string ]string
43- loc * time.Location
44- tls * tls.Config
45- timeout time.Duration
46- collation uint8
47- allowAllFiles bool
48- allowOldPasswords bool
49- allowCleartextPasswords bool
50- clientFoundRows bool
51- columnsWithAlias bool
52- interpolateParams bool
53- }
54-
5534// Handles parameters set in DSN after the connection is established
5635func (mc * mysqlConn ) handleParams () (err error ) {
57- for param , val := range mc .cfg .params {
36+ for param , val := range mc .cfg .Params {
5837 switch param {
5938 // Charset
6039 case "charset" :
@@ -70,27 +49,6 @@ func (mc *mysqlConn) handleParams() (err error) {
7049 return
7150 }
7251
73- // time.Time parsing
74- case "parseTime" :
75- var isBool bool
76- mc .parseTime , isBool = readBool (val )
77- if ! isBool {
78- return errors .New ("Invalid Bool value: " + val )
79- }
80-
81- // Strict mode
82- case "strict" :
83- var isBool bool
84- mc .strict , isBool = readBool (val )
85- if ! isBool {
86- return errors .New ("Invalid Bool value: " + val )
87- }
88-
89- // Compression
90- case "compress" :
91- err = errors .New ("Compression not implemented yet" )
92- return
93-
9452 // System Vars
9553 default :
9654 err = mc .exec ("SET " + param + "=" + val + "" )
@@ -217,7 +175,7 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
217175 if v .IsZero () {
218176 buf = append (buf , "'0000-00-00'" ... )
219177 } else {
220- v := v .In (mc .cfg .loc )
178+ v := v .In (mc .cfg .Loc )
221179 v = v .Add (time .Nanosecond * 500 ) // To round under microsecond
222180 year := v .Year ()
223181 year100 := year / 100
@@ -298,7 +256,7 @@ func (mc *mysqlConn) Exec(query string, args []driver.Value) (driver.Result, err
298256 return nil , driver .ErrBadConn
299257 }
300258 if len (args ) != 0 {
301- if ! mc .cfg .interpolateParams {
259+ if ! mc .cfg .InterpolateParams {
302260 return nil , driver .ErrSkip
303261 }
304262 // try to interpolate the parameters to save extra roundtrips for preparing and closing a statement
@@ -349,7 +307,7 @@ func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, erro
349307 return nil , driver .ErrBadConn
350308 }
351309 if len (args ) != 0 {
352- if ! mc .cfg .interpolateParams {
310+ if ! mc .cfg .InterpolateParams {
353311 return nil , driver .ErrSkip
354312 }
355313 // try client-side prepare to reduce roundtrip
@@ -395,6 +353,7 @@ func (mc *mysqlConn) getSystemVar(name string) ([]byte, error) {
395353 if err == nil {
396354 rows := new (textRows )
397355 rows .mc = mc
356+ rows .columns = []mysqlField {{fieldType : fieldTypeVarChar }}
398357
399358 if resLen > 0 {
400359 // Columns
0 commit comments