fix protocol out of sync when error happens while load local infile.
This commit is contained in:
@@ -1327,7 +1327,11 @@ class MySQLResult(object):
|
|||||||
def _read_load_local_packet(self, first_packet):
|
def _read_load_local_packet(self, first_packet):
|
||||||
load_packet = LoadLocalPacketWrapper(first_packet)
|
load_packet = LoadLocalPacketWrapper(first_packet)
|
||||||
sender = LoadLocalFile(load_packet.filename, self.connection)
|
sender = LoadLocalFile(load_packet.filename, self.connection)
|
||||||
|
try:
|
||||||
sender.send_data()
|
sender.send_data()
|
||||||
|
except:
|
||||||
|
self.connection._read_packet() # skip ok packet
|
||||||
|
raise
|
||||||
|
|
||||||
ok_packet = self.connection._read_packet()
|
ok_packet = self.connection._read_packet()
|
||||||
if not ok_packet.is_ok_packet(): # pragma: no cover - upstream induced protocol error
|
if not ok_packet.is_ok_packet(): # pragma: no cover - upstream induced protocol error
|
||||||
@@ -1448,7 +1452,7 @@ class LoadLocalFile(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(self.filename, 'rb') as open_file:
|
with open(self.filename, 'rb') as open_file:
|
||||||
chunk_size = self.connection.max_allowed_packet
|
chunk_size = conn.max_allowed_packet
|
||||||
packet = b""
|
packet = b""
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class TestLoadLocal(base.PyMySQLTestCase):
|
|||||||
self.assertTrue("Incorrect integer value" in str(w[-1].message))
|
self.assertTrue("Incorrect integer value" in str(w[-1].message))
|
||||||
finally:
|
finally:
|
||||||
c.execute("DROP TABLE test_load_local")
|
c.execute("DROP TABLE test_load_local")
|
||||||
|
c.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user