Skip to content

Commit 2d1a626

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 de81a7a commit 2d1a626

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
@@ -4163,3 +4163,36 @@ def test_unicode_password(self):
41634163
self.fail('Failed using password with unicode characters')
41644164
else:
41654165
cnx.close()
4166+
4167+
4168+
class BugOra21530841(tests.MySQLConnectorTests):
4169+
"""BUG#21530841: SELECT FAILS WITH ILLEGAL RESULT SET ERROR WHEN COLUMN
4170+
COUNT IN RESULT > 4096
4171+
"""
4172+
def setUp(self):
4173+
config = tests.get_mysql_config()
4174+
self.cnx = connection.MySQLConnection(**config)
4175+
self.tbl = "Bug21530841"
4176+
self.cnx.cmd_query("DROP TABLE IF EXISTS {0}".format(self.tbl))
4177+
4178+
def tearDown(self):
4179+
self.cnx.cmd_query("DROP TABLE IF EXISTS {0}".format(self.tbl))
4180+
self.cnx.close()
4181+
4182+
def test_big_column_count(self):
4183+
cur = self.cnx.cursor(raw=False, buffered=False)
4184+
# Create table with 512 Columns
4185+
table = "CREATE TABLE t ({0})".format(
4186+
", ".join(["c{0} INT".format(idx) for idx in range(512)]))
4187+
cur.execute(table)
4188+
4189+
# Insert 1 record
4190+
cur.execute("INSERT INTO t(c1) values (1) ")
4191+
self.cnx.commit()
4192+
4193+
# Select from 10 tables
4194+
query = "SELECT * FROM {0} WHERE a1.c1 > 0".format(
4195+
", ".join(["t a{0}".format(idx) for idx in range(10)]))
4196+
cur.execute(query)
4197+
cur.fetchone()
4198+
cur.close()

0 commit comments

Comments
 (0)