Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pingcap/tidb into xhb/auto
Browse files Browse the repository at this point in the history
  • Loading branch information
Haibin Xie committed Aug 18, 2017
2 parents d400708 + 5340b67 commit f3a6191
Show file tree
Hide file tree
Showing 72 changed files with 2,098 additions and 1,042 deletions.
27 changes: 19 additions & 8 deletions _vendor/src/github.com/go-sql-driver/mysql/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

package mysql

import "io"
import (
"io"
"net"
"time"
)

const defaultBufSize = 4096

Expand All @@ -18,17 +22,18 @@ const defaultBufSize = 4096
// The buffer is similar to bufio.Reader / Writer but zero-copy-ish
// Also highly optimized for this particular use case.
type buffer struct {
buf []byte
rd io.Reader
idx int
length int
buf []byte
nc net.Conn
idx int
length int
timeout time.Duration
}

func newBuffer(rd io.Reader) buffer {
func newBuffer(nc net.Conn) buffer {
var b [defaultBufSize]byte
return buffer{
buf: b[:],
rd: rd,
nc: nc,
}
}

Expand All @@ -54,7 +59,13 @@ func (b *buffer) fill(need int) error {
b.idx = 0

for {
nn, err := b.rd.Read(b.buf[n:])
if b.timeout > 0 {
if err := b.nc.SetReadDeadline(time.Now().Add(b.timeout)); err != nil {
return err
}
}

nn, err := b.nc.Read(b.buf[n:])
n += nn

switch err {
Expand Down
22 changes: 11 additions & 11 deletions _vendor/src/github.com/go-sql-driver/mysql/collations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package mysql

const defaultCollation byte = 33 // utf8_general_ci
const defaultCollation = "utf8_general_ci"

// A list of available collations mapped to the internal ID.
// To update this map use the following MySQL query:
Expand Down Expand Up @@ -237,14 +237,14 @@ var collations = map[string]byte{

// A blacklist of collations which is unsafe to interpolate parameters.
// These multibyte encodings may contains 0x5c (`\`) in their trailing bytes.
var unsafeCollations = map[byte]bool{
1: true, // big5_chinese_ci
13: true, // sjis_japanese_ci
28: true, // gbk_chinese_ci
84: true, // big5_bin
86: true, // gb2312_bin
87: true, // gbk_bin
88: true, // sjis_bin
95: true, // cp932_japanese_ci
96: true, // cp932_bin
var unsafeCollations = map[string]bool{
"big5_chinese_ci": true,
"sjis_japanese_ci": true,
"gbk_chinese_ci": true,
"big5_bin": true,
"gb2312_bin": true,
"gbk_bin": true,
"sjis_bin": true,
"cp932_japanese_ci": true,
"cp932_bin": true,
}
Loading

0 comments on commit f3a6191

Please sign in to comment.