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): | ||||
|         load_packet = LoadLocalPacketWrapper(first_packet) | ||||
|         sender = LoadLocalFile(load_packet.filename, self.connection) | ||||
|         try: | ||||
|             sender.send_data() | ||||
|         except: | ||||
|             self.connection._read_packet()  # skip ok packet | ||||
|             raise | ||||
|  | ||||
|         ok_packet = self.connection._read_packet() | ||||
|         if not ok_packet.is_ok_packet(): # pragma: no cover - upstream induced protocol error | ||||
| @@ -1448,7 +1452,7 @@ class LoadLocalFile(object): | ||||
|  | ||||
|         try: | ||||
|             with open(self.filename, 'rb') as open_file: | ||||
|                 chunk_size = self.connection.max_allowed_packet | ||||
|                 chunk_size = conn.max_allowed_packet | ||||
|                 packet = b"" | ||||
|  | ||||
|                 while True: | ||||
|   | ||||
| @@ -61,6 +61,7 @@ class TestLoadLocal(base.PyMySQLTestCase): | ||||
|                 self.assertTrue("Incorrect integer value" in str(w[-1].message)) | ||||
|         finally: | ||||
|             c.execute("DROP TABLE test_load_local") | ||||
|             c.close() | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 INADA Naoki
					INADA Naoki