Menu

#310 Empty response when SELECTing MEDIUMTEXT or LONGTEXT columns

open
MySQLdb (285)
5
2014-02-18
2011-03-18
No

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.

Discussion

  • Martin Kreichgauer

    Note the wrong return value of the first execute() call.

     
  • Martin Kreichgauer

    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?

     
  • Martin Kreichgauer

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.