Skip to content

Commit 67883f8

Browse files
committed
Merge branch 'BUG18742429' into develop
2 parents a016e3f + 6ab17de commit 67883f8

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

lib/mysql/connector/protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,12 @@ def _parse_binary_time(self, packet, field):
405405
def _parse_binary_values(self, fields, packet):
406406
"""Parse values from a binary result packet"""
407407
null_bitmap_length = (len(fields) + 7 + 2) // 8
408-
null_bitmap = utils.intread(packet[0:null_bitmap_length])
408+
null_bitmap = [int(i) for i in packet[0:null_bitmap_length]]
409409
packet = packet[null_bitmap_length:]
410410

411411
values = []
412412
for pos, field in enumerate(fields):
413-
if null_bitmap & 1 << (pos + 2):
413+
if null_bitmap[int((pos+2)/8)] & (1 << (pos + 2) % 8):
414414
values.append(None)
415415
continue
416416
elif field[1] in (FieldType.TINY, FieldType.SHORT,

tests/test_bugs.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,3 +2578,38 @@ def test_charset(self):
25782578

25792579
self.assertEqual(exp_nonunicode, res_nonunicode)
25802580
self.assertEqual(exp_unicode, res_unicode)
2581+
2582+
2583+
class BugOra18742429(tests.MySQLConnectorTests):
2584+
"""BUG#18742429: CPY FAILS WHEN QUERYING LARGE NUMBER OF COLUMNS
2585+
"""
2586+
def setUp(self):
2587+
config = tests.get_mysql_config()
2588+
self.cnx = connection.MySQLConnection(**config)
2589+
self.cursor = self.cnx.cursor()
2590+
2591+
self.tbl = 'Bug18742429'
2592+
self.cursor.execute("DROP TABLE IF EXISTS %s" % self.tbl)
2593+
2594+
create = 'CREATE TABLE {0}({1})'.format(self.tbl, ','.join(
2595+
['col'+str(i)+' INT(10)' for i in range(1000)]))
2596+
2597+
self.cursor.execute(create)
2598+
2599+
def tearDown(self):
2600+
self.cursor.execute("DROP TABLE IF EXISTS %s" % self.tbl)
2601+
self.cursor.close()
2602+
self.cnx.close()
2603+
2604+
def test_columns(self):
2605+
stmt = "INSERT INTO {0} VALUES({1})".format(self.tbl, ','.join(
2606+
[str(i) if i%2==0 else 'NULL' for i in range(1000)]
2607+
))
2608+
exp = tuple(i if i%2==0 else None for i in range(1000))
2609+
self.cursor.execute(stmt)
2610+
2611+
self.cursor = self.cnx.cursor(prepared=True)
2612+
stmt = 'SELECT * FROM {0} WHERE col0=?'.format(self.tbl)
2613+
self.cursor.execute(stmt, (0,))
2614+
self.assertEqual(exp, self.cursor.fetchone())
2615+

0 commit comments

Comments
 (0)