Bug #97830 Contribution: fix CMySQLCursor.fetchmany
Submitted: 29 Nov 2019 15:19 Modified: 17 Jan 2020 23:35
Reporter: OCA Admin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:8.0, 8.0.18 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[29 Nov 2019 15:19] OCA Admin
Description:
This bug tracks a contribution by Bruce Feng (Github user: brucefeng10) as described in http://github.com/mysql/mysql-connector-python/pull/54

How to repeat:
See description

Suggested fix:
See contribution code attached
[29 Nov 2019 15:19] OCA Admin
Contribution submitted via Github - fix CMySQLCursor.fetchmany 
(*) Contribution by Bruce Feng (Github brucefeng10, mysql-connector-python/pull/54#issuecomment-559636345): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_331818206.txt (text/plain), 2.66 KiB.

[29 Nov 2019 15:31] Nuno Mariz
Hi,
I already verified the patch and fixes the issue.

Thank you.
[30 Nov 2019 3:51] MySQL Verification Team
Hello Bruce Feng,

Thank you for the report and contribution.

regards,
Umesh
[12 Dec 2019 5:06] MySQL Verification Team
Bug #97953 marked as duplicate of this one
[12 Dec 2019 5:07] MySQL Verification Team
Bug #96701 marked as duplicate of this one
[17 Jan 2020 23:35] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Python 8.0.20 release, and here's the proposed changelog entry by the documentation team:

The fetchmany() method failed to function properly when the last fetch was
not a full batch; and would hang. Thanks to Bruce Feng for the patch.

Thank you for the bug report.
[15 Aug 2023 15:13] Shahul Hameed
Looks like the bug is still there. The code.

	import mysql.connector

	dbconn = mysql.connector.connect(user = 'root', password = 'xxxxx')

	cur = dbconn.cursor()

	cur.execute('SELECT 100 UNION SELECT 200')

	print(cur.fetchmany(1))
	print(cur.fetchmany(1))
	print(cur.fetchmany(1))

gives the output:
[(100,)]
[(200,)]
[(200,)]

Though there are only two records in the resultset, three records are printed.

Software versions I am using:
MySQL Connector 8.1.0
MySQL Version 8.0
Python 3.11.2