Skip to content

Commit df63ad7

Browse files
committed
Merge branch 'master' into introduce-reader-and-write-groutine-3
2 parents 22dd1e4 + 3798012 commit df63ad7

9 files changed

+32
-27
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ New Features:
162162

163163
- Enable microsecond resolution on TIME, DATETIME and TIMESTAMP (#249)
164164
- Support for returning table alias on Columns() (#289, #359, #382)
165-
- Placeholder interpolation, can be actived with the DSN parameter `interpolateParams=true` (#309, #318, #490)
165+
- Placeholder interpolation, can be activated with the DSN parameter `interpolateParams=true` (#309, #318, #490)
166166
- Support for uint64 parameters with high bit set (#332, #345)
167167
- Cleartext authentication plugin support (#327)
168168
- Exported ParseDSN function and the Config struct (#403, #419, #429)
@@ -206,7 +206,7 @@ Changes:
206206
- Also exported the MySQLWarning type
207207
- mysqlConn.Close returns the first error encountered instead of ignoring all errors
208208
- writePacket() automatically writes the packet size to the header
209-
- readPacket() uses an iterative approach instead of the recursive approach to merge splitted packets
209+
- readPacket() uses an iterative approach instead of the recursive approach to merge split packets
210210

211211
New Features:
212212

@@ -254,7 +254,7 @@ Bugfixes:
254254

255255
- Fixed MySQL 4.1 support: MySQL 4.1 sends packets with lengths which differ from the specification
256256
- Convert to DB timezone when inserting `time.Time`
257-
- Splitted packets (more than 16MB) are now merged correctly
257+
- Split packets (more than 16MB) are now merged correctly
258258
- Fixed false positive `io.EOF` errors when the data was fully read
259259
- Avoid panics on reuse of closed connections
260260
- Fixed empty string producing false nil values

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Passwords can consist of any character. Escaping is **not** necessary.
127127

128128
#### Protocol
129129
See [net.Dial](https://golang.org/pkg/net/#Dial) for more information which networks are available.
130-
In general you should use an Unix domain socket if available and TCP otherwise for best performance.
130+
In general you should use a Unix domain socket if available and TCP otherwise for best performance.
131131

132132
#### Address
133133
For TCP and UDP networks, addresses have the form `host[:port]`.

auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
338338

339339
switch plugin {
340340

341-
// https://insidemysql.com/preparing-your-community-connector-for-mysql-8-part-2-sha256/
341+
// https://dev.mysql.com/blog-archive/preparing-your-community-connector-for-mysql-8-part-2-sha256/
342342
case "caching_sha2_password":
343343
switch len(authData) {
344344
case 0:
@@ -376,7 +376,7 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
376376
}
377377

378378
if data[0] != iAuthMoreData {
379-
return fmt.Errorf("unexpect resp from server for caching_sha2_password perform full authentication")
379+
return fmt.Errorf("unexpected resp from server for caching_sha2_password, perform full authentication")
380380
}
381381

382382
// parse public key

connector.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ func encodeConnectionAttributes(textAttributes string) string {
3838

3939
// user-defined connection attributes
4040
for _, connAttr := range strings.Split(textAttributes, ",") {
41-
attr := strings.SplitN(connAttr, ":", 2)
42-
if len(attr) != 2 {
41+
k, v, found := strings.Cut(connAttr, ":")
42+
if !found {
4343
continue
4444
}
45-
for _, v := range attr {
46-
connAttrsBuf = appendLengthEncodedString(connAttrsBuf, v)
47-
}
45+
connAttrsBuf = appendLengthEncodedString(connAttrsBuf, k)
46+
connAttrsBuf = appendLengthEncodedString(connAttrsBuf, v)
4847
}
4948

5049
return string(connAttrsBuf)

driver_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ func TestLongData(t *testing.T) {
11991199
dbt.Fatalf("LONGBLOB: length in: %d, length out: %d", len(inS), len(out))
12001200
}
12011201
if rows.Next() {
1202-
dbt.Error("LONGBLOB: unexpexted row")
1202+
dbt.Error("LONGBLOB: unexpected row")
12031203
}
12041204
} else {
12051205
dbt.Fatalf("LONGBLOB: no data")
@@ -1218,7 +1218,7 @@ func TestLongData(t *testing.T) {
12181218
dbt.Fatalf("LONGBLOB: length in: %d, length out: %d", len(in), len(out))
12191219
}
12201220
if rows.Next() {
1221-
dbt.Error("LONGBLOB: unexpexted row")
1221+
dbt.Error("LONGBLOB: unexpected row")
12221222
}
12231223
} else {
12241224
if err = rows.Err(); err != nil {
@@ -1294,7 +1294,7 @@ func TestLoadData(t *testing.T) {
12941294
dbt.Fatalf("unexpected row count: got %d, want 0", count)
12951295
}
12961296

1297-
// Then fille File with data and try to load it
1297+
// Then fill File with data and try to load it
12981298
file.WriteString("1\ta string\n2\ta string containing a \\t\n3\ta string containing a \\n\n4\ta string containing both \\t\\n\n")
12991299
file.Close()
13001300
dbt.mustExec(fmt.Sprintf("LOAD DATA LOCAL INFILE %q INTO TABLE test", file.Name()))
@@ -1900,7 +1900,7 @@ func TestConcurrent(t *testing.T) {
19001900
}(i)
19011901
}
19021902

1903-
// wait until all conections are open
1903+
// wait until all connections are open
19041904
wg.Wait()
19051905

19061906
if fatalError != "" {
@@ -1949,7 +1949,7 @@ func TestCustomDial(t *testing.T) {
19491949
t.Skipf("MySQL server not running on %s", netAddr)
19501950
}
19511951

1952-
// our custom dial function which justs wraps net.Dial here
1952+
// our custom dial function which just wraps net.Dial here
19531953
RegisterDialContext("mydial", func(ctx context.Context, addr string) (net.Conn, error) {
19541954
var d net.Dialer
19551955
return d.DialContext(ctx, prot, addr)

dsn.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,13 @@ func ParseDSN(dsn string) (cfg *Config, err error) {
390390
// Values must be url.QueryEscape'ed
391391
func parseDSNParams(cfg *Config, params string) (err error) {
392392
for _, v := range strings.Split(params, "&") {
393-
param := strings.SplitN(v, "=", 2)
394-
if len(param) != 2 {
393+
key, value, found := strings.Cut(v, "=")
394+
if !found {
395395
continue
396396
}
397397

398398
// cfg params
399-
switch value := param[1]; param[0] {
399+
switch key {
400400
// Disable INFILE allowlist / enable all files
401401
case "allowAllFiles":
402402
var isBool bool
@@ -577,7 +577,7 @@ func parseDSNParams(cfg *Config, params string) (err error) {
577577
cfg.Params = make(map[string]string)
578578
}
579579

580-
if cfg.Params[param[0]], err = url.QueryUnescape(value); err != nil {
580+
if cfg.Params[key], err = url.QueryUnescape(value); err != nil {
581581
return
582582
}
583583
}

dsn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func TestDSNReformat(t *testing.T) {
132132
dsn2 := cfg1.FormatDSN()
133133
if dsn2 != dsn1 {
134134
// Just log
135-
t.Logf("%d. %q reformated as %q", i, dsn1, dsn2)
135+
t.Logf("%d. %q reformatted as %q", i, dsn1, dsn2)
136136
}
137137

138138
cfg2, err := ParseDSN(dsn2)

packets.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (mc *mysqlConn) readHandshakePacket() (data []byte, plugin string, err erro
219219
// reserved (all [00]) [10 bytes]
220220
pos += 1 + 2 + 2 + 1 + 10
221221

222-
// second part of the password cipher [mininum 13 bytes],
222+
// second part of the password cipher [minimum 13 bytes],
223223
// where len=MAX(13, length of auth-plugin-data - 8)
224224
//
225225
// The web documentation is ambiguous about the length. However,
@@ -516,7 +516,7 @@ func (mc *mysqlConn) readAuthResult() ([]byte, string, error) {
516516
}
517517
}
518518

519-
// Returns error if Packet is not an 'Result OK'-Packet
519+
// Returns error if Packet is not a 'Result OK'-Packet
520520
func (mc *okHandler) readResultOK() error {
521521
data, err := mc.conn().readPacket()
522522
if err != nil {
@@ -625,7 +625,7 @@ func (mc *mysqlConn) resultUnchanged() *okHandler {
625625
// Both return an instance of type *okHandler.
626626
type okHandler mysqlConn
627627

628-
// Exposees the underlying type's methods.
628+
// Exposes the underlying type's methods.
629629
func (mc *okHandler) conn() *mysqlConn {
630630
return (*mysqlConn)(mc)
631631
}

packets_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ var _ net.Conn = new(mockConn)
186186
// data[4] = 0x11
187187
// data[maxPacketSize+3] = 0x22
188188

189-
// // 2nd packet has payload length 0 and squence id 1
190-
// // 00 00 00 01
191-
// data[pkt2ofs+3] = 0x01
189+
// // 2nd packet has payload length 0 and sequence id 1
190+
// // 00 00 00 01
191+
// data[pkt2ofs+3] = 0x01
192192

193193
// conn.data = data
194194
// conn.maxReads = 3
@@ -218,9 +218,15 @@ var _ net.Conn = new(mockConn)
218218
// data[pkt2ofs+4] = 0x33
219219
// data[pkt2ofs+maxPacketSize+3] = 0x44
220220

221+
<<<<<<< HEAD
221222
// // 3rd packet has payload length 0 and squence id 2
222223
// // 00 00 00 02
223224
// data[pkt3ofs+3] = 0x02
225+
=======
226+
// 3rd packet has payload length 0 and sequence id 2
227+
// 00 00 00 02
228+
data[pkt3ofs+3] = 0x02
229+
>>>>>>> master
224230

225231
// conn.data = data
226232
// conn.reads = 0

0 commit comments

Comments
 (0)