mirror of
https://github.com/documize/community.git
synced 2025-07-20 05:39:42 +02:00
WIP vendored dep upgrades
This commit is contained in:
parent
5f59e95495
commit
6409ad0d63
190 changed files with 64265 additions and 109666 deletions
85
vendor/github.com/go-sql-driver/mysql/packets.go
generated
vendored
85
vendor/github.com/go-sql-driver/mysql/packets.go
generated
vendored
|
@ -35,7 +35,7 @@ func (mc *mysqlConn) readPacket() ([]byte, error) {
|
|||
}
|
||||
errLog.Print(err)
|
||||
mc.Close()
|
||||
return nil, driver.ErrBadConn
|
||||
return nil, ErrInvalidConn
|
||||
}
|
||||
|
||||
// packet length [24 bit]
|
||||
|
@ -57,7 +57,7 @@ func (mc *mysqlConn) readPacket() ([]byte, error) {
|
|||
if prevData == nil {
|
||||
errLog.Print(ErrMalformPkt)
|
||||
mc.Close()
|
||||
return nil, driver.ErrBadConn
|
||||
return nil, ErrInvalidConn
|
||||
}
|
||||
|
||||
return prevData, nil
|
||||
|
@ -71,7 +71,7 @@ func (mc *mysqlConn) readPacket() ([]byte, error) {
|
|||
}
|
||||
errLog.Print(err)
|
||||
mc.Close()
|
||||
return nil, driver.ErrBadConn
|
||||
return nil, ErrInvalidConn
|
||||
}
|
||||
|
||||
// return data if this was the last packet
|
||||
|
@ -137,10 +137,14 @@ func (mc *mysqlConn) writePacket(data []byte) error {
|
|||
if cerr := mc.canceled.Value(); cerr != nil {
|
||||
return cerr
|
||||
}
|
||||
if n == 0 && pktLen == len(data)-4 {
|
||||
// only for the first loop iteration when nothing was written yet
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
mc.cleanup()
|
||||
errLog.Print(err)
|
||||
}
|
||||
return driver.ErrBadConn
|
||||
return ErrInvalidConn
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,7 +278,7 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
|
|||
if data == nil {
|
||||
// can not take the buffer. Something must be wrong with the connection
|
||||
errLog.Print(ErrBusyBuffer)
|
||||
return driver.ErrBadConn
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
|
||||
// ClientFlags [32 bit]
|
||||
|
@ -352,7 +356,9 @@ func (mc *mysqlConn) writeAuthPacket(cipher []byte) error {
|
|||
// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::AuthSwitchResponse
|
||||
func (mc *mysqlConn) writeOldAuthPacket(cipher []byte) error {
|
||||
// User password
|
||||
scrambleBuff := scrambleOldPassword(cipher, []byte(mc.cfg.Passwd))
|
||||
// https://dev.mysql.com/doc/internals/en/old-password-authentication.html
|
||||
// Old password authentication only need and will need 8-byte challenge.
|
||||
scrambleBuff := scrambleOldPassword(cipher[:8], []byte(mc.cfg.Passwd))
|
||||
|
||||
// Calculate the packet length and add a tailing 0
|
||||
pktLen := len(scrambleBuff) + 1
|
||||
|
@ -360,7 +366,7 @@ func (mc *mysqlConn) writeOldAuthPacket(cipher []byte) error {
|
|||
if data == nil {
|
||||
// can not take the buffer. Something must be wrong with the connection
|
||||
errLog.Print(ErrBusyBuffer)
|
||||
return driver.ErrBadConn
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
|
||||
// Add the scrambled password [null terminated string]
|
||||
|
@ -379,7 +385,7 @@ func (mc *mysqlConn) writeClearAuthPacket() error {
|
|||
if data == nil {
|
||||
// can not take the buffer. Something must be wrong with the connection
|
||||
errLog.Print(ErrBusyBuffer)
|
||||
return driver.ErrBadConn
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
|
||||
// Add the clear password [null terminated string]
|
||||
|
@ -392,7 +398,9 @@ func (mc *mysqlConn) writeClearAuthPacket() error {
|
|||
// Native password authentication method
|
||||
// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::AuthSwitchResponse
|
||||
func (mc *mysqlConn) writeNativeAuthPacket(cipher []byte) error {
|
||||
scrambleBuff := scramblePassword(cipher, []byte(mc.cfg.Passwd))
|
||||
// https://dev.mysql.com/doc/internals/en/secure-password-authentication.html
|
||||
// Native password authentication only need and will need 20-byte challenge.
|
||||
scrambleBuff := scramblePassword(cipher[0:20], []byte(mc.cfg.Passwd))
|
||||
|
||||
// Calculate the packet length and add a tailing 0
|
||||
pktLen := len(scrambleBuff)
|
||||
|
@ -400,7 +408,7 @@ func (mc *mysqlConn) writeNativeAuthPacket(cipher []byte) error {
|
|||
if data == nil {
|
||||
// can not take the buffer. Something must be wrong with the connection
|
||||
errLog.Print(ErrBusyBuffer)
|
||||
return driver.ErrBadConn
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
|
||||
// Add the scramble
|
||||
|
@ -421,7 +429,7 @@ func (mc *mysqlConn) writeCommandPacket(command byte) error {
|
|||
if data == nil {
|
||||
// can not take the buffer. Something must be wrong with the connection
|
||||
errLog.Print(ErrBusyBuffer)
|
||||
return driver.ErrBadConn
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
|
||||
// Add command byte
|
||||
|
@ -440,7 +448,7 @@ func (mc *mysqlConn) writeCommandPacketStr(command byte, arg string) error {
|
|||
if data == nil {
|
||||
// can not take the buffer. Something must be wrong with the connection
|
||||
errLog.Print(ErrBusyBuffer)
|
||||
return driver.ErrBadConn
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
|
||||
// Add command byte
|
||||
|
@ -461,7 +469,7 @@ func (mc *mysqlConn) writeCommandPacketUint32(command byte, arg uint32) error {
|
|||
if data == nil {
|
||||
// can not take the buffer. Something must be wrong with the connection
|
||||
errLog.Print(ErrBusyBuffer)
|
||||
return driver.ErrBadConn
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
|
||||
// Add command byte
|
||||
|
@ -495,7 +503,7 @@ func (mc *mysqlConn) readResultOK() ([]byte, error) {
|
|||
if len(data) > 1 {
|
||||
pluginEndIndex := bytes.IndexByte(data, 0x00)
|
||||
plugin := string(data[1:pluginEndIndex])
|
||||
cipher := data[pluginEndIndex+1 : len(data)-1]
|
||||
cipher := data[pluginEndIndex+1:]
|
||||
|
||||
switch plugin {
|
||||
case "mysql_old_password":
|
||||
|
@ -563,7 +571,8 @@ func (mc *mysqlConn) handleErrorPacket(data []byte) error {
|
|||
errno := binary.LittleEndian.Uint16(data[1:3])
|
||||
|
||||
// 1792: ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
|
||||
if errno == 1792 && mc.cfg.RejectReadOnly {
|
||||
// 1290: ER_OPTION_PREVENTS_STATEMENT (returned by Aurora during failover)
|
||||
if (errno == 1792 || errno == 1290) && mc.cfg.RejectReadOnly {
|
||||
// Oops; we are connected to a read-only connection, and won't be able
|
||||
// to issue any write statements. Since RejectReadOnly is configured,
|
||||
// we throw away this connection hoping this one would have write
|
||||
|
@ -616,14 +625,7 @@ func (mc *mysqlConn) handleOkPacket(data []byte) error {
|
|||
}
|
||||
|
||||
// warning count [2 bytes]
|
||||
if !mc.strict {
|
||||
return nil
|
||||
}
|
||||
|
||||
pos := 1 + n + m + 2
|
||||
if binary.LittleEndian.Uint16(data[pos:pos+2]) > 0 {
|
||||
return mc.getWarnings()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -695,14 +697,21 @@ func (mc *mysqlConn) readColumns(count int) ([]mysqlField, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pos += n
|
||||
|
||||
// Filler [uint8]
|
||||
pos++
|
||||
|
||||
// Charset [charset, collation uint8]
|
||||
columns[i].charSet = data[pos]
|
||||
pos += 2
|
||||
|
||||
// Length [uint32]
|
||||
pos += n + 1 + 2 + 4
|
||||
columns[i].length = binary.LittleEndian.Uint32(data[pos : pos+4])
|
||||
pos += 4
|
||||
|
||||
// Field type [uint8]
|
||||
columns[i].fieldType = data[pos]
|
||||
columns[i].fieldType = fieldType(data[pos])
|
||||
pos++
|
||||
|
||||
// Flags [uint16]
|
||||
|
@ -835,14 +844,7 @@ func (stmt *mysqlStmt) readPrepareResultPacket() (uint16, error) {
|
|||
// Reserved [8 bit]
|
||||
|
||||
// Warning count [16 bit uint]
|
||||
if !stmt.mc.strict {
|
||||
return columnCount, nil
|
||||
}
|
||||
|
||||
// Check for warnings count > 0, only available in MySQL > 4.1
|
||||
if len(data) >= 12 && binary.LittleEndian.Uint16(data[10:12]) > 0 {
|
||||
return columnCount, stmt.mc.getWarnings()
|
||||
}
|
||||
return columnCount, nil
|
||||
}
|
||||
return 0, err
|
||||
|
@ -927,7 +929,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
|
|||
if data == nil {
|
||||
// can not take the buffer. Something must be wrong with the connection
|
||||
errLog.Print(ErrBusyBuffer)
|
||||
return driver.ErrBadConn
|
||||
return errBadConnNoWrite
|
||||
}
|
||||
|
||||
// command [1 byte]
|
||||
|
@ -986,7 +988,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
|
|||
// build NULL-bitmap
|
||||
if arg == nil {
|
||||
nullMask[i/8] |= 1 << (uint(i) & 7)
|
||||
paramTypes[i+i] = fieldTypeNULL
|
||||
paramTypes[i+i] = byte(fieldTypeNULL)
|
||||
paramTypes[i+i+1] = 0x00
|
||||
continue
|
||||
}
|
||||
|
@ -994,7 +996,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
|
|||
// cache types and values
|
||||
switch v := arg.(type) {
|
||||
case int64:
|
||||
paramTypes[i+i] = fieldTypeLongLong
|
||||
paramTypes[i+i] = byte(fieldTypeLongLong)
|
||||
paramTypes[i+i+1] = 0x00
|
||||
|
||||
if cap(paramValues)-len(paramValues)-8 >= 0 {
|
||||
|
@ -1010,7 +1012,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
|
|||
}
|
||||
|
||||
case float64:
|
||||
paramTypes[i+i] = fieldTypeDouble
|
||||
paramTypes[i+i] = byte(fieldTypeDouble)
|
||||
paramTypes[i+i+1] = 0x00
|
||||
|
||||
if cap(paramValues)-len(paramValues)-8 >= 0 {
|
||||
|
@ -1026,7 +1028,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
|
|||
}
|
||||
|
||||
case bool:
|
||||
paramTypes[i+i] = fieldTypeTiny
|
||||
paramTypes[i+i] = byte(fieldTypeTiny)
|
||||
paramTypes[i+i+1] = 0x00
|
||||
|
||||
if v {
|
||||
|
@ -1038,7 +1040,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
|
|||
case []byte:
|
||||
// Common case (non-nil value) first
|
||||
if v != nil {
|
||||
paramTypes[i+i] = fieldTypeString
|
||||
paramTypes[i+i] = byte(fieldTypeString)
|
||||
paramTypes[i+i+1] = 0x00
|
||||
|
||||
if len(v) < mc.maxAllowedPacket-pos-len(paramValues)-(len(args)-(i+1))*64 {
|
||||
|
@ -1056,11 +1058,11 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
|
|||
|
||||
// Handle []byte(nil) as a NULL value
|
||||
nullMask[i/8] |= 1 << (uint(i) & 7)
|
||||
paramTypes[i+i] = fieldTypeNULL
|
||||
paramTypes[i+i] = byte(fieldTypeNULL)
|
||||
paramTypes[i+i+1] = 0x00
|
||||
|
||||
case string:
|
||||
paramTypes[i+i] = fieldTypeString
|
||||
paramTypes[i+i] = byte(fieldTypeString)
|
||||
paramTypes[i+i+1] = 0x00
|
||||
|
||||
if len(v) < mc.maxAllowedPacket-pos-len(paramValues)-(len(args)-(i+1))*64 {
|
||||
|
@ -1075,7 +1077,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
|
|||
}
|
||||
|
||||
case time.Time:
|
||||
paramTypes[i+i] = fieldTypeString
|
||||
paramTypes[i+i] = byte(fieldTypeString)
|
||||
paramTypes[i+i+1] = 0x00
|
||||
|
||||
var a [64]byte
|
||||
|
@ -1149,10 +1151,11 @@ func (rows *binaryRows) readRow(dest []driver.Value) error {
|
|||
}
|
||||
return io.EOF
|
||||
}
|
||||
mc := rows.mc
|
||||
rows.mc = nil
|
||||
|
||||
// Error otherwise
|
||||
return rows.mc.handleErrorPacket(data)
|
||||
return mc.handleErrorPacket(data)
|
||||
}
|
||||
|
||||
// NULL-bitmap, [(column-count + 7 + 2) / 8 bytes]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue