Support DEPRECATE_EOF (#433)
This commit is contained in:
parent
c33b17d325
commit
308e835058
|
@ -363,17 +363,18 @@ class MysqlPacket(object):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def is_ok_packet(self):
|
def is_ok_packet(self):
|
||||||
return self._data[0:1] == b'\0'
|
# https://dev.mysql.com/doc/internals/en/packet-OK_Packet.html
|
||||||
|
return self._data[0:1] == b'\0' and len(self._data) >= 7
|
||||||
def is_auth_switch_request(self):
|
|
||||||
# http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::AuthSwitchRequest
|
|
||||||
return self._data[0:1] == b'\xfe'
|
|
||||||
|
|
||||||
def is_eof_packet(self):
|
def is_eof_packet(self):
|
||||||
# http://dev.mysql.com/doc/internals/en/generic-response-packets.html#packet-EOF_Packet
|
# http://dev.mysql.com/doc/internals/en/generic-response-packets.html#packet-EOF_Packet
|
||||||
# Caution: \xFE may be LengthEncodedInteger.
|
# Caution: \xFE may be LengthEncodedInteger.
|
||||||
# If \xFE is LengthEncodedInteger header, 8bytes followed.
|
# If \xFE is LengthEncodedInteger header, 8bytes followed.
|
||||||
return len(self._data) < 9 and self._data[0:1] == b'\xfe'
|
return self._data[0:1] == b'\xfe' and len(self._data) < 9
|
||||||
|
|
||||||
|
def is_auth_switch_request(self):
|
||||||
|
# http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::AuthSwitchRequest
|
||||||
|
return self._data[0:1] == b'\xfe'
|
||||||
|
|
||||||
def is_resultset_packet(self):
|
def is_resultset_packet(self):
|
||||||
field_count = ord(self._data[0:1])
|
field_count = ord(self._data[0:1])
|
||||||
|
@ -1357,11 +1358,14 @@ class MySQLResult(object):
|
||||||
|
|
||||||
def _check_packet_is_eof(self, packet):
|
def _check_packet_is_eof(self, packet):
|
||||||
if packet.is_eof_packet():
|
if packet.is_eof_packet():
|
||||||
eof_packet = EOFPacketWrapper(packet)
|
wp = EOFPacketWrapper(packet)
|
||||||
self.warning_count = eof_packet.warning_count
|
elif packet.is_ok_packet():
|
||||||
self.has_next = eof_packet.has_next
|
wp = OKPacketWrapper(packet)
|
||||||
return True
|
else:
|
||||||
return False
|
return False
|
||||||
|
self.warning_count = wp.warning_count
|
||||||
|
self.has_next = wp.has_next
|
||||||
|
return True
|
||||||
|
|
||||||
def _read_result_packet(self, first_packet):
|
def _read_result_packet(self, first_packet):
|
||||||
self.field_count = first_packet.read_length_encoded_integer()
|
self.field_count = first_packet.read_length_encoded_integer()
|
||||||
|
@ -1466,7 +1470,7 @@ class MySQLResult(object):
|
||||||
self.converters.append((encoding, converter))
|
self.converters.append((encoding, converter))
|
||||||
|
|
||||||
eof_packet = self.connection._read_packet()
|
eof_packet = self.connection._read_packet()
|
||||||
assert eof_packet.is_eof_packet(), 'Protocol error, expecting EOF'
|
assert eof_packet.is_eof_packet() or eof_packet.is_ok_packet, 'Protocol error, expecting EOF'
|
||||||
self.description = tuple(description)
|
self.description = tuple(description)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,4 @@ CAPABILITIES = (LONG_PASSWORD | LONG_FLAG | TRANSACTIONS |
|
||||||
CONNECT_ATTRS = 1 << 20
|
CONNECT_ATTRS = 1 << 20
|
||||||
HANDLE_EXPIRED_PASSWORDS = 1 << 22
|
HANDLE_EXPIRED_PASSWORDS = 1 << 22
|
||||||
SESSION_TRACK = 1 << 23
|
SESSION_TRACK = 1 << 23
|
||||||
CLIENT_DEPRECATE_EOF = 1 << 24
|
DEPRECATE_EOF = 1 << 24
|
||||||
|
|
Loading…
Reference in New Issue