Skip to content

Commit e70b985

Browse files
committed
BUG21530841: Select statement fails for results with more than 4096 columns
Using SELECT statements having results with more than 4096 columns fails. MySQL has hard limit of 4096 columns per table, but when using table joins this number can increase. This patch fixes this issue by removing the test for maximum table columns. A test was added for regression.
1 parent 27991a9 commit e70b985

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

lib/mysql/connector/protocol.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ def parse_column_count(self, packet):
227227
"""Parse a MySQL packet with the number of columns in result set"""
228228
try:
229229
count = utils.read_lc_int(packet[4:])[1]
230-
if count > MAX_MYSQL_TABLE_COLUMNS:
231-
return None
232230
return count
233231
except (struct.error, ValueError):
234232
raise errors.InterfaceError("Failed parsing column count")

tests/test_bugs.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,3 +4196,36 @@ def test_unicode_password(self):
41964196
self.fail('Failed using password with unicode characters')
41974197
else:
41984198
cnx.close()
4199+
4200+
4201+
class BugOra21530841(tests.MySQLConnectorTests):
4202+
"""BUG#21530841: SELECT FAILS WITH ILLEGAL RESULT SET ERROR WHEN COLUMN
4203+
COUNT IN RESULT > 4096
4204+
"""
4205+
def setUp(self):
4206+
config = tests.get_mysql_config()
4207+
self.cnx = connection.MySQLConnection(**config)
4208+
self.tbl = "Bug21530841"
4209+
self.cnx.cmd_query("DROP TABLE IF EXISTS {0}".format(self.tbl))
4210+
4211+
def tearDown(self):
4212+
self.cnx.cmd_query("DROP TABLE IF EXISTS {0}".format(self.tbl))
4213+
self.cnx.close()
4214+
4215+
def test_big_column_count(self):
4216+
cur = self.cnx.cursor(raw=False, buffered=False)
4217+
# Create table with 512 Columns
4218+
table = "CREATE TABLE t ({0})".format(
4219+
", ".join(["c{0} INT".format(idx) for idx in range(512)]))
4220+
cur.execute(table)
4221+
4222+
# Insert 1 record
4223+
cur.execute("INSERT INTO t(c1) values (1) ")
4224+
self.cnx.commit()
4225+
4226+
# Select from 10 tables
4227+
query = "SELECT * FROM {0} WHERE a1.c1 > 0".format(
4228+
", ".join(["t a{0}".format(idx) for idx in range(10)]))
4229+
cur.execute(query)
4230+
cur.fetchone()
4231+
cur.close()

0 commit comments

Comments
 (0)