@@ -434,7 +434,7 @@ func (mc *mysqlConn) readColumns(count int) (columns []mysqlField, err error) {
434
434
pos += n + 1 + 2 + 4
435
435
436
436
// Field type [byte]
437
- columns [i ].fieldType = FieldType ( data [pos ])
437
+ columns [i ].fieldType = data [pos ]
438
438
pos ++
439
439
440
440
// Flags [16 bit uint]
@@ -561,26 +561,26 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
561
561
// build NULL-bitmap
562
562
if args [i ] == nil {
563
563
bitMask += 1 << uint (i )
564
- paramTypes [i << 1 ] = byte ( FIELD_TYPE_NULL )
564
+ paramTypes [i << 1 ] = FIELD_TYPE_NULL
565
565
continue
566
566
}
567
567
568
568
// cache types and values
569
569
switch args [i ].(type ) {
570
570
case int64 :
571
- paramTypes [i << 1 ] = byte ( FIELD_TYPE_LONGLONG )
571
+ paramTypes [i << 1 ] = FIELD_TYPE_LONGLONG
572
572
paramValues [i ] = uint64ToBytes (uint64 (args [i ].(int64 )))
573
573
pktLen += 8
574
574
continue
575
575
576
576
case float64 :
577
- paramTypes [i << 1 ] = byte ( FIELD_TYPE_DOUBLE )
577
+ paramTypes [i << 1 ] = FIELD_TYPE_DOUBLE
578
578
paramValues [i ] = uint64ToBytes (math .Float64bits (args [i ].(float64 )))
579
579
pktLen += 8
580
580
continue
581
581
582
582
case bool :
583
- paramTypes [i << 1 ] = byte ( FIELD_TYPE_TINY )
583
+ paramTypes [i << 1 ] = FIELD_TYPE_TINY
584
584
pktLen ++
585
585
if args [i ].(bool ) {
586
586
paramValues [i ] = []byte {0x01 }
@@ -590,7 +590,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
590
590
continue
591
591
592
592
case []byte :
593
- paramTypes [i << 1 ] = byte ( FIELD_TYPE_STRING )
593
+ paramTypes [i << 1 ] = FIELD_TYPE_STRING
594
594
val := args [i ].([]byte )
595
595
paramValues [i ] = append (
596
596
lengthEncodedIntegerToBytes (uint64 (len (val ))),
@@ -600,7 +600,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
600
600
continue
601
601
602
602
case string :
603
- paramTypes [i << 1 ] = byte ( FIELD_TYPE_STRING )
603
+ paramTypes [i << 1 ] = FIELD_TYPE_STRING
604
604
val := []byte (args [i ].(string ))
605
605
paramValues [i ] = append (
606
606
lengthEncodedIntegerToBytes (uint64 (len (val ))),
@@ -610,7 +610,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
610
610
continue
611
611
612
612
case time.Time :
613
- paramTypes [i << 1 ] = byte ( FIELD_TYPE_STRING )
613
+ paramTypes [i << 1 ] = FIELD_TYPE_STRING
614
614
val := []byte (args [i ].(time.Time ).Format (TIME_FORMAT ))
615
615
paramValues [i ] = append (
616
616
lengthEncodedIntegerToBytes (uint64 (len (val ))),
@@ -718,7 +718,7 @@ func (rc *mysqlRows) readBinaryRow(dest []driver.Value) (err error) {
718
718
// Numeric Typs
719
719
case FIELD_TYPE_TINY :
720
720
if unsigned {
721
- dest [i ] = uint64 (data [pos ])
721
+ dest [i ] = int64 (data [pos ])
722
722
} else {
723
723
dest [i ] = int64 (int8 (data [pos ]))
724
724
}
@@ -727,7 +727,7 @@ func (rc *mysqlRows) readBinaryRow(dest []driver.Value) (err error) {
727
727
728
728
case FIELD_TYPE_SHORT , FIELD_TYPE_YEAR :
729
729
if unsigned {
730
- dest [i ] = uint64 (binary .LittleEndian .Uint16 (data [pos : pos + 2 ]))
730
+ dest [i ] = int64 (binary .LittleEndian .Uint16 (data [pos : pos + 2 ]))
731
731
} else {
732
732
dest [i ] = int64 (int16 (binary .LittleEndian .Uint16 (data [pos : pos + 2 ])))
733
733
}
@@ -736,7 +736,7 @@ func (rc *mysqlRows) readBinaryRow(dest []driver.Value) (err error) {
736
736
737
737
case FIELD_TYPE_INT24 , FIELD_TYPE_LONG :
738
738
if unsigned {
739
- dest [i ] = uint64 (binary .LittleEndian .Uint32 (data [pos : pos + 4 ]))
739
+ dest [i ] = int64 (binary .LittleEndian .Uint32 (data [pos : pos + 4 ]))
740
740
} else {
741
741
dest [i ] = int64 (int32 (binary .LittleEndian .Uint32 (data [pos : pos + 4 ])))
742
742
}
@@ -745,15 +745,20 @@ func (rc *mysqlRows) readBinaryRow(dest []driver.Value) (err error) {
745
745
746
746
case FIELD_TYPE_LONGLONG :
747
747
if unsigned {
748
- dest [i ] = binary .LittleEndian .Uint64 (data [pos : pos + 8 ])
748
+ val := binary .LittleEndian .Uint64 (data [pos : pos + 8 ])
749
+ if val > math .MaxInt64 {
750
+ dest [i ] = uint64ToString (val )
751
+ } else {
752
+ dest [i ] = int64 (val )
753
+ }
749
754
} else {
750
755
dest [i ] = int64 (binary .LittleEndian .Uint64 (data [pos : pos + 8 ]))
751
756
}
752
757
pos += 8
753
758
continue
754
759
755
760
case FIELD_TYPE_FLOAT :
756
- dest [i ] = math .Float32frombits (binary .LittleEndian .Uint32 (data [pos : pos + 4 ]))
761
+ dest [i ] = float64 ( math .Float32frombits (binary .LittleEndian .Uint32 (data [pos : pos + 4 ]) ))
757
762
pos += 4
758
763
continue
759
764
0 commit comments