@@ -614,7 +614,7 @@ func readStatus(b []byte) statusFlag {
614
614
}
615
615
616
616
// Ok Packet
617
- // http ://dev.mysql.com/doc/internals/en/generic-response-packets.html# packet-OK_Packet
617
+ // https ://dev.mysql.com/doc/internals/en/packet-OK_Packet.html
618
618
func (mc * mysqlConn ) handleOkPacket (data []byte ) error {
619
619
// 0x00 or 0xFE [1 byte]
620
620
n := 1
@@ -634,14 +634,19 @@ func (mc *mysqlConn) handleOkPacket(data []byte) error {
634
634
}
635
635
636
636
// warning count [2 bytes]
637
+ n += 2
637
638
638
639
return nil
639
640
}
640
641
641
642
// isEOFPacket will return true if the data is either a EOF-Packet or OK-Packet
642
643
// acting as an EOF.
643
- func isEOFPacket (data []byte ) bool {
644
- return data [0 ] == iEOF && len (data ) < 9
644
+ func (mc * mysqlConn ) isEOFPacket (data []byte ) bool {
645
+ // Legacy EOF packet
646
+ if data [0 ] == iEOF && (len (data ) == 5 || len (data ) == 1 ) && mc .flags & clientDeprecateEOF == 0 {
647
+ return true
648
+ }
649
+ return data [0 ] == iEOF && len (data ) < 9 && mc .flags & clientDeprecateEOF != 0
645
650
}
646
651
647
652
// Read Packets as Field Packets until EOF-Packet or an Error appears
@@ -655,7 +660,7 @@ func (mc *mysqlConn) readColumns(count int) ([]mysqlField, error) {
655
660
return nil , err
656
661
}
657
662
658
- if mc .flags & clientDeprecateEOF == 0 && isEOFPacket (data ) {
663
+ if mc .isEOFPacket (data ) {
659
664
if i == count {
660
665
return columns , nil
661
666
}
@@ -759,7 +764,7 @@ func (rows *textRows) readRow(dest []driver.Value) error {
759
764
}
760
765
761
766
// EOF Packet
762
- if isEOFPacket (data ) {
767
+ if mc . isEOFPacket (data ) {
763
768
if mc .flags & clientDeprecateEOF == 0 {
764
769
// server_status [2 bytes]
765
770
rows .mc .status = readStatus (data [3 :])
@@ -830,7 +835,7 @@ func (mc *mysqlConn) readUntilEOF() error {
830
835
switch {
831
836
case data [0 ] == iERR :
832
837
return mc .handleErrorPacket (data )
833
- case isEOFPacket (data ):
838
+ case mc . isEOFPacket (data ):
834
839
if mc .flags & clientDeprecateEOF == 0 {
835
840
mc .status = readStatus (data [3 :])
836
841
} else {
@@ -857,7 +862,7 @@ func (mc *mysqlConn) readPackets(num int) error {
857
862
switch {
858
863
case data [0 ] == iERR :
859
864
return mc .handleErrorPacket (data )
860
- case mc .flags & clientDeprecateEOF == 0 && isEOFPacket (data ):
865
+ case mc .isEOFPacket (data ):
861
866
mc .status = readStatus (data [3 :])
862
867
return nil
863
868
}
@@ -1223,7 +1228,7 @@ func (rows *binaryRows) readRow(dest []driver.Value) error {
1223
1228
1224
1229
// packet indicator [1 byte]
1225
1230
if data [0 ] != iOK {
1226
- if isEOFPacket (data ) {
1231
+ if rows . mc . isEOFPacket (data ) {
1227
1232
if rows .mc .flags & clientDeprecateEOF == 0 {
1228
1233
rows .mc .status = readStatus (data [3 :])
1229
1234
} else {
0 commit comments