mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-30 15:02:08 -08:00
dependency upgrades for v2.18 release cycle (#2314)
This commit is contained in:
parent
462e568f00
commit
748700877e
134 changed files with 7198 additions and 1595 deletions
60
vendor/github.com/go-sql-driver/mysql/utils.go
generated
vendored
60
vendor/github.com/go-sql-driver/mysql/utils.go
generated
vendored
|
|
@ -36,7 +36,7 @@ var (
|
|||
// registering it.
|
||||
//
|
||||
// rootCertPool := x509.NewCertPool()
|
||||
// pem, err := ioutil.ReadFile("/path/ca-cert.pem")
|
||||
// pem, err := os.ReadFile("/path/ca-cert.pem")
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
|
|
@ -265,7 +265,11 @@ func parseBinaryDateTime(num uint64, data []byte, loc *time.Location) (driver.Va
|
|||
return nil, fmt.Errorf("invalid DATETIME packet length %d", num)
|
||||
}
|
||||
|
||||
func appendDateTime(buf []byte, t time.Time) ([]byte, error) {
|
||||
func appendDateTime(buf []byte, t time.Time, timeTruncate time.Duration) ([]byte, error) {
|
||||
if timeTruncate > 0 {
|
||||
t = t.Truncate(timeTruncate)
|
||||
}
|
||||
|
||||
year, month, day := t.Date()
|
||||
hour, min, sec := t.Clock()
|
||||
nsec := t.Nanosecond()
|
||||
|
|
@ -486,17 +490,16 @@ func formatBinaryTime(src []byte, length uint8) (driver.Value, error) {
|
|||
* Convert from and to bytes *
|
||||
******************************************************************************/
|
||||
|
||||
func uint64ToBytes(n uint64) []byte {
|
||||
return []byte{
|
||||
byte(n),
|
||||
byte(n >> 8),
|
||||
byte(n >> 16),
|
||||
byte(n >> 24),
|
||||
byte(n >> 32),
|
||||
byte(n >> 40),
|
||||
byte(n >> 48),
|
||||
byte(n >> 56),
|
||||
}
|
||||
// 24bit integer: used for packet headers.
|
||||
|
||||
func putUint24(data []byte, n int) {
|
||||
data[2] = byte(n >> 16)
|
||||
data[1] = byte(n >> 8)
|
||||
data[0] = byte(n)
|
||||
}
|
||||
|
||||
func getUint24(data []byte) int {
|
||||
return int(data[2])<<16 | int(data[1])<<8 | int(data[0])
|
||||
}
|
||||
|
||||
func uint64ToString(n uint64) []byte {
|
||||
|
|
@ -521,16 +524,6 @@ func uint64ToString(n uint64) []byte {
|
|||
return a[i:]
|
||||
}
|
||||
|
||||
// treats string value as unsigned integer representation
|
||||
func stringToInt(b []byte) int {
|
||||
val := 0
|
||||
for i := range b {
|
||||
val *= 10
|
||||
val += int(b[i] - 0x30)
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// returns the string read as a bytes slice, whether the value is NULL,
|
||||
// the number of bytes read and an error, in case the string is longer than
|
||||
// the input slice
|
||||
|
|
@ -582,18 +575,15 @@ func readLengthEncodedInteger(b []byte) (uint64, bool, int) {
|
|||
|
||||
// 252: value of following 2
|
||||
case 0xfc:
|
||||
return uint64(b[1]) | uint64(b[2])<<8, false, 3
|
||||
return uint64(binary.LittleEndian.Uint16(b[1:])), false, 3
|
||||
|
||||
// 253: value of following 3
|
||||
case 0xfd:
|
||||
return uint64(b[1]) | uint64(b[2])<<8 | uint64(b[3])<<16, false, 4
|
||||
return uint64(getUint24(b[1:])), false, 4
|
||||
|
||||
// 254: value of following 8
|
||||
case 0xfe:
|
||||
return uint64(b[1]) | uint64(b[2])<<8 | uint64(b[3])<<16 |
|
||||
uint64(b[4])<<24 | uint64(b[5])<<32 | uint64(b[6])<<40 |
|
||||
uint64(b[7])<<48 | uint64(b[8])<<56,
|
||||
false, 9
|
||||
return uint64(binary.LittleEndian.Uint64(b[1:])), false, 9
|
||||
}
|
||||
|
||||
// 0-250: value of first byte
|
||||
|
|
@ -607,13 +597,19 @@ func appendLengthEncodedInteger(b []byte, n uint64) []byte {
|
|||
return append(b, byte(n))
|
||||
|
||||
case n <= 0xffff:
|
||||
return append(b, 0xfc, byte(n), byte(n>>8))
|
||||
b = append(b, 0xfc)
|
||||
return binary.LittleEndian.AppendUint16(b, uint16(n))
|
||||
|
||||
case n <= 0xffffff:
|
||||
return append(b, 0xfd, byte(n), byte(n>>8), byte(n>>16))
|
||||
}
|
||||
return append(b, 0xfe, byte(n), byte(n>>8), byte(n>>16), byte(n>>24),
|
||||
byte(n>>32), byte(n>>40), byte(n>>48), byte(n>>56))
|
||||
b = append(b, 0xfe)
|
||||
return binary.LittleEndian.AppendUint64(b, n)
|
||||
}
|
||||
|
||||
func appendLengthEncodedString(b []byte, s string) []byte {
|
||||
b = appendLengthEncodedInteger(b, uint64(len(s)))
|
||||
return append(b, s...)
|
||||
}
|
||||
|
||||
// reserveBuffer checks cap(buf) and expand buffer to len(buf) + appendSize.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue