File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -915,20 +915,29 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
915
915
}
916
916
917
917
case []byte :
918
- paramTypes [i + i ] = fieldTypeString
919
- paramTypes [i + i + 1 ] = 0x00
920
-
921
- if len (v ) < mc .maxPacketAllowed - pos - len (paramValues )- (len (args )- (i + 1 ))* 64 {
922
- paramValues = appendLengthEncodedInteger (paramValues ,
923
- uint64 (len (v )),
924
- )
925
- paramValues = append (paramValues , v ... )
926
- } else {
927
- if err := stmt .writeCommandLongData (i , v ); err != nil {
928
- return err
918
+ // Common case (non-nil value) first
919
+ if v != nil {
920
+ paramTypes [i + i ] = fieldTypeString
921
+ paramTypes [i + i + 1 ] = 0x00
922
+
923
+ if len (v ) < mc .maxPacketAllowed - pos - len (paramValues )- (len (args )- (i + 1 ))* 64 {
924
+ paramValues = appendLengthEncodedInteger (paramValues ,
925
+ uint64 (len (v )),
926
+ )
927
+ paramValues = append (paramValues , v ... )
928
+ } else {
929
+ if err := stmt .writeCommandLongData (i , v ); err != nil {
930
+ return err
931
+ }
929
932
}
933
+ continue
930
934
}
931
935
936
+ // Handle []byte(nil) as a NULL value
937
+ nullMask |= 1 << uint (i )
938
+ paramTypes [i + i ] = fieldTypeNULL
939
+ paramTypes [i + i + 1 ] = 0x00
940
+
932
941
case string :
933
942
paramTypes [i + i ] = fieldTypeString
934
943
paramTypes [i + i + 1 ] = 0x00
You can’t perform that action at this time.
0 commit comments