@@ -868,18 +868,21 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
868868 for i := range args {
869869 // build NULL-bitmap
870870 if args [i ] == nil {
871- nullMask + = 1 << uint (i )
871+ nullMask | = 1 << uint (i )
872872 paramTypes [i + i ] = fieldTypeNULL
873+ paramTypes [i + i + 1 ] = 0x00
873874 continue
874875 }
875876
876877 // cache types and values
877878 switch v := args [i ].(type ) {
878879 case int64 :
879880 paramTypes [i + i ] = fieldTypeLongLong
881+ paramTypes [i + i + 1 ] = 0x00
882+
880883 if cap (paramValues )- len (paramValues )- 8 >= 0 {
881884 paramValues = paramValues [:len (paramValues )+ 8 ]
882- binary .LittleEndian .PutUint64 (paramValues , uint64 (v ))
885+ binary .LittleEndian .PutUint64 (paramValues [ len ( paramValues ) - 8 :] , uint64 (v ))
883886 } else {
884887 paramValues = append (paramValues ,
885888 uint64ToBytes (uint64 (v ))... ,
@@ -888,9 +891,11 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
888891
889892 case float64 :
890893 paramTypes [i + i ] = fieldTypeDouble
894+ paramTypes [i + i + 1 ] = 0x00
895+
891896 if cap (paramValues )- len (paramValues )- 8 >= 0 {
892897 paramValues = paramValues [:len (paramValues )+ 8 ]
893- binary .LittleEndian .PutUint64 (paramValues , math .Float64bits (v ))
898+ binary .LittleEndian .PutUint64 (paramValues [ len ( paramValues ) - 8 :] , math .Float64bits (v ))
894899 } else {
895900 paramValues = append (paramValues ,
896901 uint64ToBytes (math .Float64bits (v ))... ,
@@ -899,6 +904,8 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
899904
900905 case bool :
901906 paramTypes [i + i ] = fieldTypeTiny
907+ paramTypes [i + i + 1 ] = 0x00
908+
902909 if v {
903910 paramValues = append (paramValues , 0x01 )
904911 } else {
@@ -907,6 +914,8 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
907914
908915 case []byte :
909916 paramTypes [i + i ] = fieldTypeString
917+ paramTypes [i + i + 1 ] = 0x00
918+
910919 if len (v ) < stmt .mc .maxPacketAllowed - pos - len (paramValues )- (len (args )- (i + 1 ))* 64 {
911920 paramValues = append (paramValues ,
912921 lengthEncodedIntegerToBytes (uint64 (len (v )))... ,
@@ -920,6 +929,8 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
920929
921930 case string :
922931 paramTypes [i + i ] = fieldTypeString
932+ paramTypes [i + i + 1 ] = 0x00
933+
923934 if len (v ) < stmt .mc .maxPacketAllowed - pos - len (paramValues )- (len (args )- (i + 1 ))* 64 {
924935 paramValues = append (paramValues ,
925936 lengthEncodedIntegerToBytes (uint64 (len (v )))... ,
@@ -933,6 +944,7 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
933944
934945 case time.Time :
935946 paramTypes [i + i ] = fieldTypeString
947+ paramTypes [i + i + 1 ] = 0x00
936948
937949 var val []byte
938950 if v .IsZero () {
0 commit comments