Empty response when SELECTing MEDIUMTEXT or LONGTEXT columns
MySQL database connector for Python programming
Brought to you by:
adustman
When I select text that's longer than 64K from a MEDIUMTEXT or LONGTEXT column, I get an empty result:
import MySQLdb as mysql
conn=mysql.connect(user='',passwd='',host='',db='')
cursor=conn.cursor()
cursor.execute('select * from wbo where length(text) > 1000000')
18446744073709551615L
assert cursor.description
[raises AssertionError]
cursor.fetchall()
()
If you leave out the MEDIUMTEXT column from the selection, everything works fine:
cursor.execute('select id from table where length(text) > 1000000')
2L
cursor.fetchall()
(('1a9008a84520dc6ec5e4d6607174291d6b10efa3',), ('9781c913a78e90587af24706cb96bdbbc5e71a30',))
I'm on Linux with MySQL 5.0, Python 2.6, MySQLdb 1.2.3.
Note the wrong return value of the first execute() call.
I was not able to reproduce this on my Mac with MySQL 5.1, Python 2.6, MySQLdb 1.2.3. Any advice what other steps I could take to diagnose the issue?
The issue apparently was the max_allowed_packet setting in my my.cnf file. I originally set it to 1G, but if i change it to the byte value of 1G, everything works fine. I'm not sure if mysql-python has to support the 1K/M/G syntax.