@@ -868,18 +868,21 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
868
868
for i := range args {
869
869
// build NULL-bitmap
870
870
if args [i ] == nil {
871
- nullMask + = 1 << uint (i )
871
+ nullMask | = 1 << uint (i )
872
872
paramTypes [i + i ] = fieldTypeNULL
873
+ paramTypes [i + i + 1 ] = 0x00
873
874
continue
874
875
}
875
876
876
877
// cache types and values
877
878
switch v := args [i ].(type ) {
878
879
case int64 :
879
880
paramTypes [i + i ] = fieldTypeLongLong
881
+ paramTypes [i + i + 1 ] = 0x00
882
+
880
883
if cap (paramValues )- len (paramValues )- 8 >= 0 {
881
884
paramValues = paramValues [:len (paramValues )+ 8 ]
882
- binary .LittleEndian .PutUint64 (paramValues , uint64 (v ))
885
+ binary .LittleEndian .PutUint64 (paramValues [ len ( paramValues ) - 8 :] , uint64 (v ))
883
886
} else {
884
887
paramValues = append (paramValues ,
885
888
uint64ToBytes (uint64 (v ))... ,
@@ -888,9 +891,11 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
888
891
889
892
case float64 :
890
893
paramTypes [i + i ] = fieldTypeDouble
894
+ paramTypes [i + i + 1 ] = 0x00
895
+
891
896
if cap (paramValues )- len (paramValues )- 8 >= 0 {
892
897
paramValues = paramValues [:len (paramValues )+ 8 ]
893
- binary .LittleEndian .PutUint64 (paramValues , math .Float64bits (v ))
898
+ binary .LittleEndian .PutUint64 (paramValues [ len ( paramValues ) - 8 :] , math .Float64bits (v ))
894
899
} else {
895
900
paramValues = append (paramValues ,
896
901
uint64ToBytes (math .Float64bits (v ))... ,
@@ -899,6 +904,8 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
899
904
900
905
case bool :
901
906
paramTypes [i + i ] = fieldTypeTiny
907
+ paramTypes [i + i + 1 ] = 0x00
908
+
902
909
if v {
903
910
paramValues = append (paramValues , 0x01 )
904
911
} else {
@@ -907,6 +914,8 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
907
914
908
915
case []byte :
909
916
paramTypes [i + i ] = fieldTypeString
917
+ paramTypes [i + i + 1 ] = 0x00
918
+
910
919
if len (v ) < stmt .mc .maxPacketAllowed - pos - len (paramValues )- (len (args )- (i + 1 ))* 64 {
911
920
paramValues = append (paramValues ,
912
921
lengthEncodedIntegerToBytes (uint64 (len (v )))... ,
@@ -920,6 +929,8 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
920
929
921
930
case string :
922
931
paramTypes [i + i ] = fieldTypeString
932
+ paramTypes [i + i + 1 ] = 0x00
933
+
923
934
if len (v ) < stmt .mc .maxPacketAllowed - pos - len (paramValues )- (len (args )- (i + 1 ))* 64 {
924
935
paramValues = append (paramValues ,
925
936
lengthEncodedIntegerToBytes (uint64 (len (v )))... ,
@@ -933,6 +944,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
933
944
934
945
case time.Time :
935
946
paramTypes [i + i ] = fieldTypeString
947
+ paramTypes [i + i + 1 ] = 0x00
936
948
937
949
var val []byte
938
950
if v .IsZero () {
0 commit comments