Fix for issue 38, thanks google@evax.fr

This commit is contained in:
Pete Hunt
2010-12-08 05:56:29 +00:00
parent 014ee3d136
commit edd8a1a895
2 changed files with 16 additions and 5 deletions

View File

@@ -46,7 +46,7 @@ UNSIGNED_INT24_LENGTH = 3
UNSIGNED_INT64_LENGTH = 8
DEFAULT_CHARSET = 'latin1'
BUFFER_SIZE = 256*256*256-1
MAX_PACKET_LENGTH = 256*256*256-1
def dump_packet(data):
@@ -667,10 +667,21 @@ class Connection(object):
return result.affected_rows
def _send_command(self, command, sql):
send_data = struct.pack('<i', len(sql) + 1) + command + sql
#send_data = struct.pack('<i', len(sql) + 1) + command + sql
# could probably be more efficient, at least it's correct
buf = command + sql
pckt_no = 0
while len(buf) >= MAX_PACKET_LENGTH:
header = struct.pack('<i', MAX_PACKET_LENGTH)[:-1]+chr(pckt_no)
self.socket.send(header+buf[:MAX_PACKET_LENGTH])
buf = buf[MAX_PACKET_LENGTH:]
pckt_no += 1
header = struct.pack('<i', len(buf))[:-1]+chr(pckt_no)
self.socket.send(header+buf)
sock = self.socket
sock.send(send_data)
#sock = self.socket
#sock.send(send_data)
if DEBUG: dump_packet(send_data)

View File

@@ -217,7 +217,7 @@ class TestNewIssues(base.PyMySQLTestCase):
def test_issue_38(self):
conn = self.connections[0]
c = conn.cursor()
datum = "a" * 1024 * 1024 * 64
datum = "a" * 1024 * 1023 # reduced size for most default mysql installs
try:
c.execute("create table issue38 (id integer, data mediumblob)")